My favorites | Sign in
Project Logo
                
Search
for
Updated Jan 08, 2009 by haineault
JqueryArrayUtils  

jquery.arrayUtils.js

Author Copyright (c) 2008 Maxime Haineault (haineault.com)
License MIT License

Introduction

Provide additional functional method to work with array. This library is largely inspired by the enumerables concept in the Prototype Javascript Library.

Methods

Method Returns Descriptions
$.all boolean Determines whether all the elements are boolean-equivalent to true, either directly or through computation by the provided iterator
$.any boolean Determines whether at least one element is boolean-equivalent to true, either directly or through computation by the provided iterator
$.detect mixed Finds the first element for which the iterator returns true
$.eachSlice array Groups items in chunks based on a given size, with last chunk being possibly smaller
$.inject number Incrementally builds a result value based on the successive results of the iterator. This can be used for array construction, numerical sums/averages, etc
$.invoke array Invokes the same method, with the same arguments, for all items in a collection. Returns the results of the method calls
$.max array Returns the maximum element (or element-based computation), or false if the enumeration is empty. Elements are either compared directly, or by first applying the iterator and comparing returned values
$.min array Returns the minimum element (or element-based computation), or false if the enumeration is empty. Elements are either compared directly, or by first applying the iterator and comparing returned values
$.partition array Partitions the elements in two groups: those regarded as true, and those considered false. By default, regular JavaScript boolean equivalence is used, but an iterator can be provided, that computes a boolean representation of the elements.
$.partition array Partitions the elements in two groups: those regarded as true, and those considered false. By default, regular JavaScript boolean equivalence is used, but an iterator can be provided, that computes a boolean representation of the elements.
$.pluck array Fetch the same property for all the elements and returns the property values
$.randomize array Returns a randomized version of an array
$.reject array Returns all the elements for which the iterator returned false
$.select array Returns all the elements for which the iterator returned true
$.sum number Returns the sum of a given array
$.zip array Zips together 2 sequences, providing an array of tuples. Each tuple contains one value per original sequence. Tuples can be converted to something else by applying the optional iterator on them.

Complementary methods

These methods are available with jQuery core.

Method Returns Descriptions
$.each array A generic iterator function, which can be used to seamlessly iterate over both objects and arrays
$.find array Searches for all elements that match the specified expression. This method is a good way to find additional descendant elements with which to process
$.grep array Filter items out of an array, by using a filter function
$.inArray number Determine the index of the first parameter in the Array (-1 if not found)
$.merge array Merge two arrays together. Removing all duplicates is removed in jQuery 1.1.3
$.map array Translate all items in an array to another array of items
$.slice array Selects a subset of the matched elements
$.unique array Remove all duplicate elements from an array of elements
$.size number Return the size of a collection or an array


Sign in to add a comment
Hosted by Google Code