Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pluck.js 931B

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[props[i]];
  21. if (typeof p !== 'undefined') {
  22. currentProp = p;
  23. }
  24. else {
  25. return undefined;
  26. }
  27. }
  28. return currentProp;
  29. };
  30. return mapper;
  31. }
  32. //# sourceMappingURL=pluck.js.map