Urara-Blog/node_modules/.pnpm-store/v3/files/b5/5df435031c3fd290841ab826efb5839c6fcef31e8e724a17699f1ed69a7017552c6acfa27fca3f979e8942c36d5a98803adbc815b77e41b5268ef562bd5097
2022-08-14 01:14:53 +08:00

30 lines
732 B
Text

var baseGet = require('./_baseGet');
/**
* The opposite of `_.property`; this method creates a function that returns
* the value at a given path of `object`.
*
* @static
* @memberOf _
* @since 3.0.0
* @category Util
* @param {Object} object The object to query.
* @returns {Function} Returns the new accessor function.
* @example
*
* var array = [0, 1, 2],
* object = { 'a': array, 'b': array, 'c': array };
*
* _.map(['a[2]', 'c[0]'], _.propertyOf(object));
* // => [2, 0]
*
* _.map([['a', '2'], ['c', '0']], _.propertyOf(object));
* // => [2, 0]
*/
function propertyOf(object) {
return function(path) {
return object == null ? undefined : baseGet(object, path);
};
}
module.exports = propertyOf;