main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
730 bytes
|
Line | |
---|
1 | import baseGet from './_baseGet.js';
|
---|
2 |
|
---|
3 | /**
|
---|
4 | * The opposite of `_.property`; this method creates a function that returns
|
---|
5 | * the value at a given path of `object`.
|
---|
6 | *
|
---|
7 | * @static
|
---|
8 | * @memberOf _
|
---|
9 | * @since 3.0.0
|
---|
10 | * @category Util
|
---|
11 | * @param {Object} object The object to query.
|
---|
12 | * @returns {Function} Returns the new accessor 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 object == null ? undefined : baseGet(object, path);
|
---|
27 | };
|
---|
28 | }
|
---|
29 |
|
---|
30 | export default propertyOf;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.