@newdash/newdash
Version:
javascript/typescript utility library
32 lines (31 loc) • 926 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const baseGet_1 = __importDefault(require("./.internal/baseGet"));
/**
* The opposite of `property`s method creates a function that returns
* the value at a given path of `object`.
*
* @since 5.0.0
* @category Util
* @param object The object to query.
* @returns Returns the new accessor function.
* @example
*
* ```js
* const array = [0, 1, 2]
* const 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 (path) => object == null ? undefined : (0, baseGet_1.default)(object, path);
}
exports.default = propertyOf;