Initial commit
[yaffs-website] / node_modules / grunt-contrib-watch / node_modules / lodash / collection / pluck.js
1 var map = require('./map'),
2     property = require('../utility/property');
3
4 /**
5  * Gets the property value of `path` from all elements in `collection`.
6  *
7  * @static
8  * @memberOf _
9  * @category Collection
10  * @param {Array|Object|string} collection The collection to iterate over.
11  * @param {Array|string} path The path of the property to pluck.
12  * @returns {Array} Returns the property values.
13  * @example
14  *
15  * var users = [
16  *   { 'user': 'barney', 'age': 36 },
17  *   { 'user': 'fred',   'age': 40 }
18  * ];
19  *
20  * _.pluck(users, 'user');
21  * // => ['barney', 'fred']
22  *
23  * var userIndex = _.indexBy(users, 'user');
24  * _.pluck(userIndex, 'age');
25  * // => [36, 40] (iteration order is not guaranteed)
26  */
27 function pluck(collection, path) {
28   return map(collection, property(path));
29 }
30
31 module.exports = pluck;