UNPKG

@newdash/newdash

Version:

javascript/typescript utility library

31 lines (30 loc) 575 B
import { Path } from "./types"; /** * @ignore */ interface Accessor { (obj: any): any; } /** * Creates a function that returns the value at `path` of a given object. * * @since 5.0.0 * @category Util * @param path The path of the property to get. * @example * * ```js * const objects = [ * { 'a': { 'b': 2 } }, * { 'a': { 'b': 1 } } * ] * * map(objects, property('a.b')) * // => [2, 1] * * map(sortBy(objects, property(['a', 'b'])), 'a.b') * // => [1, 2] * ``` */ export declare function property(path: Path): Accessor; export default property;