My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
modify  
Overview of modify
Updated Apr 30, 2010 by matr...@mac.com

modify

Action that modifies objects in an array by replacing them for the return of the changer function

Usage

objx( array ).modify( changer [, behaviour);

array The array containing the objects to select from
changer (required) The each callback function that returns the replacement object
behaviour (required) Must be OOriginal since modify changes the original array anyway, see actions

Example

var selectTestObjects = [
	{ name: "Mat", age: 26 },
	{ name: "Simon", age: 23 },
	{ name: "Laurie", age: 25 },
	{ name: "Chris", age: 21 },
	{ name: "Corey", age: 1 }
];

objx(selectTestObjects).select(function(o,i){ return { user: o, index: i }; }, OOriginal);
/*
returns [
{user: { name: "Mat", age: 26 }, index: 0},
{user: { name: "Simon", age: 23 }, index: 1},
{user: { name: "Laurie", age: 25 }, index: 2},
{user: { name: "Chris", age: 21 }, index: 3},
{user: { name: "Corey", age: 1 } index: 4}
]
*/

Sign in to add a comment
Powered by Google Project Hosting