takeWhile.js 732 B

123456789101112131415161718
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.takeWhile = void 0;
  4. var lift_1 = require("../util/lift");
  5. var OperatorSubscriber_1 = require("./OperatorSubscriber");
  6. function takeWhile(predicate, inclusive) {
  7. if (inclusive === void 0) { inclusive = false; }
  8. return lift_1.operate(function (source, subscriber) {
  9. var index = 0;
  10. source.subscribe(OperatorSubscriber_1.createOperatorSubscriber(subscriber, function (value) {
  11. var result = predicate(value, index++);
  12. (result || inclusive) && subscriber.next(value);
  13. !result && subscriber.complete();
  14. }));
  15. });
  16. }
  17. exports.takeWhile = takeWhile;
  18. //# sourceMappingURL=takeWhile.js.map