a3b9c2799c65060c2d81b79921f5792db73f057b
[platform/framework/web/crosswalk-tizen.git] /
1 var baseGet = require('../internal/baseGet'),
2     toPath = require('../internal/toPath');
3
4 /**
5  * The opposite of `_.property`; this method creates a function which returns
6  * the property value at a given path on `object`.
7  *
8  * @static
9  * @memberOf _
10  * @category Utility
11  * @param {Object} object The object to query.
12  * @returns {Function} Returns the new function.
13  * @example
14  *
15  * var array = [0, 1, 2],
16  *     object = { 'a': array, 'b': array, 'c': array };
17  *
18  * _.map(['a[2]', 'c[0]'], _.propertyOf(object));
19  * // => [2, 0]
20  *
21  * _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
22  * // => [2, 0]
23  */
24 function propertyOf(object) {
25   return function(path) {
26     return baseGet(object, toPath(path), path + '');
27   };
28 }
29
30 module.exports = propertyOf;