source: frontend/node_modules/underscore/modules/result.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 745 bytes
Line 
1import isFunction from './isFunction.js';
2import toPath from './_toPath.js';
3
4// Traverses the children of `obj` along `path`. If a child is a function, it
5// is invoked with its parent as context. Returns the value of the final
6// child, or `fallback` if any child is undefined.
7export default function result(obj, path, fallback) {
8 path = toPath(path);
9 var length = path.length;
10 if (!length) {
11 return isFunction(fallback) ? fallback.call(obj) : fallback;
12 }
13 for (var i = 0; i < length; i++) {
14 var prop = obj == null ? void 0 : obj[path[i]];
15 if (prop === void 0) {
16 prop = fallback;
17 i = length; // Ensure we don't continue iterating.
18 }
19 obj = isFunction(prop) ? prop.call(obj) : prop;
20 }
21 return obj;
22}
Note: See TracBrowser for help on using the repository browser.