pluck.js 879 B

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