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.

takeWhile.js 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. "use strict";
  2. var __extends = (this && this.__extends) || (function () {
  3. var extendStatics = function (d, b) {
  4. extendStatics = Object.setPrototypeOf ||
  5. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  7. return extendStatics(d, b);
  8. }
  9. return function (d, b) {
  10. extendStatics(d, b);
  11. function __() { this.constructor = d; }
  12. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13. };
  14. })();
  15. Object.defineProperty(exports, "__esModule", { value: true });
  16. var Subscriber_1 = require("../Subscriber");
  17. function takeWhile(predicate) {
  18. return function (source) { return source.lift(new TakeWhileOperator(predicate)); };
  19. }
  20. exports.takeWhile = takeWhile;
  21. var TakeWhileOperator = (function () {
  22. function TakeWhileOperator(predicate) {
  23. this.predicate = predicate;
  24. }
  25. TakeWhileOperator.prototype.call = function (subscriber, source) {
  26. return source.subscribe(new TakeWhileSubscriber(subscriber, this.predicate));
  27. };
  28. return TakeWhileOperator;
  29. }());
  30. var TakeWhileSubscriber = (function (_super) {
  31. __extends(TakeWhileSubscriber, _super);
  32. function TakeWhileSubscriber(destination, predicate) {
  33. var _this = _super.call(this, destination) || this;
  34. _this.predicate = predicate;
  35. _this.index = 0;
  36. return _this;
  37. }
  38. TakeWhileSubscriber.prototype._next = function (value) {
  39. var destination = this.destination;
  40. var result;
  41. try {
  42. result = this.predicate(value, this.index++);
  43. }
  44. catch (err) {
  45. destination.error(err);
  46. return;
  47. }
  48. this.nextOrComplete(value, result);
  49. };
  50. TakeWhileSubscriber.prototype.nextOrComplete = function (value, predicateResult) {
  51. var destination = this.destination;
  52. if (Boolean(predicateResult)) {
  53. destination.next(value);
  54. }
  55. else {
  56. destination.complete();
  57. }
  58. };
  59. return TakeWhileSubscriber;
  60. }(Subscriber_1.Subscriber));
  61. //# sourceMappingURL=takeWhile.js.map