Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

every.js 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 every(predicate, thisArg) {
  18. return function (source) { return source.lift(new EveryOperator(predicate, thisArg, source)); };
  19. }
  20. exports.every = every;
  21. var EveryOperator = (function () {
  22. function EveryOperator(predicate, thisArg, source) {
  23. this.predicate = predicate;
  24. this.thisArg = thisArg;
  25. this.source = source;
  26. }
  27. EveryOperator.prototype.call = function (observer, source) {
  28. return source.subscribe(new EverySubscriber(observer, this.predicate, this.thisArg, this.source));
  29. };
  30. return EveryOperator;
  31. }());
  32. var EverySubscriber = (function (_super) {
  33. __extends(EverySubscriber, _super);
  34. function EverySubscriber(destination, predicate, thisArg, source) {
  35. var _this = _super.call(this, destination) || this;
  36. _this.predicate = predicate;
  37. _this.thisArg = thisArg;
  38. _this.source = source;
  39. _this.index = 0;
  40. _this.thisArg = thisArg || _this;
  41. return _this;
  42. }
  43. EverySubscriber.prototype.notifyComplete = function (everyValueMatch) {
  44. this.destination.next(everyValueMatch);
  45. this.destination.complete();
  46. };
  47. EverySubscriber.prototype._next = function (value) {
  48. var result = false;
  49. try {
  50. result = this.predicate.call(this.thisArg, value, this.index++, this.source);
  51. }
  52. catch (err) {
  53. this.destination.error(err);
  54. return;
  55. }
  56. if (!result) {
  57. this.notifyComplete(false);
  58. }
  59. };
  60. EverySubscriber.prototype._complete = function () {
  61. this.notifyComplete(true);
  62. };
  63. return EverySubscriber;
  64. }(Subscriber_1.Subscriber));
  65. //# sourceMappingURL=every.js.map