-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
212 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import _ from './underscore.js'; | ||
import './toPath.js'; | ||
|
||
// Internal wrapper for `_.toPath` to enable minification. | ||
// Similar to `cb` for `_.iteratee`. | ||
export default function toPath(path) { | ||
return _.toPath(path); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import toPath from './_toPath.js'; | ||
import deepGet from './_deepGet.js'; | ||
import isUndefined from './isUndefined.js'; | ||
|
||
// Get the value of the (deep) property on `path` from `object`. | ||
// If any property in `path` does not exist or if the value is | ||
// `undefined`, return `defaultValue` instead. | ||
// The `path` is normalized through `_.toPath`. | ||
export default function get(object, path, defaultValue) { | ||
var value = deepGet(object, toPath(path)); | ||
return isUndefined(value) ? defaultValue : value; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
import isArray from './isArray.js'; | ||
import deepGet from './_deepGet.js'; | ||
import noop from './noop.js'; | ||
import get from './get.js'; | ||
|
||
// Generates a function for a given object that returns a given property. | ||
export default function propertyOf(obj) { | ||
if (obj == null) { | ||
return function(){}; | ||
} | ||
if (obj == null) return noop; | ||
return function(path) { | ||
return !isArray(path) ? obj[path] : deepGet(obj, path); | ||
return get(obj, path); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import _ from './underscore.js'; | ||
import isArray from './isArray.js'; | ||
|
||
// Normalize a (deep) property `path` to array. | ||
// Like `_.iteratee`, this function can be customized. | ||
export default function toPath(path) { | ||
return isArray(path) ? path : [path]; | ||
} | ||
_.toPath = toPath; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.