Skip to content

Commit

Permalink
Merge pull request #1013 from buzzdecafe/pluck-xf
Browse files Browse the repository at this point in the history
make pluck behave with transducers, fixes #1012
  • Loading branch information
CrossEye committed Apr 6, 2015
2 parents e95088f + 13097b9 commit fe356b6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/internal/_pluck.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var _map = require('./_map');
var map = require('../map');
var prop = require('../prop');


module.exports = function _pluck(p, list) {
return _map(prop(p), list);
return map(prop(p), list);
};
7 changes: 7 additions & 0 deletions test/pluck.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,11 @@ describe('pluck', function() {
assert.strictEqual(typeof nm, 'function');
assert.deepEqual(nm(people), ['Fred', 'Wilma', 'Pebbles']);
});

it('behaves as a transducer when given a transducer in list position', function() {
var numbers = [{a: 1}, {a: 2}, {a: 3}, {a: 4}];
var transducer = R.compose(R.pluck('a'), R.map(R.add(1)), R.take(2));
assert.deepEqual(R.transduce(transducer, R.flip(R.append), [], numbers), [2, 3]);
});

});

0 comments on commit fe356b6

Please sign in to comment.