elementAt.js 924 B

12345678910111213141516171819
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.elementAt = void 0;
  4. var ArgumentOutOfRangeError_1 = require("../util/ArgumentOutOfRangeError");
  5. var filter_1 = require("./filter");
  6. var throwIfEmpty_1 = require("./throwIfEmpty");
  7. var defaultIfEmpty_1 = require("./defaultIfEmpty");
  8. var take_1 = require("./take");
  9. function elementAt(index, defaultValue) {
  10. if (index < 0) {
  11. throw new ArgumentOutOfRangeError_1.ArgumentOutOfRangeError();
  12. }
  13. var hasDefaultValue = arguments.length >= 2;
  14. return function (source) {
  15. return source.pipe(filter_1.filter(function (v, i) { return i === index; }), take_1.take(1), hasDefaultValue ? defaultIfEmpty_1.defaultIfEmpty(defaultValue) : throwIfEmpty_1.throwIfEmpty(function () { return new ArgumentOutOfRangeError_1.ArgumentOutOfRangeError(); }));
  16. };
  17. }
  18. exports.elementAt = elementAt;
  19. //# sourceMappingURL=elementAt.js.map