This plugin generates generic collection classes, that work almost exactly as jQuery does. These collections include all those jQuery functions, that are used to manipulate the collection itself. The supported functions are:
add, andSelf, attr, each, end, eq, extend, filter, get, implement, include, index, init, is, map, not, pushStack, setArray, size and slice.The init() function included is a basic and generic one. It should be (likely) modified for each collection, to suit the needs. The include() function, is an invention of the plugin, it works similary to extend(), it will copy the listed attributes/methods from target to source. If target's not specified, then it will be the caller(like extend). The arguments are .include([ target,] source, methods ). Every collection will have a build() function, that will create a new collection class, that inherits from the caller. $.collection is a collection class by itself. So other collections will inherit from it, or its subclasses. The filter() function accepts:
- A function that returns true/false.
- Anything else will be taken literally and compared. Only those items included pass the filter. The filter can be an array of items.
$.collection(1,2,3,4).filter([2,3]);//--> [ 2, 3 ]The function .not() works the same way, but matches the opposite.
Links: Downloads:
- jQuery.Collection 1.0.3 Zip(all files and docs)
- jQuery.Collection 1.0.3 Source(to learn or test)
- jQuery.Collection 1.0.3 Minified(recommended)
I really advice using the minified versions. The code is optimized for those releases. Source versions should only be used to learn.