Skip to content

Commit

Permalink
added Iter.pluck() (trvial, useful, but mostly since the name/concept…
Browse files Browse the repository at this point in the history
… seems to have caught on in other libs)
  • Loading branch information
blq committed May 28, 2013
1 parent 557876e commit a6fb37b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions MochiKit/Iter-ext.js
Expand Up @@ -930,6 +930,7 @@ MochiKit.Iter.limit = function(iter, n) {
*
* @param {!Iterable} iterable
* @param {Function=} [func=operator.add]
* @return {!Iterable}
*/
MochiKit.Iter.accumulate = function(iterable, func) {
var iter = MochiKit.Iter.iter(iterable);
Expand All @@ -951,6 +952,20 @@ MochiKit.Iter.accumulate = function(iterable, func) {
};


/**
* Maps a property name
* useful?
* (mostly since it seems like this name might have caught on(?) (see Underscore etc) )
*
* @param {!terable} iterable
* @param {string} property
* @return {!Iterable}
*/
MochiKit.Iter.pluck = function(iterable, property) {
return MochiKit.Iter.imap(MochiKit.Base.itemgetter(property), iterable);
};


//--------------------------------

MochiKit.Iter_ext.__new__ = function() {
Expand Down

0 comments on commit a6fb37b

Please sign in to comment.