Added the underscore node_module.
All checks were successful
Auto Maintenance Cycle / pre-commit Autoupdate (push) Successful in 39s
All checks were successful
Auto Maintenance Cycle / pre-commit Autoupdate (push) Successful in 39s
This commit is contained in:
25
node_modules/underscore/amd/result.js
generated
vendored
Normal file
25
node_modules/underscore/amd/result.js
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
define(['./isFunction', './_toPath'], function (isFunction, _toPath) {
|
||||
|
||||
// Traverses the children of `obj` along `path`. If a child is a function, it
|
||||
// is invoked with its parent as context. Returns the value of the final
|
||||
// child, or `fallback` if any child is undefined.
|
||||
function result(obj, path, fallback) {
|
||||
path = _toPath(path);
|
||||
var length = path.length;
|
||||
if (!length) {
|
||||
return isFunction(fallback) ? fallback.call(obj) : fallback;
|
||||
}
|
||||
for (var i = 0; i < length; i++) {
|
||||
var prop = obj == null ? void 0 : obj[path[i]];
|
||||
if (prop === void 0) {
|
||||
prop = fallback;
|
||||
i = length; // Ensure we don't continue iterating.
|
||||
}
|
||||
obj = isFunction(prop) ? prop.call(obj) : prop;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
});
|
Reference in New Issue
Block a user