pickit
v0.1.1
Published
Pick a single item from an array
Downloads
6
Readme
pickit
var pick = require('pickit');
var array = [
{name: 'James', age: 36, siblings: 3},
{name: 'Susan', age: 40, siblings: 2},
{name: 'Noah', age: 4, siblings: 1}
];
// supply a callback
pick.max(array, function (x) {return x.age;}); // {name: 'Susan', ...}
// or a string property name
pick.max(array, 'siblings'); // {name: 'James', ...}
pick.min(array, 'siblings')/ // {name: 'Noah', ...}
polyfill
pickit
requires that Array.prototype.reduce
be implemented (IE 9
or greater).
A copy of the standard polyfill is included for your convenience (reduce-polyfill.js
).