You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
458 B
16 lines
458 B
import isString from './is-string';
|
|
/**
|
|
* https://github.com/developit/dlv/blob/master/index.js
|
|
* @param obj
|
|
* @param key
|
|
* @param defaultValue
|
|
*/
|
|
export default (function (obj, key, defaultValue) {
|
|
var p = 0;
|
|
var keyArr = isString(key) ? key.split('.') : key;
|
|
while (obj && p < keyArr.length) {
|
|
obj = obj[keyArr[p++]];
|
|
}
|
|
return obj === undefined || p < keyArr.length ? defaultValue : obj;
|
|
});
|
|
//# sourceMappingURL=get.js.map
|