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

pluck.js 953B

1234567891011121314151617181920212223242526272829303132
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var map_1 = require("./map");
  4. function pluck() {
  5. var properties = [];
  6. for (var _i = 0; _i < arguments.length; _i++) {
  7. properties[_i] = arguments[_i];
  8. }
  9. var length = properties.length;
  10. if (length === 0) {
  11. throw new Error('list of properties cannot be empty.');
  12. }
  13. return function (source) { return map_1.map(plucker(properties, length))(source); };
  14. }
  15. exports.pluck = pluck;
  16. function plucker(props, length) {
  17. var mapper = function (x) {
  18. var currentProp = x;
  19. for (var i = 0; i < length; i++) {
  20. var p = currentProp != null ? currentProp[props[i]] : undefined;
  21. if (p !== void 0) {
  22. currentProp = p;
  23. }
  24. else {
  25. return undefined;
  26. }
  27. }
  28. return currentProp;
  29. };
  30. return mapper;
  31. }
  32. //# sourceMappingURL=pluck.js.map