54e95eb6a81540c29d1f842b1444feb698728487
[yaffs-website] / node_modules / grunt-legacy-log-utils / node_modules / lodash / property.js
1 var baseProperty = require('./_baseProperty'),
2     basePropertyDeep = require('./_basePropertyDeep'),
3     isKey = require('./_isKey');
4
5 /**
6  * Creates a function that returns the value at `path` of a given object.
7  *
8  * @static
9  * @memberOf _
10  * @category Util
11  * @param {Array|string} path The path of the property to get.
12  * @returns {Function} Returns the new function.
13  * @example
14  *
15  * var objects = [
16  *   { 'a': { 'b': { 'c': 2 } } },
17  *   { 'a': { 'b': { 'c': 1 } } }
18  * ];
19  *
20  * _.map(objects, _.property('a.b.c'));
21  * // => [2, 1]
22  *
23  * _.map(_.sortBy(objects, _.property(['a', 'b', 'c'])), 'a.b.c');
24  * // => [1, 2]
25  */
26 function property(path) {
27   return isKey(path) ? baseProperty(path) : basePropertyDeep(path);
28 }
29
30 module.exports = property;