1var baseGet = require('../internal/baseGet'), 2 toPath = require('../internal/toPath'); 3 4/** 5 * The opposite of `_.property`; this method creates a function that 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 */ 24function propertyOf(object) { 25 return function(path) { 26 return baseGet(object, toPath(path), path + ''); 27 }; 28} 29 30module.exports = propertyOf; 31 32