|
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:
786 bytes
|
| Line | |
|---|
| 1 | define(['./isFunction', './_toPath'], function (isFunction, _toPath) {
|
|---|
| 2 |
|
|---|
| 3 | // Traverses the children of `obj` along `path`. If a child is a function, it
|
|---|
| 4 | // is invoked with its parent as context. Returns the value of the final
|
|---|
| 5 | // child, or `fallback` if any child is undefined.
|
|---|
| 6 | function result(obj, path, fallback) {
|
|---|
| 7 | path = _toPath(path);
|
|---|
| 8 | var length = path.length;
|
|---|
| 9 | if (!length) {
|
|---|
| 10 | return isFunction(fallback) ? fallback.call(obj) : fallback;
|
|---|
| 11 | }
|
|---|
| 12 | for (var i = 0; i < length; i++) {
|
|---|
| 13 | var prop = obj == null ? void 0 : obj[path[i]];
|
|---|
| 14 | if (prop === void 0) {
|
|---|
| 15 | prop = fallback;
|
|---|
| 16 | i = length; // Ensure we don't continue iterating.
|
|---|
| 17 | }
|
|---|
| 18 | obj = isFunction(prop) ? prop.call(obj) : prop;
|
|---|
| 19 | }
|
|---|
| 20 | return obj;
|
|---|
| 21 | }
|
|---|
| 22 |
|
|---|
| 23 | return result;
|
|---|
| 24 |
|
|---|
| 25 | });
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.