Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

result.js 799B

12345678910111213141516171819202122232425
  1. define(['./isFunction', './isArray'], function (isFunction, isArray) {
  2. // Traverses the children of `obj` along `path`. If a child is a function, it
  3. // is invoked with its parent as context. Returns the value of the final
  4. // child, or `fallback` if any child is undefined.
  5. function result(obj, path, fallback) {
  6. if (!isArray(path)) path = [path];
  7. var length = path.length;
  8. if (!length) {
  9. return isFunction(fallback) ? fallback.call(obj) : fallback;
  10. }
  11. for (var i = 0; i < length; i++) {
  12. var prop = obj == null ? void 0 : obj[path[i]];
  13. if (prop === void 0) {
  14. prop = fallback;
  15. i = length; // Ensure we don't continue iterating.
  16. }
  17. obj = isFunction(prop) ? prop.call(obj) : prop;
  18. }
  19. return obj;
  20. }
  21. return result;
  22. });