4 Version 2.0, January 2004
5 http://www.apache.org/licenses/
7 TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
11 "License" shall mean the terms and conditions for use, reproduction,
12 and distribution as defined by Sections 1 through 9 of this document.
14 "Licensor" shall mean the copyright owner or entity authorized by
15 the copyright owner that is granting the License.
17 "Legal Entity" shall mean the union of the acting entity and all
18 other entities that control, are controlled by, or are under common
19 control with that entity. For the purposes of this definition,
20 "control" means (i) the power, direct or indirect, to cause the
21 direction or management of such entity, whether by contract or
22 otherwise, or (ii) ownership of fifty percent (50%) or more of the
23 outstanding shares, or (iii) beneficial ownership of such entity.
25 "You" (or "Your") shall mean an individual or Legal Entity
26 exercising permissions granted by this License.
28 "Source" form shall mean the preferred form for making modifications,
29 including but not limited to software source code, documentation
30 source, and configuration files.
32 "Object" form shall mean any form resulting from mechanical
33 transformation or translation of a Source form, including but
34 not limited to compiled object code, generated documentation,
35 and conversions to other media types.
37 "Work" shall mean the work of authorship, whether in Source or
38 Object form, made available under the License, as indicated by a
39 copyright notice that is included in or attached to the work
40 (an example is provided in the Appendix below).
42 "Derivative Works" shall mean any work, whether in Source or Object
43 form, that is based on (or derived from) the Work and for which the
44 editorial revisions, annotations, elaborations, or other modifications
45 represent, as a whole, an original work of authorship. For the purposes
46 of this License, Derivative Works shall not include works that remain
47 separable from, or merely link (or bind by name) to the interfaces of,
48 the Work and Derivative Works thereof.
50 "Contribution" shall mean any work of authorship, including
51 the original version of the Work and any modifications or additions
52 to that Work or Derivative Works thereof, that is intentionally
53 submitted to Licensor for inclusion in the Work by the copyright owner
54 or by an individual or Legal Entity authorized to submit on behalf of
55 the copyright owner. For the purposes of this definition, "submitted"
56 means any form of electronic, verbal, or written communication sent
57 to the Licensor or its representatives, including but not limited to
58 communication on electronic mailing lists, source code control systems,
59 and issue tracking systems that are managed by, or on behalf of, the
60 Licensor for the purpose of discussing and improving the Work, but
61 excluding communication that is conspicuously marked or otherwise
62 designated in writing by the copyright owner as "Not a Contribution."
64 "Contributor" shall mean Licensor and any individual or Legal Entity
65 on behalf of whom a Contribution has been received by Licensor and
66 subsequently incorporated within the Work.
68 2. Grant of Copyright License. Subject to the terms and conditions of
69 this License, each Contributor hereby grants to You a perpetual,
70 worldwide, non-exclusive, no-charge, royalty-free, irrevocable
71 copyright license to reproduce, prepare Derivative Works of,
72 publicly display, publicly perform, sublicense, and distribute the
73 Work and such Derivative Works in Source or Object form.
75 3. Grant of Patent License. Subject to the terms and conditions of
76 this License, each Contributor hereby grants to You a perpetual,
77 worldwide, non-exclusive, no-charge, royalty-free, irrevocable
78 (except as stated in this section) patent license to make, have made,
79 use, offer to sell, sell, import, and otherwise transfer the Work,
80 where such license applies only to those patent claims licensable
81 by such Contributor that are necessarily infringed by their
82 Contribution(s) alone or by combination of their Contribution(s)
83 with the Work to which such Contribution(s) was submitted. If You
84 institute patent litigation against any entity (including a
85 cross-claim or counterclaim in a lawsuit) alleging that the Work
86 or a Contribution incorporated within the Work constitutes direct
87 or contributory patent infringement, then any patent licenses
88 granted to You under this License for that Work shall terminate
89 as of the date such litigation is filed.
91 4. Redistribution. You may reproduce and distribute copies of the
92 Work or Derivative Works thereof in any medium, with or without
93 modifications, and in Source or Object form, provided that You
94 meet the following conditions:
96 (a) You must give any other recipients of the Work or
97 Derivative Works a copy of this License; and
99 (b) You must cause any modified files to carry prominent notices
100 stating that You changed the files; and
102 (c) You must retain, in the Source form of any Derivative Works
103 that You distribute, all copyright, patent, trademark, and
104 attribution notices from the Source form of the Work,
105 excluding those notices that do not pertain to any part of
106 the Derivative Works; and
108 (d) If the Work includes a "NOTICE" text file as part of its
109 distribution, then any Derivative Works that You distribute must
110 include a readable copy of the attribution notices contained
111 within such NOTICE file, excluding those notices that do not
112 pertain to any part of the Derivative Works, in at least one
113 of the following places: within a NOTICE text file distributed
114 as part of the Derivative Works; within the Source form or
115 documentation, if provided along with the Derivative Works; or,
116 within a display generated by the Derivative Works, if and
117 wherever such third-party notices normally appear. The contents
118 of the NOTICE file are for informational purposes only and
119 do not modify the License. You may add Your own attribution
120 notices within Derivative Works that You distribute, alongside
121 or as an addendum to the NOTICE text from the Work, provided
122 that such additional attribution notices cannot be construed
123 as modifying the License.
125 You may add Your own copyright statement to Your modifications and
126 may provide additional or different license terms and conditions
127 for use, reproduction, or distribution of Your modifications, or
128 for any such Derivative Works as a whole, provided Your use,
129 reproduction, and distribution of the Work otherwise complies with
130 the conditions stated in this License.
132 5. Submission of Contributions. Unless You explicitly state otherwise,
133 any Contribution intentionally submitted for inclusion in the Work
134 by You to the Licensor shall be under the terms and conditions of
135 this License, without any additional terms or conditions.
136 Notwithstanding the above, nothing herein shall supersede or modify
137 the terms of any separate license agreement you may have executed
138 with Licensor regarding such Contributions.
140 6. Trademarks. This License does not grant permission to use the trade
141 names, trademarks, service marks, or product names of the Licensor,
142 except as required for reasonable and customary use in describing the
143 origin of the Work and reproducing the content of the NOTICE file.
145 7. Disclaimer of Warranty. Unless required by applicable law or
146 agreed to in writing, Licensor provides the Work (and each
147 Contributor provides its Contributions) on an "AS IS" BASIS,
148 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
149 implied, including, without limitation, any warranties or conditions
150 of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
151 PARTICULAR PURPOSE. You are solely responsible for determining the
152 appropriateness of using or redistributing the Work and assume any
153 risks associated with Your exercise of permissions under this License.
155 8. Limitation of Liability. In no event and under no legal theory,
156 whether in tort (including negligence), contract, or otherwise,
157 unless required by applicable law (such as deliberate and grossly
158 negligent acts) or agreed to in writing, shall any Contributor be
159 liable to You for damages, including any direct, indirect, special,
160 incidental, or consequential damages of any character arising as a
161 result of this License or out of the use or inability to use the
162 Work (including but not limited to damages for loss of goodwill,
163 work stoppage, computer failure or malfunction, or any and all
164 other commercial damages or losses), even if such Contributor
165 has been advised of the possibility of such damages.
167 9. Accepting Warranty or Additional Liability. While redistributing
168 the Work or Derivative Works thereof, You may choose to offer,
169 and charge a fee for, acceptance of support, warranty, indemnity,
170 or other liability obligations and/or rights consistent with this
171 License. However, in accepting such obligations, You may act only
172 on Your own behalf and on Your sole responsibility, not on behalf
173 of any other Contributor, and only if You agree to indemnify,
174 defend, and hold each Contributor harmless for any liability
175 incurred by, or claims asserted against, such Contributor by reason
176 of your accepting any such warranty or additional liability.
178 END OF TERMS AND CONDITIONS
180 APPENDIX: How to apply the Apache License to your work.
182 To apply the Apache License to your work, attach the following
183 boilerplate notice, with the fields enclosed by brackets "[]"
184 replaced with your own identifying information. (Don't include
185 the brackets!) The text should be enclosed in the appropriate
186 comment syntax for the file format. We also recommend that a
187 file or class name and description of purpose be included on the
188 same "printed page" as the copyright notice for easier
189 identification within third-party archives.
191 Copyright (c) 2015-2018 Google, Inc., Netflix, Inc., Microsoft Corp. and contributors
193 Licensed under the Apache License, Version 2.0 (the "License");
194 you may not use this file except in compliance with the License.
195 You may obtain a copy of the License at
197 http://www.apache.org/licenses/LICENSE-2.0
199 Unless required by applicable law or agreed to in writing, software
200 distributed under the License is distributed on an "AS IS" BASIS,
201 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
202 See the License for the specific language governing permissions and
203 limitations under the License.
210 Version 2.0, January 2004
211 http://www.apache.org/licenses/
213 TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
217 "License" shall mean the terms and conditions for use, reproduction,
218 and distribution as defined by Sections 1 through 9 of this document.
220 "Licensor" shall mean the copyright owner or entity authorized by
221 the copyright owner that is granting the License.
223 "Legal Entity" shall mean the union of the acting entity and all
224 other entities that control, are controlled by, or are under common
225 control with that entity. For the purposes of this definition,
226 "control" means (i) the power, direct or indirect, to cause the
227 direction or management of such entity, whether by contract or
228 otherwise, or (ii) ownership of fifty percent (50%) or more of the
229 outstanding shares, or (iii) beneficial ownership of such entity.
231 "You" (or "Your") shall mean an individual or Legal Entity
232 exercising permissions granted by this License.
234 "Source" form shall mean the preferred form for making modifications,
235 including but not limited to software source code, documentation
236 source, and configuration files.
238 "Object" form shall mean any form resulting from mechanical
239 transformation or translation of a Source form, including but
240 not limited to compiled object code, generated documentation,
241 and conversions to other media types.
243 "Work" shall mean the work of authorship, whether in Source or
244 Object form, made available under the License, as indicated by a
245 copyright notice that is included in or attached to the work
246 (an example is provided in the Appendix below).
248 "Derivative Works" shall mean any work, whether in Source or Object
249 form, that is based on (or derived from) the Work and for which the
250 editorial revisions, annotations, elaborations, or other modifications
251 represent, as a whole, an original work of authorship. For the purposes
252 of this License, Derivative Works shall not include works that remain
253 separable from, or merely link (or bind by name) to the interfaces of,
254 the Work and Derivative Works thereof.
256 "Contribution" shall mean any work of authorship, including
257 the original version of the Work and any modifications or additions
258 to that Work or Derivative Works thereof, that is intentionally
259 submitted to Licensor for inclusion in the Work by the copyright owner
260 or by an individual or Legal Entity authorized to submit on behalf of
261 the copyright owner. For the purposes of this definition, "submitted"
262 means any form of electronic, verbal, or written communication sent
263 to the Licensor or its representatives, including but not limited to
264 communication on electronic mailing lists, source code control systems,
265 and issue tracking systems that are managed by, or on behalf of, the
266 Licensor for the purpose of discussing and improving the Work, but
267 excluding communication that is conspicuously marked or otherwise
268 designated in writing by the copyright owner as "Not a Contribution."
270 "Contributor" shall mean Licensor and any individual or Legal Entity
271 on behalf of whom a Contribution has been received by Licensor and
272 subsequently incorporated within the Work.
274 2. Grant of Copyright License. Subject to the terms and conditions of
275 this License, each Contributor hereby grants to You a perpetual,
276 worldwide, non-exclusive, no-charge, royalty-free, irrevocable
277 copyright license to reproduce, prepare Derivative Works of,
278 publicly display, publicly perform, sublicense, and distribute the
279 Work and such Derivative Works in Source or Object form.
281 3. Grant of Patent License. Subject to the terms and conditions of
282 this License, each Contributor hereby grants to You a perpetual,
283 worldwide, non-exclusive, no-charge, royalty-free, irrevocable
284 (except as stated in this section) patent license to make, have made,
285 use, offer to sell, sell, import, and otherwise transfer the Work,
286 where such license applies only to those patent claims licensable
287 by such Contributor that are necessarily infringed by their
288 Contribution(s) alone or by combination of their Contribution(s)
289 with the Work to which such Contribution(s) was submitted. If You
290 institute patent litigation against any entity (including a
291 cross-claim or counterclaim in a lawsuit) alleging that the Work
292 or a Contribution incorporated within the Work constitutes direct
293 or contributory patent infringement, then any patent licenses
294 granted to You under this License for that Work shall terminate
295 as of the date such litigation is filed.
297 4. Redistribution. You may reproduce and distribute copies of the
298 Work or Derivative Works thereof in any medium, with or without
299 modifications, and in Source or Object form, provided that You
300 meet the following conditions:
302 (a) You must give any other recipients of the Work or
303 Derivative Works a copy of this License; and
305 (b) You must cause any modified files to carry prominent notices
306 stating that You changed the files; and
308 (c) You must retain, in the Source form of any Derivative Works
309 that You distribute, all copyright, patent, trademark, and
310 attribution notices from the Source form of the Work,
311 excluding those notices that do not pertain to any part of
312 the Derivative Works; and
314 (d) If the Work includes a "NOTICE" text file as part of its
315 distribution, then any Derivative Works that You distribute must
316 include a readable copy of the attribution notices contained
317 within such NOTICE file, excluding those notices that do not
318 pertain to any part of the Derivative Works, in at least one
319 of the following places: within a NOTICE text file distributed
320 as part of the Derivative Works; within the Source form or
321 documentation, if provided along with the Derivative Works; or,
322 within a display generated by the Derivative Works, if and
323 wherever such third-party notices normally appear. The contents
324 of the NOTICE file are for informational purposes only and
325 do not modify the License. You may add Your own attribution
326 notices within Derivative Works that You distribute, alongside
327 or as an addendum to the NOTICE text from the Work, provided
328 that such additional attribution notices cannot be construed
329 as modifying the License.
331 You may add Your own copyright statement to Your modifications and
332 may provide additional or different license terms and conditions
333 for use, reproduction, or distribution of Your modifications, or
334 for any such Derivative Works as a whole, provided Your use,
335 reproduction, and distribution of the Work otherwise complies with
336 the conditions stated in this License.
338 5. Submission of Contributions. Unless You explicitly state otherwise,
339 any Contribution intentionally submitted for inclusion in the Work
340 by You to the Licensor shall be under the terms and conditions of
341 this License, without any additional terms or conditions.
342 Notwithstanding the above, nothing herein shall supersede or modify
343 the terms of any separate license agreement you may have executed
344 with Licensor regarding such Contributions.
346 6. Trademarks. This License does not grant permission to use the trade
347 names, trademarks, service marks, or product names of the Licensor,
348 except as required for reasonable and customary use in describing the
349 origin of the Work and reproducing the content of the NOTICE file.
351 7. Disclaimer of Warranty. Unless required by applicable law or
352 agreed to in writing, Licensor provides the Work (and each
353 Contributor provides its Contributions) on an "AS IS" BASIS,
354 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
355 implied, including, without limitation, any warranties or conditions
356 of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
357 PARTICULAR PURPOSE. You are solely responsible for determining the
358 appropriateness of using or redistributing the Work and assume any
359 risks associated with Your exercise of permissions under this License.
361 8. Limitation of Liability. In no event and under no legal theory,
362 whether in tort (including negligence), contract, or otherwise,
363 unless required by applicable law (such as deliberate and grossly
364 negligent acts) or agreed to in writing, shall any Contributor be
365 liable to You for damages, including any direct, indirect, special,
366 incidental, or consequential damages of any character arising as a
367 result of this License or out of the use or inability to use the
368 Work (including but not limited to damages for loss of goodwill,
369 work stoppage, computer failure or malfunction, or any and all
370 other commercial damages or losses), even if such Contributor
371 has been advised of the possibility of such damages.
373 9. Accepting Warranty or Additional Liability. While redistributing
374 the Work or Derivative Works thereof, You may choose to offer,
375 and charge a fee for, acceptance of support, warranty, indemnity,
376 or other liability obligations and/or rights consistent with this
377 License. However, in accepting such obligations, You may act only
378 on Your own behalf and on Your sole responsibility, not on behalf
379 of any other Contributor, and only if You agree to indemnify,
380 defend, and hold each Contributor harmless for any liability
381 incurred by, or claims asserted against, such Contributor by reason
382 of your accepting any such warranty or additional liability.
384 END OF TERMS AND CONDITIONS
386 APPENDIX: How to apply the Apache License to your work.
388 To apply the Apache License to your work, attach the following
389 boilerplate notice, with the fields enclosed by brackets "[]"
390 replaced with your own identifying information. (Don't include
391 the brackets!) The text should be enclosed in the appropriate
392 comment syntax for the file format. We also recommend that a
393 file or class name and description of purpose be included on the
394 same "printed page" as the copyright notice for easier
395 identification within third-party archives.
397 Copyright (c) 2015-2018 Google, Inc., Netflix, Inc., Microsoft Corp. and contributors
399 Licensed under the Apache License, Version 2.0 (the "License");
400 you may not use this file except in compliance with the License.
401 You may obtain a copy of the License at
403 http://www.apache.org/licenses/LICENSE-2.0
405 Unless required by applicable law or agreed to in writing, software
406 distributed under the License is distributed on an "AS IS" BASIS,
407 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
408 See the License for the specific language governing permissions and
409 limitations under the License.
413 (function (global, factory) {
414 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
415 typeof define === 'function' && define.amd ? define('rxjs', ['exports'], factory) :
416 (factory((global.rxjs = {})));
417 }(this, (function (exports) { 'use strict';
419 /*! *****************************************************************************
\r
420 Copyright (c) Microsoft Corporation. All rights reserved.
\r
421 Licensed under the Apache License, Version 2.0 (the "License"); you may not use
\r
422 this file except in compliance with the License. You may obtain a copy of the
\r
423 License at http://www.apache.org/licenses/LICENSE-2.0
\r
425 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
\r
426 KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
\r
427 WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
\r
428 MERCHANTABLITY OR NON-INFRINGEMENT.
\r
430 See the Apache Version 2.0 License for specific language governing permissions
\r
431 and limitations under the License.
\r
432 ***************************************************************************** */
\r
433 /* global Reflect, Promise */
\r
435 var extendStatics = Object.setPrototypeOf ||
\r
436 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
\r
437 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
\r
439 function __extends(d, b) {
\r
440 extendStatics(d, b);
\r
441 function __() { this.constructor = d; }
\r
442 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
\r
445 var __assign = Object.assign || function __assign(t) {
\r
446 for (var s, i = 1, n = arguments.length; i < n; i++) {
\r
448 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
\r
453 function __rest(s, e) {
\r
455 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
\r
457 if (s != null && typeof Object.getOwnPropertySymbols === "function")
\r
458 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
\r
463 function isFunction(x) {
464 return typeof x === 'function';
467 var _enable_super_gross_mode_that_will_cause_bad_things = false;
470 set useDeprecatedSynchronousErrorHandling(value) {
472 var error = new Error();
473 console.warn('DEPRECATED! RxJS was set to use deprecated synchronous error handling behavior by code at: \n' + error.stack);
475 else if (_enable_super_gross_mode_that_will_cause_bad_things) {
476 console.log('RxJS: Back to a better error behavior. Thank you. <3');
478 _enable_super_gross_mode_that_will_cause_bad_things = value;
480 get useDeprecatedSynchronousErrorHandling() {
481 return _enable_super_gross_mode_that_will_cause_bad_things;
485 function hostReportError(err) {
486 setTimeout(function () { throw err; }, 0);
491 next: function (value) { },
492 error: function (err) {
493 if (config.useDeprecatedSynchronousErrorHandling) {
497 hostReportError(err);
500 complete: function () { }
503 var isArray = (function () { return Array.isArray || (function (x) { return x && typeof x.length === 'number'; }); })();
505 function isObject(x) {
506 return x !== null && typeof x === 'object';
509 var UnsubscriptionErrorImpl = (function () {
510 function UnsubscriptionErrorImpl(errors) {
512 this.message = errors ?
513 errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) { return i + 1 + ") " + err.toString(); }).join('\n ') : '';
514 this.name = 'UnsubscriptionError';
515 this.errors = errors;
518 UnsubscriptionErrorImpl.prototype = Object.create(Error.prototype);
519 return UnsubscriptionErrorImpl;
521 var UnsubscriptionError = UnsubscriptionErrorImpl;
523 var Subscription = (function () {
524 function Subscription(unsubscribe) {
526 this._parentOrParents = null;
527 this._subscriptions = null;
529 this._unsubscribe = unsubscribe;
532 Subscription.prototype.unsubscribe = function () {
537 var _a = this, _parentOrParents = _a._parentOrParents, _unsubscribe = _a._unsubscribe, _subscriptions = _a._subscriptions;
539 this._parentOrParents = null;
540 this._subscriptions = null;
541 if (_parentOrParents instanceof Subscription) {
542 _parentOrParents.remove(this);
544 else if (_parentOrParents !== null) {
545 for (var index = 0; index < _parentOrParents.length; ++index) {
546 var parent_1 = _parentOrParents[index];
547 parent_1.remove(this);
550 if (isFunction(_unsubscribe)) {
552 _unsubscribe.call(this);
555 errors = e instanceof UnsubscriptionError ? flattenUnsubscriptionErrors(e.errors) : [e];
558 if (isArray(_subscriptions)) {
560 var len = _subscriptions.length;
561 while (++index < len) {
562 var sub = _subscriptions[index];
568 errors = errors || [];
569 if (e instanceof UnsubscriptionError) {
570 errors = errors.concat(flattenUnsubscriptionErrors(e.errors));
580 throw new UnsubscriptionError(errors);
583 Subscription.prototype.add = function (teardown) {
584 var subscription = teardown;
586 return Subscription.EMPTY;
588 switch (typeof teardown) {
590 subscription = new Subscription(teardown);
592 if (subscription === this || subscription.closed || typeof subscription.unsubscribe !== 'function') {
595 else if (this.closed) {
596 subscription.unsubscribe();
599 else if (!(subscription instanceof Subscription)) {
600 var tmp = subscription;
601 subscription = new Subscription();
602 subscription._subscriptions = [tmp];
606 throw new Error('unrecognized teardown ' + teardown + ' added to Subscription.');
609 var _parentOrParents = subscription._parentOrParents;
610 if (_parentOrParents === null) {
611 subscription._parentOrParents = this;
613 else if (_parentOrParents instanceof Subscription) {
614 if (_parentOrParents === this) {
617 subscription._parentOrParents = [_parentOrParents, this];
619 else if (_parentOrParents.indexOf(this) === -1) {
620 _parentOrParents.push(this);
625 var subscriptions = this._subscriptions;
626 if (subscriptions === null) {
627 this._subscriptions = [subscription];
630 subscriptions.push(subscription);
634 Subscription.prototype.remove = function (subscription) {
635 var subscriptions = this._subscriptions;
637 var subscriptionIndex = subscriptions.indexOf(subscription);
638 if (subscriptionIndex !== -1) {
639 subscriptions.splice(subscriptionIndex, 1);
643 Subscription.EMPTY = (function (empty) {
646 }(new Subscription()));
649 function flattenUnsubscriptionErrors(errors) {
650 return errors.reduce(function (errs, err) { return errs.concat((err instanceof UnsubscriptionError) ? err.errors : err); }, []);
653 var rxSubscriber = (function () {
654 return typeof Symbol === 'function'
655 ? Symbol('rxSubscriber')
656 : '@@rxSubscriber_' + Math.random();
659 var Subscriber = (function (_super) {
660 __extends(Subscriber, _super);
661 function Subscriber(destinationOrNext, error, complete) {
662 var _this = _super.call(this) || this;
663 _this.syncErrorValue = null;
664 _this.syncErrorThrown = false;
665 _this.syncErrorThrowable = false;
666 _this.isStopped = false;
667 switch (arguments.length) {
669 _this.destination = empty;
672 if (!destinationOrNext) {
673 _this.destination = empty;
676 if (typeof destinationOrNext === 'object') {
677 if (destinationOrNext instanceof Subscriber) {
678 _this.syncErrorThrowable = destinationOrNext.syncErrorThrowable;
679 _this.destination = destinationOrNext;
680 destinationOrNext.add(_this);
683 _this.syncErrorThrowable = true;
684 _this.destination = new SafeSubscriber(_this, destinationOrNext);
689 _this.syncErrorThrowable = true;
690 _this.destination = new SafeSubscriber(_this, destinationOrNext, error, complete);
695 Subscriber.prototype[rxSubscriber] = function () { return this; };
696 Subscriber.create = function (next, error, complete) {
697 var subscriber = new Subscriber(next, error, complete);
698 subscriber.syncErrorThrowable = false;
701 Subscriber.prototype.next = function (value) {
702 if (!this.isStopped) {
706 Subscriber.prototype.error = function (err) {
707 if (!this.isStopped) {
708 this.isStopped = true;
712 Subscriber.prototype.complete = function () {
713 if (!this.isStopped) {
714 this.isStopped = true;
718 Subscriber.prototype.unsubscribe = function () {
722 this.isStopped = true;
723 _super.prototype.unsubscribe.call(this);
725 Subscriber.prototype._next = function (value) {
726 this.destination.next(value);
728 Subscriber.prototype._error = function (err) {
729 this.destination.error(err);
732 Subscriber.prototype._complete = function () {
733 this.destination.complete();
736 Subscriber.prototype._unsubscribeAndRecycle = function () {
737 var _parentOrParents = this._parentOrParents;
738 this._parentOrParents = null;
741 this.isStopped = false;
742 this._parentOrParents = _parentOrParents;
747 var SafeSubscriber = (function (_super) {
748 __extends(SafeSubscriber, _super);
749 function SafeSubscriber(_parentSubscriber, observerOrNext, error, complete) {
750 var _this = _super.call(this) || this;
751 _this._parentSubscriber = _parentSubscriber;
754 if (isFunction(observerOrNext)) {
755 next = observerOrNext;
757 else if (observerOrNext) {
758 next = observerOrNext.next;
759 error = observerOrNext.error;
760 complete = observerOrNext.complete;
761 if (observerOrNext !== empty) {
762 context = Object.create(observerOrNext);
763 if (isFunction(context.unsubscribe)) {
764 _this.add(context.unsubscribe.bind(context));
766 context.unsubscribe = _this.unsubscribe.bind(_this);
769 _this._context = context;
771 _this._error = error;
772 _this._complete = complete;
775 SafeSubscriber.prototype.next = function (value) {
776 if (!this.isStopped && this._next) {
777 var _parentSubscriber = this._parentSubscriber;
778 if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
779 this.__tryOrUnsub(this._next, value);
781 else if (this.__tryOrSetError(_parentSubscriber, this._next, value)) {
786 SafeSubscriber.prototype.error = function (err) {
787 if (!this.isStopped) {
788 var _parentSubscriber = this._parentSubscriber;
789 var useDeprecatedSynchronousErrorHandling = config.useDeprecatedSynchronousErrorHandling;
791 if (!useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
792 this.__tryOrUnsub(this._error, err);
796 this.__tryOrSetError(_parentSubscriber, this._error, err);
800 else if (!_parentSubscriber.syncErrorThrowable) {
802 if (useDeprecatedSynchronousErrorHandling) {
805 hostReportError(err);
808 if (useDeprecatedSynchronousErrorHandling) {
809 _parentSubscriber.syncErrorValue = err;
810 _parentSubscriber.syncErrorThrown = true;
813 hostReportError(err);
819 SafeSubscriber.prototype.complete = function () {
821 if (!this.isStopped) {
822 var _parentSubscriber = this._parentSubscriber;
823 if (this._complete) {
824 var wrappedComplete = function () { return _this._complete.call(_this._context); };
825 if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
826 this.__tryOrUnsub(wrappedComplete);
830 this.__tryOrSetError(_parentSubscriber, wrappedComplete);
839 SafeSubscriber.prototype.__tryOrUnsub = function (fn, value) {
841 fn.call(this._context, value);
845 if (config.useDeprecatedSynchronousErrorHandling) {
849 hostReportError(err);
853 SafeSubscriber.prototype.__tryOrSetError = function (parent, fn, value) {
854 if (!config.useDeprecatedSynchronousErrorHandling) {
855 throw new Error('bad call');
858 fn.call(this._context, value);
861 if (config.useDeprecatedSynchronousErrorHandling) {
862 parent.syncErrorValue = err;
863 parent.syncErrorThrown = true;
867 hostReportError(err);
873 SafeSubscriber.prototype._unsubscribe = function () {
874 var _parentSubscriber = this._parentSubscriber;
875 this._context = null;
876 this._parentSubscriber = null;
877 _parentSubscriber.unsubscribe();
879 return SafeSubscriber;
882 function canReportError(observer) {
884 var _a = observer, closed_1 = _a.closed, destination = _a.destination, isStopped = _a.isStopped;
885 if (closed_1 || isStopped) {
888 else if (destination && destination instanceof Subscriber) {
889 observer = destination;
898 function toSubscriber(nextOrObserver, error, complete) {
899 if (nextOrObserver) {
900 if (nextOrObserver instanceof Subscriber) {
901 return nextOrObserver;
903 if (nextOrObserver[rxSubscriber]) {
904 return nextOrObserver[rxSubscriber]();
907 if (!nextOrObserver && !error && !complete) {
908 return new Subscriber(empty);
910 return new Subscriber(nextOrObserver, error, complete);
913 var observable = (function () { return typeof Symbol === 'function' && Symbol.observable || '@@observable'; })();
915 function identity(x) {
921 for (var _i = 0; _i < arguments.length; _i++) {
922 fns[_i] = arguments[_i];
924 return pipeFromArray(fns);
926 function pipeFromArray(fns) {
927 if (fns.length === 0) {
930 if (fns.length === 1) {
933 return function piped(input) {
934 return fns.reduce(function (prev, fn) { return fn(prev); }, input);
938 var Observable = (function () {
939 function Observable(subscribe) {
940 this._isScalar = false;
942 this._subscribe = subscribe;
945 Observable.prototype.lift = function (operator) {
946 var observable$$1 = new Observable();
947 observable$$1.source = this;
948 observable$$1.operator = operator;
949 return observable$$1;
951 Observable.prototype.subscribe = function (observerOrNext, error, complete) {
952 var operator = this.operator;
953 var sink = toSubscriber(observerOrNext, error, complete);
955 sink.add(operator.call(sink, this.source));
958 sink.add(this.source || (config.useDeprecatedSynchronousErrorHandling && !sink.syncErrorThrowable) ?
959 this._subscribe(sink) :
960 this._trySubscribe(sink));
962 if (config.useDeprecatedSynchronousErrorHandling) {
963 if (sink.syncErrorThrowable) {
964 sink.syncErrorThrowable = false;
965 if (sink.syncErrorThrown) {
966 throw sink.syncErrorValue;
972 Observable.prototype._trySubscribe = function (sink) {
974 return this._subscribe(sink);
977 if (config.useDeprecatedSynchronousErrorHandling) {
978 sink.syncErrorThrown = true;
979 sink.syncErrorValue = err;
981 if (canReportError(sink)) {
989 Observable.prototype.forEach = function (next, promiseCtor) {
991 promiseCtor = getPromiseCtor(promiseCtor);
992 return new promiseCtor(function (resolve, reject) {
994 subscription = _this.subscribe(function (value) {
1001 subscription.unsubscribe();
1004 }, reject, resolve);
1007 Observable.prototype._subscribe = function (subscriber) {
1008 var source = this.source;
1009 return source && source.subscribe(subscriber);
1011 Observable.prototype[observable] = function () {
1014 Observable.prototype.pipe = function () {
1015 var operations = [];
1016 for (var _i = 0; _i < arguments.length; _i++) {
1017 operations[_i] = arguments[_i];
1019 if (operations.length === 0) {
1022 return pipeFromArray(operations)(this);
1024 Observable.prototype.toPromise = function (promiseCtor) {
1026 promiseCtor = getPromiseCtor(promiseCtor);
1027 return new promiseCtor(function (resolve, reject) {
1029 _this.subscribe(function (x) { return value = x; }, function (err) { return reject(err); }, function () { return resolve(value); });
1032 Observable.create = function (subscribe) {
1033 return new Observable(subscribe);
1037 function getPromiseCtor(promiseCtor) {
1039 promiseCtor = config.Promise || Promise;
1042 throw new Error('no Promise impl found');
1047 var ObjectUnsubscribedErrorImpl = (function () {
1048 function ObjectUnsubscribedErrorImpl() {
1050 this.message = 'object unsubscribed';
1051 this.name = 'ObjectUnsubscribedError';
1054 ObjectUnsubscribedErrorImpl.prototype = Object.create(Error.prototype);
1055 return ObjectUnsubscribedErrorImpl;
1057 var ObjectUnsubscribedError = ObjectUnsubscribedErrorImpl;
1059 var SubjectSubscription = (function (_super) {
1060 __extends(SubjectSubscription, _super);
1061 function SubjectSubscription(subject, subscriber) {
1062 var _this = _super.call(this) || this;
1063 _this.subject = subject;
1064 _this.subscriber = subscriber;
1065 _this.closed = false;
1068 SubjectSubscription.prototype.unsubscribe = function () {
1073 var subject = this.subject;
1074 var observers = subject.observers;
1075 this.subject = null;
1076 if (!observers || observers.length === 0 || subject.isStopped || subject.closed) {
1079 var subscriberIndex = observers.indexOf(this.subscriber);
1080 if (subscriberIndex !== -1) {
1081 observers.splice(subscriberIndex, 1);
1084 return SubjectSubscription;
1087 var SubjectSubscriber = (function (_super) {
1088 __extends(SubjectSubscriber, _super);
1089 function SubjectSubscriber(destination) {
1090 var _this = _super.call(this, destination) || this;
1091 _this.destination = destination;
1094 return SubjectSubscriber;
1096 var Subject = (function (_super) {
1097 __extends(Subject, _super);
1098 function Subject() {
1099 var _this = _super.call(this) || this;
1100 _this.observers = [];
1101 _this.closed = false;
1102 _this.isStopped = false;
1103 _this.hasError = false;
1104 _this.thrownError = null;
1107 Subject.prototype[rxSubscriber] = function () {
1108 return new SubjectSubscriber(this);
1110 Subject.prototype.lift = function (operator) {
1111 var subject = new AnonymousSubject(this, this);
1112 subject.operator = operator;
1115 Subject.prototype.next = function (value) {
1117 throw new ObjectUnsubscribedError();
1119 if (!this.isStopped) {
1120 var observers = this.observers;
1121 var len = observers.length;
1122 var copy = observers.slice();
1123 for (var i = 0; i < len; i++) {
1124 copy[i].next(value);
1128 Subject.prototype.error = function (err) {
1130 throw new ObjectUnsubscribedError();
1132 this.hasError = true;
1133 this.thrownError = err;
1134 this.isStopped = true;
1135 var observers = this.observers;
1136 var len = observers.length;
1137 var copy = observers.slice();
1138 for (var i = 0; i < len; i++) {
1141 this.observers.length = 0;
1143 Subject.prototype.complete = function () {
1145 throw new ObjectUnsubscribedError();
1147 this.isStopped = true;
1148 var observers = this.observers;
1149 var len = observers.length;
1150 var copy = observers.slice();
1151 for (var i = 0; i < len; i++) {
1154 this.observers.length = 0;
1156 Subject.prototype.unsubscribe = function () {
1157 this.isStopped = true;
1159 this.observers = null;
1161 Subject.prototype._trySubscribe = function (subscriber) {
1163 throw new ObjectUnsubscribedError();
1166 return _super.prototype._trySubscribe.call(this, subscriber);
1169 Subject.prototype._subscribe = function (subscriber) {
1171 throw new ObjectUnsubscribedError();
1173 else if (this.hasError) {
1174 subscriber.error(this.thrownError);
1175 return Subscription.EMPTY;
1177 else if (this.isStopped) {
1178 subscriber.complete();
1179 return Subscription.EMPTY;
1182 this.observers.push(subscriber);
1183 return new SubjectSubscription(this, subscriber);
1186 Subject.prototype.asObservable = function () {
1187 var observable = new Observable();
1188 observable.source = this;
1191 Subject.create = function (destination, source) {
1192 return new AnonymousSubject(destination, source);
1196 var AnonymousSubject = (function (_super) {
1197 __extends(AnonymousSubject, _super);
1198 function AnonymousSubject(destination, source) {
1199 var _this = _super.call(this) || this;
1200 _this.destination = destination;
1201 _this.source = source;
1204 AnonymousSubject.prototype.next = function (value) {
1205 var destination = this.destination;
1206 if (destination && destination.next) {
1207 destination.next(value);
1210 AnonymousSubject.prototype.error = function (err) {
1211 var destination = this.destination;
1212 if (destination && destination.error) {
1213 this.destination.error(err);
1216 AnonymousSubject.prototype.complete = function () {
1217 var destination = this.destination;
1218 if (destination && destination.complete) {
1219 this.destination.complete();
1222 AnonymousSubject.prototype._subscribe = function (subscriber) {
1223 var source = this.source;
1225 return this.source.subscribe(subscriber);
1228 return Subscription.EMPTY;
1231 return AnonymousSubject;
1234 function refCount() {
1235 return function refCountOperatorFunction(source) {
1236 return source.lift(new RefCountOperator(source));
1239 var RefCountOperator = (function () {
1240 function RefCountOperator(connectable) {
1241 this.connectable = connectable;
1243 RefCountOperator.prototype.call = function (subscriber, source) {
1244 var connectable = this.connectable;
1245 connectable._refCount++;
1246 var refCounter = new RefCountSubscriber(subscriber, connectable);
1247 var subscription = source.subscribe(refCounter);
1248 if (!refCounter.closed) {
1249 refCounter.connection = connectable.connect();
1251 return subscription;
1253 return RefCountOperator;
1255 var RefCountSubscriber = (function (_super) {
1256 __extends(RefCountSubscriber, _super);
1257 function RefCountSubscriber(destination, connectable) {
1258 var _this = _super.call(this, destination) || this;
1259 _this.connectable = connectable;
1262 RefCountSubscriber.prototype._unsubscribe = function () {
1263 var connectable = this.connectable;
1265 this.connection = null;
1268 this.connectable = null;
1269 var refCount = connectable._refCount;
1270 if (refCount <= 0) {
1271 this.connection = null;
1274 connectable._refCount = refCount - 1;
1276 this.connection = null;
1279 var connection = this.connection;
1280 var sharedConnection = connectable._connection;
1281 this.connection = null;
1282 if (sharedConnection && (!connection || sharedConnection === connection)) {
1283 sharedConnection.unsubscribe();
1286 return RefCountSubscriber;
1289 var ConnectableObservable = (function (_super) {
1290 __extends(ConnectableObservable, _super);
1291 function ConnectableObservable(source, subjectFactory) {
1292 var _this = _super.call(this) || this;
1293 _this.source = source;
1294 _this.subjectFactory = subjectFactory;
1295 _this._refCount = 0;
1296 _this._isComplete = false;
1299 ConnectableObservable.prototype._subscribe = function (subscriber) {
1300 return this.getSubject().subscribe(subscriber);
1302 ConnectableObservable.prototype.getSubject = function () {
1303 var subject = this._subject;
1304 if (!subject || subject.isStopped) {
1305 this._subject = this.subjectFactory();
1307 return this._subject;
1309 ConnectableObservable.prototype.connect = function () {
1310 var connection = this._connection;
1312 this._isComplete = false;
1313 connection = this._connection = new Subscription();
1314 connection.add(this.source
1315 .subscribe(new ConnectableSubscriber(this.getSubject(), this)));
1316 if (connection.closed) {
1317 this._connection = null;
1318 connection = Subscription.EMPTY;
1323 ConnectableObservable.prototype.refCount = function () {
1324 return refCount()(this);
1326 return ConnectableObservable;
1328 var connectableObservableDescriptor = (function () {
1329 var connectableProto = ConnectableObservable.prototype;
1331 operator: { value: null },
1332 _refCount: { value: 0, writable: true },
1333 _subject: { value: null, writable: true },
1334 _connection: { value: null, writable: true },
1335 _subscribe: { value: connectableProto._subscribe },
1336 _isComplete: { value: connectableProto._isComplete, writable: true },
1337 getSubject: { value: connectableProto.getSubject },
1338 connect: { value: connectableProto.connect },
1339 refCount: { value: connectableProto.refCount }
1342 var ConnectableSubscriber = (function (_super) {
1343 __extends(ConnectableSubscriber, _super);
1344 function ConnectableSubscriber(destination, connectable) {
1345 var _this = _super.call(this, destination) || this;
1346 _this.connectable = connectable;
1349 ConnectableSubscriber.prototype._error = function (err) {
1350 this._unsubscribe();
1351 _super.prototype._error.call(this, err);
1353 ConnectableSubscriber.prototype._complete = function () {
1354 this.connectable._isComplete = true;
1355 this._unsubscribe();
1356 _super.prototype._complete.call(this);
1358 ConnectableSubscriber.prototype._unsubscribe = function () {
1359 var connectable = this.connectable;
1361 this.connectable = null;
1362 var connection = connectable._connection;
1363 connectable._refCount = 0;
1364 connectable._subject = null;
1365 connectable._connection = null;
1367 connection.unsubscribe();
1371 return ConnectableSubscriber;
1372 }(SubjectSubscriber));
1373 var RefCountSubscriber$1 = (function (_super) {
1374 __extends(RefCountSubscriber, _super);
1375 function RefCountSubscriber(destination, connectable) {
1376 var _this = _super.call(this, destination) || this;
1377 _this.connectable = connectable;
1380 RefCountSubscriber.prototype._unsubscribe = function () {
1381 var connectable = this.connectable;
1383 this.connection = null;
1386 this.connectable = null;
1387 var refCount$$1 = connectable._refCount;
1388 if (refCount$$1 <= 0) {
1389 this.connection = null;
1392 connectable._refCount = refCount$$1 - 1;
1393 if (refCount$$1 > 1) {
1394 this.connection = null;
1397 var connection = this.connection;
1398 var sharedConnection = connectable._connection;
1399 this.connection = null;
1400 if (sharedConnection && (!connection || sharedConnection === connection)) {
1401 sharedConnection.unsubscribe();
1404 return RefCountSubscriber;
1407 function groupBy(keySelector, elementSelector, durationSelector, subjectSelector) {
1408 return function (source) {
1409 return source.lift(new GroupByOperator(keySelector, elementSelector, durationSelector, subjectSelector));
1412 var GroupByOperator = (function () {
1413 function GroupByOperator(keySelector, elementSelector, durationSelector, subjectSelector) {
1414 this.keySelector = keySelector;
1415 this.elementSelector = elementSelector;
1416 this.durationSelector = durationSelector;
1417 this.subjectSelector = subjectSelector;
1419 GroupByOperator.prototype.call = function (subscriber, source) {
1420 return source.subscribe(new GroupBySubscriber(subscriber, this.keySelector, this.elementSelector, this.durationSelector, this.subjectSelector));
1422 return GroupByOperator;
1424 var GroupBySubscriber = (function (_super) {
1425 __extends(GroupBySubscriber, _super);
1426 function GroupBySubscriber(destination, keySelector, elementSelector, durationSelector, subjectSelector) {
1427 var _this = _super.call(this, destination) || this;
1428 _this.keySelector = keySelector;
1429 _this.elementSelector = elementSelector;
1430 _this.durationSelector = durationSelector;
1431 _this.subjectSelector = subjectSelector;
1432 _this.groups = null;
1433 _this.attemptedToUnsubscribe = false;
1437 GroupBySubscriber.prototype._next = function (value) {
1440 key = this.keySelector(value);
1446 this._group(value, key);
1448 GroupBySubscriber.prototype._group = function (value, key) {
1449 var groups = this.groups;
1451 groups = this.groups = new Map();
1453 var group = groups.get(key);
1455 if (this.elementSelector) {
1457 element = this.elementSelector(value);
1467 group = (this.subjectSelector ? this.subjectSelector() : new Subject());
1468 groups.set(key, group);
1469 var groupedObservable = new GroupedObservable(key, group, this);
1470 this.destination.next(groupedObservable);
1471 if (this.durationSelector) {
1472 var duration = void 0;
1474 duration = this.durationSelector(new GroupedObservable(key, group));
1480 this.add(duration.subscribe(new GroupDurationSubscriber(key, group, this)));
1483 if (!group.closed) {
1484 group.next(element);
1487 GroupBySubscriber.prototype._error = function (err) {
1488 var groups = this.groups;
1490 groups.forEach(function (group, key) {
1495 this.destination.error(err);
1497 GroupBySubscriber.prototype._complete = function () {
1498 var groups = this.groups;
1500 groups.forEach(function (group, key) {
1505 this.destination.complete();
1507 GroupBySubscriber.prototype.removeGroup = function (key) {
1508 this.groups.delete(key);
1510 GroupBySubscriber.prototype.unsubscribe = function () {
1512 this.attemptedToUnsubscribe = true;
1513 if (this.count === 0) {
1514 _super.prototype.unsubscribe.call(this);
1518 return GroupBySubscriber;
1520 var GroupDurationSubscriber = (function (_super) {
1521 __extends(GroupDurationSubscriber, _super);
1522 function GroupDurationSubscriber(key, group, parent) {
1523 var _this = _super.call(this, group) || this;
1525 _this.group = group;
1526 _this.parent = parent;
1529 GroupDurationSubscriber.prototype._next = function (value) {
1532 GroupDurationSubscriber.prototype._unsubscribe = function () {
1533 var _a = this, parent = _a.parent, key = _a.key;
1534 this.key = this.parent = null;
1536 parent.removeGroup(key);
1539 return GroupDurationSubscriber;
1541 var GroupedObservable = (function (_super) {
1542 __extends(GroupedObservable, _super);
1543 function GroupedObservable(key, groupSubject, refCountSubscription) {
1544 var _this = _super.call(this) || this;
1546 _this.groupSubject = groupSubject;
1547 _this.refCountSubscription = refCountSubscription;
1550 GroupedObservable.prototype._subscribe = function (subscriber) {
1551 var subscription = new Subscription();
1552 var _a = this, refCountSubscription = _a.refCountSubscription, groupSubject = _a.groupSubject;
1553 if (refCountSubscription && !refCountSubscription.closed) {
1554 subscription.add(new InnerRefCountSubscription(refCountSubscription));
1556 subscription.add(groupSubject.subscribe(subscriber));
1557 return subscription;
1559 return GroupedObservable;
1561 var InnerRefCountSubscription = (function (_super) {
1562 __extends(InnerRefCountSubscription, _super);
1563 function InnerRefCountSubscription(parent) {
1564 var _this = _super.call(this) || this;
1565 _this.parent = parent;
1569 InnerRefCountSubscription.prototype.unsubscribe = function () {
1570 var parent = this.parent;
1571 if (!parent.closed && !this.closed) {
1572 _super.prototype.unsubscribe.call(this);
1574 if (parent.count === 0 && parent.attemptedToUnsubscribe) {
1575 parent.unsubscribe();
1579 return InnerRefCountSubscription;
1582 var BehaviorSubject = (function (_super) {
1583 __extends(BehaviorSubject, _super);
1584 function BehaviorSubject(_value) {
1585 var _this = _super.call(this) || this;
1586 _this._value = _value;
1589 Object.defineProperty(BehaviorSubject.prototype, "value", {
1591 return this.getValue();
1596 BehaviorSubject.prototype._subscribe = function (subscriber) {
1597 var subscription = _super.prototype._subscribe.call(this, subscriber);
1598 if (subscription && !subscription.closed) {
1599 subscriber.next(this._value);
1601 return subscription;
1603 BehaviorSubject.prototype.getValue = function () {
1604 if (this.hasError) {
1605 throw this.thrownError;
1607 else if (this.closed) {
1608 throw new ObjectUnsubscribedError();
1614 BehaviorSubject.prototype.next = function (value) {
1615 _super.prototype.next.call(this, this._value = value);
1617 return BehaviorSubject;
1620 var Action = (function (_super) {
1621 __extends(Action, _super);
1622 function Action(scheduler, work) {
1623 return _super.call(this) || this;
1625 Action.prototype.schedule = function (state, delay) {
1626 if (delay === void 0) { delay = 0; }
1632 var AsyncAction = (function (_super) {
1633 __extends(AsyncAction, _super);
1634 function AsyncAction(scheduler, work) {
1635 var _this = _super.call(this, scheduler, work) || this;
1636 _this.scheduler = scheduler;
1638 _this.pending = false;
1641 AsyncAction.prototype.schedule = function (state, delay) {
1642 if (delay === void 0) { delay = 0; }
1648 var scheduler = this.scheduler;
1650 this.id = this.recycleAsyncId(scheduler, id, delay);
1652 this.pending = true;
1654 this.id = this.id || this.requestAsyncId(scheduler, this.id, delay);
1657 AsyncAction.prototype.requestAsyncId = function (scheduler, id, delay) {
1658 if (delay === void 0) { delay = 0; }
1659 return setInterval(scheduler.flush.bind(scheduler, this), delay);
1661 AsyncAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
1662 if (delay === void 0) { delay = 0; }
1663 if (delay !== null && this.delay === delay && this.pending === false) {
1669 AsyncAction.prototype.execute = function (state, delay) {
1671 return new Error('executing a cancelled action');
1673 this.pending = false;
1674 var error = this._execute(state, delay);
1678 else if (this.pending === false && this.id != null) {
1679 this.id = this.recycleAsyncId(this.scheduler, this.id, null);
1682 AsyncAction.prototype._execute = function (state, delay) {
1683 var errored = false;
1684 var errorValue = undefined;
1690 errorValue = !!e && e || new Error(e);
1697 AsyncAction.prototype._unsubscribe = function () {
1699 var scheduler = this.scheduler;
1700 var actions = scheduler.actions;
1701 var index = actions.indexOf(this);
1704 this.pending = false;
1705 this.scheduler = null;
1707 actions.splice(index, 1);
1710 this.id = this.recycleAsyncId(scheduler, id, null);
1717 var QueueAction = (function (_super) {
1718 __extends(QueueAction, _super);
1719 function QueueAction(scheduler, work) {
1720 var _this = _super.call(this, scheduler, work) || this;
1721 _this.scheduler = scheduler;
1725 QueueAction.prototype.schedule = function (state, delay) {
1726 if (delay === void 0) { delay = 0; }
1728 return _super.prototype.schedule.call(this, state, delay);
1732 this.scheduler.flush(this);
1735 QueueAction.prototype.execute = function (state, delay) {
1736 return (delay > 0 || this.closed) ?
1737 _super.prototype.execute.call(this, state, delay) :
1738 this._execute(state, delay);
1740 QueueAction.prototype.requestAsyncId = function (scheduler, id, delay) {
1741 if (delay === void 0) { delay = 0; }
1742 if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
1743 return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
1745 return scheduler.flush(this);
1750 var Scheduler = (function () {
1751 function Scheduler(SchedulerAction, now) {
1752 if (now === void 0) { now = Scheduler.now; }
1753 this.SchedulerAction = SchedulerAction;
1756 Scheduler.prototype.schedule = function (work, delay, state) {
1757 if (delay === void 0) { delay = 0; }
1758 return new this.SchedulerAction(this, work).schedule(state, delay);
1760 Scheduler.now = function () { return Date.now(); };
1764 var AsyncScheduler = (function (_super) {
1765 __extends(AsyncScheduler, _super);
1766 function AsyncScheduler(SchedulerAction, now) {
1767 if (now === void 0) { now = Scheduler.now; }
1768 var _this = _super.call(this, SchedulerAction, function () {
1769 if (AsyncScheduler.delegate && AsyncScheduler.delegate !== _this) {
1770 return AsyncScheduler.delegate.now();
1777 _this.active = false;
1778 _this.scheduled = undefined;
1781 AsyncScheduler.prototype.schedule = function (work, delay, state) {
1782 if (delay === void 0) { delay = 0; }
1783 if (AsyncScheduler.delegate && AsyncScheduler.delegate !== this) {
1784 return AsyncScheduler.delegate.schedule(work, delay, state);
1787 return _super.prototype.schedule.call(this, work, delay, state);
1790 AsyncScheduler.prototype.flush = function (action) {
1791 var actions = this.actions;
1793 actions.push(action);
1799 if (error = action.execute(action.state, action.delay)) {
1802 } while (action = actions.shift());
1803 this.active = false;
1805 while (action = actions.shift()) {
1806 action.unsubscribe();
1811 return AsyncScheduler;
1814 var QueueScheduler = (function (_super) {
1815 __extends(QueueScheduler, _super);
1816 function QueueScheduler() {
1817 return _super !== null && _super.apply(this, arguments) || this;
1819 return QueueScheduler;
1822 var queueScheduler = new QueueScheduler(QueueAction);
1823 var queue = queueScheduler;
1825 var EMPTY = new Observable(function (subscriber) { return subscriber.complete(); });
1826 function empty$1(scheduler) {
1827 return scheduler ? emptyScheduled(scheduler) : EMPTY;
1829 function emptyScheduled(scheduler) {
1830 return new Observable(function (subscriber) { return scheduler.schedule(function () { return subscriber.complete(); }); });
1833 function isScheduler(value) {
1834 return value && typeof value.schedule === 'function';
1837 var subscribeToArray = function (array) { return function (subscriber) {
1838 for (var i = 0, len = array.length; i < len && !subscriber.closed; i++) {
1839 subscriber.next(array[i]);
1841 subscriber.complete();
1844 function scheduleArray(input, scheduler) {
1845 return new Observable(function (subscriber) {
1846 var sub = new Subscription();
1848 sub.add(scheduler.schedule(function () {
1849 if (i === input.length) {
1850 subscriber.complete();
1853 subscriber.next(input[i++]);
1854 if (!subscriber.closed) {
1855 sub.add(this.schedule());
1862 function fromArray(input, scheduler) {
1864 return new Observable(subscribeToArray(input));
1867 return scheduleArray(input, scheduler);
1873 for (var _i = 0; _i < arguments.length; _i++) {
1874 args[_i] = arguments[_i];
1876 var scheduler = args[args.length - 1];
1877 if (isScheduler(scheduler)) {
1879 return scheduleArray(args, scheduler);
1882 return fromArray(args);
1886 function throwError(error, scheduler) {
1888 return new Observable(function (subscriber) { return subscriber.error(error); });
1891 return new Observable(function (subscriber) { return scheduler.schedule(dispatch, 0, { error: error, subscriber: subscriber }); });
1894 function dispatch(_a) {
1895 var error = _a.error, subscriber = _a.subscriber;
1896 subscriber.error(error);
1899 (function (NotificationKind) {
1900 NotificationKind["NEXT"] = "N";
1901 NotificationKind["ERROR"] = "E";
1902 NotificationKind["COMPLETE"] = "C";
1903 })(exports.NotificationKind || (exports.NotificationKind = {}));
1904 var Notification = (function () {
1905 function Notification(kind, value, error) {
1909 this.hasValue = kind === 'N';
1911 Notification.prototype.observe = function (observer) {
1912 switch (this.kind) {
1914 return observer.next && observer.next(this.value);
1916 return observer.error && observer.error(this.error);
1918 return observer.complete && observer.complete();
1921 Notification.prototype.do = function (next, error, complete) {
1922 var kind = this.kind;
1925 return next && next(this.value);
1927 return error && error(this.error);
1929 return complete && complete();
1932 Notification.prototype.accept = function (nextOrObserver, error, complete) {
1933 if (nextOrObserver && typeof nextOrObserver.next === 'function') {
1934 return this.observe(nextOrObserver);
1937 return this.do(nextOrObserver, error, complete);
1940 Notification.prototype.toObservable = function () {
1941 var kind = this.kind;
1944 return of(this.value);
1946 return throwError(this.error);
1950 throw new Error('unexpected notification kind value');
1952 Notification.createNext = function (value) {
1953 if (typeof value !== 'undefined') {
1954 return new Notification('N', value);
1956 return Notification.undefinedValueNotification;
1958 Notification.createError = function (err) {
1959 return new Notification('E', undefined, err);
1961 Notification.createComplete = function () {
1962 return Notification.completeNotification;
1964 Notification.completeNotification = new Notification('C');
1965 Notification.undefinedValueNotification = new Notification('N', undefined);
1966 return Notification;
1969 function observeOn(scheduler, delay) {
1970 if (delay === void 0) { delay = 0; }
1971 return function observeOnOperatorFunction(source) {
1972 return source.lift(new ObserveOnOperator(scheduler, delay));
1975 var ObserveOnOperator = (function () {
1976 function ObserveOnOperator(scheduler, delay) {
1977 if (delay === void 0) { delay = 0; }
1978 this.scheduler = scheduler;
1981 ObserveOnOperator.prototype.call = function (subscriber, source) {
1982 return source.subscribe(new ObserveOnSubscriber(subscriber, this.scheduler, this.delay));
1984 return ObserveOnOperator;
1986 var ObserveOnSubscriber = (function (_super) {
1987 __extends(ObserveOnSubscriber, _super);
1988 function ObserveOnSubscriber(destination, scheduler, delay) {
1989 if (delay === void 0) { delay = 0; }
1990 var _this = _super.call(this, destination) || this;
1991 _this.scheduler = scheduler;
1992 _this.delay = delay;
1995 ObserveOnSubscriber.dispatch = function (arg) {
1996 var notification = arg.notification, destination = arg.destination;
1997 notification.observe(destination);
2000 ObserveOnSubscriber.prototype.scheduleMessage = function (notification) {
2001 var destination = this.destination;
2002 destination.add(this.scheduler.schedule(ObserveOnSubscriber.dispatch, this.delay, new ObserveOnMessage(notification, this.destination)));
2004 ObserveOnSubscriber.prototype._next = function (value) {
2005 this.scheduleMessage(Notification.createNext(value));
2007 ObserveOnSubscriber.prototype._error = function (err) {
2008 this.scheduleMessage(Notification.createError(err));
2011 ObserveOnSubscriber.prototype._complete = function () {
2012 this.scheduleMessage(Notification.createComplete());
2015 return ObserveOnSubscriber;
2017 var ObserveOnMessage = (function () {
2018 function ObserveOnMessage(notification, destination) {
2019 this.notification = notification;
2020 this.destination = destination;
2022 return ObserveOnMessage;
2025 var ReplaySubject = (function (_super) {
2026 __extends(ReplaySubject, _super);
2027 function ReplaySubject(bufferSize, windowTime, scheduler) {
2028 if (bufferSize === void 0) { bufferSize = Number.POSITIVE_INFINITY; }
2029 if (windowTime === void 0) { windowTime = Number.POSITIVE_INFINITY; }
2030 var _this = _super.call(this) || this;
2031 _this.scheduler = scheduler;
2033 _this._infiniteTimeWindow = false;
2034 _this._bufferSize = bufferSize < 1 ? 1 : bufferSize;
2035 _this._windowTime = windowTime < 1 ? 1 : windowTime;
2036 if (windowTime === Number.POSITIVE_INFINITY) {
2037 _this._infiniteTimeWindow = true;
2038 _this.next = _this.nextInfiniteTimeWindow;
2041 _this.next = _this.nextTimeWindow;
2045 ReplaySubject.prototype.nextInfiniteTimeWindow = function (value) {
2046 var _events = this._events;
2047 _events.push(value);
2048 if (_events.length > this._bufferSize) {
2051 _super.prototype.next.call(this, value);
2053 ReplaySubject.prototype.nextTimeWindow = function (value) {
2054 this._events.push(new ReplayEvent(this._getNow(), value));
2055 this._trimBufferThenGetEvents();
2056 _super.prototype.next.call(this, value);
2058 ReplaySubject.prototype._subscribe = function (subscriber) {
2059 var _infiniteTimeWindow = this._infiniteTimeWindow;
2060 var _events = _infiniteTimeWindow ? this._events : this._trimBufferThenGetEvents();
2061 var scheduler = this.scheduler;
2062 var len = _events.length;
2065 throw new ObjectUnsubscribedError();
2067 else if (this.isStopped || this.hasError) {
2068 subscription = Subscription.EMPTY;
2071 this.observers.push(subscriber);
2072 subscription = new SubjectSubscription(this, subscriber);
2075 subscriber.add(subscriber = new ObserveOnSubscriber(subscriber, scheduler));
2077 if (_infiniteTimeWindow) {
2078 for (var i = 0; i < len && !subscriber.closed; i++) {
2079 subscriber.next(_events[i]);
2083 for (var i = 0; i < len && !subscriber.closed; i++) {
2084 subscriber.next(_events[i].value);
2087 if (this.hasError) {
2088 subscriber.error(this.thrownError);
2090 else if (this.isStopped) {
2091 subscriber.complete();
2093 return subscription;
2095 ReplaySubject.prototype._getNow = function () {
2096 return (this.scheduler || queue).now();
2098 ReplaySubject.prototype._trimBufferThenGetEvents = function () {
2099 var now = this._getNow();
2100 var _bufferSize = this._bufferSize;
2101 var _windowTime = this._windowTime;
2102 var _events = this._events;
2103 var eventsCount = _events.length;
2104 var spliceCount = 0;
2105 while (spliceCount < eventsCount) {
2106 if ((now - _events[spliceCount].time) < _windowTime) {
2111 if (eventsCount > _bufferSize) {
2112 spliceCount = Math.max(spliceCount, eventsCount - _bufferSize);
2114 if (spliceCount > 0) {
2115 _events.splice(0, spliceCount);
2119 return ReplaySubject;
2121 var ReplayEvent = (function () {
2122 function ReplayEvent(time, value) {
2129 var AsyncSubject = (function (_super) {
2130 __extends(AsyncSubject, _super);
2131 function AsyncSubject() {
2132 var _this = _super !== null && _super.apply(this, arguments) || this;
2134 _this.hasNext = false;
2135 _this.hasCompleted = false;
2138 AsyncSubject.prototype._subscribe = function (subscriber) {
2139 if (this.hasError) {
2140 subscriber.error(this.thrownError);
2141 return Subscription.EMPTY;
2143 else if (this.hasCompleted && this.hasNext) {
2144 subscriber.next(this.value);
2145 subscriber.complete();
2146 return Subscription.EMPTY;
2148 return _super.prototype._subscribe.call(this, subscriber);
2150 AsyncSubject.prototype.next = function (value) {
2151 if (!this.hasCompleted) {
2153 this.hasNext = true;
2156 AsyncSubject.prototype.error = function (error) {
2157 if (!this.hasCompleted) {
2158 _super.prototype.error.call(this, error);
2161 AsyncSubject.prototype.complete = function () {
2162 this.hasCompleted = true;
2164 _super.prototype.next.call(this, this.value);
2166 _super.prototype.complete.call(this);
2168 return AsyncSubject;
2172 var RESOLVED = (function () { return Promise.resolve(); })();
2173 var activeHandles = {};
2174 function findAndClearHandle(handle) {
2175 if (handle in activeHandles) {
2176 delete activeHandles[handle];
2182 setImmediate: function (cb) {
2183 var handle = nextHandle++;
2184 activeHandles[handle] = true;
2185 RESOLVED.then(function () { return findAndClearHandle(handle) && cb(); });
2188 clearImmediate: function (handle) {
2189 findAndClearHandle(handle);
2193 var AsapAction = (function (_super) {
2194 __extends(AsapAction, _super);
2195 function AsapAction(scheduler, work) {
2196 var _this = _super.call(this, scheduler, work) || this;
2197 _this.scheduler = scheduler;
2201 AsapAction.prototype.requestAsyncId = function (scheduler, id, delay) {
2202 if (delay === void 0) { delay = 0; }
2203 if (delay !== null && delay > 0) {
2204 return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
2206 scheduler.actions.push(this);
2207 return scheduler.scheduled || (scheduler.scheduled = Immediate.setImmediate(scheduler.flush.bind(scheduler, null)));
2209 AsapAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
2210 if (delay === void 0) { delay = 0; }
2211 if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
2212 return _super.prototype.recycleAsyncId.call(this, scheduler, id, delay);
2214 if (scheduler.actions.length === 0) {
2215 Immediate.clearImmediate(id);
2216 scheduler.scheduled = undefined;
2223 var AsapScheduler = (function (_super) {
2224 __extends(AsapScheduler, _super);
2225 function AsapScheduler() {
2226 return _super !== null && _super.apply(this, arguments) || this;
2228 AsapScheduler.prototype.flush = function (action) {
2230 this.scheduled = undefined;
2231 var actions = this.actions;
2234 var count = actions.length;
2235 action = action || actions.shift();
2237 if (error = action.execute(action.state, action.delay)) {
2240 } while (++index < count && (action = actions.shift()));
2241 this.active = false;
2243 while (++index < count && (action = actions.shift())) {
2244 action.unsubscribe();
2249 return AsapScheduler;
2252 var asapScheduler = new AsapScheduler(AsapAction);
2253 var asap = asapScheduler;
2255 var asyncScheduler = new AsyncScheduler(AsyncAction);
2256 var async = asyncScheduler;
2258 var AnimationFrameAction = (function (_super) {
2259 __extends(AnimationFrameAction, _super);
2260 function AnimationFrameAction(scheduler, work) {
2261 var _this = _super.call(this, scheduler, work) || this;
2262 _this.scheduler = scheduler;
2266 AnimationFrameAction.prototype.requestAsyncId = function (scheduler, id, delay) {
2267 if (delay === void 0) { delay = 0; }
2268 if (delay !== null && delay > 0) {
2269 return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
2271 scheduler.actions.push(this);
2272 return scheduler.scheduled || (scheduler.scheduled = requestAnimationFrame(function () { return scheduler.flush(null); }));
2274 AnimationFrameAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
2275 if (delay === void 0) { delay = 0; }
2276 if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
2277 return _super.prototype.recycleAsyncId.call(this, scheduler, id, delay);
2279 if (scheduler.actions.length === 0) {
2280 cancelAnimationFrame(id);
2281 scheduler.scheduled = undefined;
2285 return AnimationFrameAction;
2288 var AnimationFrameScheduler = (function (_super) {
2289 __extends(AnimationFrameScheduler, _super);
2290 function AnimationFrameScheduler() {
2291 return _super !== null && _super.apply(this, arguments) || this;
2293 AnimationFrameScheduler.prototype.flush = function (action) {
2295 this.scheduled = undefined;
2296 var actions = this.actions;
2299 var count = actions.length;
2300 action = action || actions.shift();
2302 if (error = action.execute(action.state, action.delay)) {
2305 } while (++index < count && (action = actions.shift()));
2306 this.active = false;
2308 while (++index < count && (action = actions.shift())) {
2309 action.unsubscribe();
2314 return AnimationFrameScheduler;
2317 var animationFrameScheduler = new AnimationFrameScheduler(AnimationFrameAction);
2318 var animationFrame = animationFrameScheduler;
2320 var VirtualTimeScheduler = (function (_super) {
2321 __extends(VirtualTimeScheduler, _super);
2322 function VirtualTimeScheduler(SchedulerAction, maxFrames) {
2323 if (SchedulerAction === void 0) { SchedulerAction = VirtualAction; }
2324 if (maxFrames === void 0) { maxFrames = Number.POSITIVE_INFINITY; }
2325 var _this = _super.call(this, SchedulerAction, function () { return _this.frame; }) || this;
2326 _this.maxFrames = maxFrames;
2331 VirtualTimeScheduler.prototype.flush = function () {
2332 var _a = this, actions = _a.actions, maxFrames = _a.maxFrames;
2334 while ((action = actions[0]) && action.delay <= maxFrames) {
2336 this.frame = action.delay;
2337 if (error = action.execute(action.state, action.delay)) {
2342 while (action = actions.shift()) {
2343 action.unsubscribe();
2348 VirtualTimeScheduler.frameTimeFactor = 10;
2349 return VirtualTimeScheduler;
2351 var VirtualAction = (function (_super) {
2352 __extends(VirtualAction, _super);
2353 function VirtualAction(scheduler, work, index) {
2354 if (index === void 0) { index = scheduler.index += 1; }
2355 var _this = _super.call(this, scheduler, work) || this;
2356 _this.scheduler = scheduler;
2358 _this.index = index;
2359 _this.active = true;
2360 _this.index = scheduler.index = index;
2363 VirtualAction.prototype.schedule = function (state, delay) {
2364 if (delay === void 0) { delay = 0; }
2366 return _super.prototype.schedule.call(this, state, delay);
2368 this.active = false;
2369 var action = new VirtualAction(this.scheduler, this.work);
2371 return action.schedule(state, delay);
2373 VirtualAction.prototype.requestAsyncId = function (scheduler, id, delay) {
2374 if (delay === void 0) { delay = 0; }
2375 this.delay = scheduler.frame + delay;
2376 var actions = scheduler.actions;
2378 actions.sort(VirtualAction.sortActions);
2381 VirtualAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
2382 if (delay === void 0) { delay = 0; }
2385 VirtualAction.prototype._execute = function (state, delay) {
2386 if (this.active === true) {
2387 return _super.prototype._execute.call(this, state, delay);
2390 VirtualAction.sortActions = function (a, b) {
2391 if (a.delay === b.delay) {
2392 if (a.index === b.index) {
2395 else if (a.index > b.index) {
2402 else if (a.delay > b.delay) {
2409 return VirtualAction;
2414 function isObservable(obj) {
2415 return !!obj && (obj instanceof Observable || (typeof obj.lift === 'function' && typeof obj.subscribe === 'function'));
2418 var ArgumentOutOfRangeErrorImpl = (function () {
2419 function ArgumentOutOfRangeErrorImpl() {
2421 this.message = 'argument out of range';
2422 this.name = 'ArgumentOutOfRangeError';
2425 ArgumentOutOfRangeErrorImpl.prototype = Object.create(Error.prototype);
2426 return ArgumentOutOfRangeErrorImpl;
2428 var ArgumentOutOfRangeError = ArgumentOutOfRangeErrorImpl;
2430 var EmptyErrorImpl = (function () {
2431 function EmptyErrorImpl() {
2433 this.message = 'no elements in sequence';
2434 this.name = 'EmptyError';
2437 EmptyErrorImpl.prototype = Object.create(Error.prototype);
2438 return EmptyErrorImpl;
2440 var EmptyError = EmptyErrorImpl;
2442 var TimeoutErrorImpl = (function () {
2443 function TimeoutErrorImpl() {
2445 this.message = 'Timeout has occurred';
2446 this.name = 'TimeoutError';
2449 TimeoutErrorImpl.prototype = Object.create(Error.prototype);
2450 return TimeoutErrorImpl;
2452 var TimeoutError = TimeoutErrorImpl;
2454 function map(project, thisArg) {
2455 return function mapOperation(source) {
2456 if (typeof project !== 'function') {
2457 throw new TypeError('argument is not a function. Are you looking for `mapTo()`?');
2459 return source.lift(new MapOperator(project, thisArg));
2462 var MapOperator = (function () {
2463 function MapOperator(project, thisArg) {
2464 this.project = project;
2465 this.thisArg = thisArg;
2467 MapOperator.prototype.call = function (subscriber, source) {
2468 return source.subscribe(new MapSubscriber(subscriber, this.project, this.thisArg));
2472 var MapSubscriber = (function (_super) {
2473 __extends(MapSubscriber, _super);
2474 function MapSubscriber(destination, project, thisArg) {
2475 var _this = _super.call(this, destination) || this;
2476 _this.project = project;
2478 _this.thisArg = thisArg || _this;
2481 MapSubscriber.prototype._next = function (value) {
2484 result = this.project.call(this.thisArg, value, this.count++);
2487 this.destination.error(err);
2490 this.destination.next(result);
2492 return MapSubscriber;
2495 function bindCallback(callbackFunc, resultSelector, scheduler) {
2496 if (resultSelector) {
2497 if (isScheduler(resultSelector)) {
2498 scheduler = resultSelector;
2501 return function () {
2503 for (var _i = 0; _i < arguments.length; _i++) {
2504 args[_i] = arguments[_i];
2506 return bindCallback(callbackFunc, scheduler).apply(void 0, args).pipe(map(function (args) { return isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
2510 return function () {
2512 for (var _i = 0; _i < arguments.length; _i++) {
2513 args[_i] = arguments[_i];
2520 callbackFunc: callbackFunc,
2521 scheduler: scheduler,
2523 return new Observable(function (subscriber) {
2526 subject = new AsyncSubject();
2527 var handler = function () {
2529 for (var _i = 0; _i < arguments.length; _i++) {
2530 innerArgs[_i] = arguments[_i];
2532 subject.next(innerArgs.length <= 1 ? innerArgs[0] : innerArgs);
2536 callbackFunc.apply(context, args.concat([handler]));
2539 if (canReportError(subject)) {
2547 return subject.subscribe(subscriber);
2551 args: args, subscriber: subscriber, params: params,
2553 return scheduler.schedule(dispatch$1, 0, state);
2558 function dispatch$1(state) {
2560 var args = state.args, subscriber = state.subscriber, params = state.params;
2561 var callbackFunc = params.callbackFunc, context = params.context, scheduler = params.scheduler;
2562 var subject = params.subject;
2564 subject = params.subject = new AsyncSubject();
2565 var handler = function () {
2567 for (var _i = 0; _i < arguments.length; _i++) {
2568 innerArgs[_i] = arguments[_i];
2570 var value = innerArgs.length <= 1 ? innerArgs[0] : innerArgs;
2571 _this.add(scheduler.schedule(dispatchNext, 0, { value: value, subject: subject }));
2574 callbackFunc.apply(context, args.concat([handler]));
2580 this.add(subject.subscribe(subscriber));
2582 function dispatchNext(state) {
2583 var value = state.value, subject = state.subject;
2584 subject.next(value);
2588 function bindNodeCallback(callbackFunc, resultSelector, scheduler) {
2589 if (resultSelector) {
2590 if (isScheduler(resultSelector)) {
2591 scheduler = resultSelector;
2594 return function () {
2596 for (var _i = 0; _i < arguments.length; _i++) {
2597 args[_i] = arguments[_i];
2599 return bindNodeCallback(callbackFunc, scheduler).apply(void 0, args).pipe(map(function (args) { return isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
2603 return function () {
2605 for (var _i = 0; _i < arguments.length; _i++) {
2606 args[_i] = arguments[_i];
2611 callbackFunc: callbackFunc,
2612 scheduler: scheduler,
2615 return new Observable(function (subscriber) {
2616 var context = params.context;
2617 var subject = params.subject;
2620 subject = params.subject = new AsyncSubject();
2621 var handler = function () {
2623 for (var _i = 0; _i < arguments.length; _i++) {
2624 innerArgs[_i] = arguments[_i];
2626 var err = innerArgs.shift();
2631 subject.next(innerArgs.length <= 1 ? innerArgs[0] : innerArgs);
2635 callbackFunc.apply(context, args.concat([handler]));
2638 if (canReportError(subject)) {
2646 return subject.subscribe(subscriber);
2649 return scheduler.schedule(dispatch$2, 0, { params: params, subscriber: subscriber, context: context });
2654 function dispatch$2(state) {
2656 var params = state.params, subscriber = state.subscriber, context = state.context;
2657 var callbackFunc = params.callbackFunc, args = params.args, scheduler = params.scheduler;
2658 var subject = params.subject;
2660 subject = params.subject = new AsyncSubject();
2661 var handler = function () {
2663 for (var _i = 0; _i < arguments.length; _i++) {
2664 innerArgs[_i] = arguments[_i];
2666 var err = innerArgs.shift();
2668 _this.add(scheduler.schedule(dispatchError$1, 0, { err: err, subject: subject }));
2671 var value = innerArgs.length <= 1 ? innerArgs[0] : innerArgs;
2672 _this.add(scheduler.schedule(dispatchNext$1, 0, { value: value, subject: subject }));
2676 callbackFunc.apply(context, args.concat([handler]));
2679 this.add(scheduler.schedule(dispatchError$1, 0, { err: err, subject: subject }));
2682 this.add(subject.subscribe(subscriber));
2684 function dispatchNext$1(arg) {
2685 var value = arg.value, subject = arg.subject;
2686 subject.next(value);
2689 function dispatchError$1(arg) {
2690 var err = arg.err, subject = arg.subject;
2694 var OuterSubscriber = (function (_super) {
2695 __extends(OuterSubscriber, _super);
2696 function OuterSubscriber() {
2697 return _super !== null && _super.apply(this, arguments) || this;
2699 OuterSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
2700 this.destination.next(innerValue);
2702 OuterSubscriber.prototype.notifyError = function (error, innerSub) {
2703 this.destination.error(error);
2705 OuterSubscriber.prototype.notifyComplete = function (innerSub) {
2706 this.destination.complete();
2708 return OuterSubscriber;
2711 var InnerSubscriber = (function (_super) {
2712 __extends(InnerSubscriber, _super);
2713 function InnerSubscriber(parent, outerValue, outerIndex) {
2714 var _this = _super.call(this) || this;
2715 _this.parent = parent;
2716 _this.outerValue = outerValue;
2717 _this.outerIndex = outerIndex;
2721 InnerSubscriber.prototype._next = function (value) {
2722 this.parent.notifyNext(this.outerValue, value, this.outerIndex, this.index++, this);
2724 InnerSubscriber.prototype._error = function (error) {
2725 this.parent.notifyError(error, this);
2728 InnerSubscriber.prototype._complete = function () {
2729 this.parent.notifyComplete(this);
2732 return InnerSubscriber;
2735 var subscribeToPromise = function (promise) { return function (subscriber) {
2736 promise.then(function (value) {
2737 if (!subscriber.closed) {
2738 subscriber.next(value);
2739 subscriber.complete();
2741 }, function (err) { return subscriber.error(err); })
2742 .then(null, hostReportError);
2746 function getSymbolIterator() {
2747 if (typeof Symbol !== 'function' || !Symbol.iterator) {
2748 return '@@iterator';
2750 return Symbol.iterator;
2752 var iterator = getSymbolIterator();
2754 var subscribeToIterable = function (iterable) { return function (subscriber) {
2755 var iterator$$1 = iterable[iterator]();
2759 item = iterator$$1.next();
2762 subscriber.error(err);
2766 subscriber.complete();
2769 subscriber.next(item.value);
2770 if (subscriber.closed) {
2774 if (typeof iterator$$1.return === 'function') {
2775 subscriber.add(function () {
2776 if (iterator$$1.return) {
2777 iterator$$1.return();
2784 var subscribeToObservable = function (obj) { return function (subscriber) {
2785 var obs = obj[observable]();
2786 if (typeof obs.subscribe !== 'function') {
2787 throw new TypeError('Provided object does not correctly implement Symbol.observable');
2790 return obs.subscribe(subscriber);
2794 var isArrayLike = (function (x) { return x && typeof x.length === 'number' && typeof x !== 'function'; });
2796 function isPromise(value) {
2797 return !!value && typeof value.subscribe !== 'function' && typeof value.then === 'function';
2800 var subscribeTo = function (result) {
2801 if (!!result && typeof result[observable] === 'function') {
2802 return subscribeToObservable(result);
2804 else if (isArrayLike(result)) {
2805 return subscribeToArray(result);
2807 else if (isPromise(result)) {
2808 return subscribeToPromise(result);
2810 else if (!!result && typeof result[iterator] === 'function') {
2811 return subscribeToIterable(result);
2814 var value = isObject(result) ? 'an invalid object' : "'" + result + "'";
2815 var msg = "You provided " + value + " where a stream was expected."
2816 + ' You can provide an Observable, Promise, Array, or Iterable.';
2817 throw new TypeError(msg);
2821 function subscribeToResult(outerSubscriber, result, outerValue, outerIndex, innerSubscriber) {
2822 if (innerSubscriber === void 0) { innerSubscriber = new InnerSubscriber(outerSubscriber, outerValue, outerIndex); }
2823 if (innerSubscriber.closed) {
2826 if (result instanceof Observable) {
2827 return result.subscribe(innerSubscriber);
2829 return subscribeTo(result)(innerSubscriber);
2833 function combineLatest() {
2834 var observables = [];
2835 for (var _i = 0; _i < arguments.length; _i++) {
2836 observables[_i] = arguments[_i];
2838 var resultSelector = null;
2839 var scheduler = null;
2840 if (isScheduler(observables[observables.length - 1])) {
2841 scheduler = observables.pop();
2843 if (typeof observables[observables.length - 1] === 'function') {
2844 resultSelector = observables.pop();
2846 if (observables.length === 1 && isArray(observables[0])) {
2847 observables = observables[0];
2849 return fromArray(observables, scheduler).lift(new CombineLatestOperator(resultSelector));
2851 var CombineLatestOperator = (function () {
2852 function CombineLatestOperator(resultSelector) {
2853 this.resultSelector = resultSelector;
2855 CombineLatestOperator.prototype.call = function (subscriber, source) {
2856 return source.subscribe(new CombineLatestSubscriber(subscriber, this.resultSelector));
2858 return CombineLatestOperator;
2860 var CombineLatestSubscriber = (function (_super) {
2861 __extends(CombineLatestSubscriber, _super);
2862 function CombineLatestSubscriber(destination, resultSelector) {
2863 var _this = _super.call(this, destination) || this;
2864 _this.resultSelector = resultSelector;
2867 _this.observables = [];
2870 CombineLatestSubscriber.prototype._next = function (observable) {
2871 this.values.push(NONE);
2872 this.observables.push(observable);
2874 CombineLatestSubscriber.prototype._complete = function () {
2875 var observables = this.observables;
2876 var len = observables.length;
2878 this.destination.complete();
2882 this.toRespond = len;
2883 for (var i = 0; i < len; i++) {
2884 var observable = observables[i];
2885 this.add(subscribeToResult(this, observable, observable, i));
2889 CombineLatestSubscriber.prototype.notifyComplete = function (unused) {
2890 if ((this.active -= 1) === 0) {
2891 this.destination.complete();
2894 CombineLatestSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
2895 var values = this.values;
2896 var oldVal = values[outerIndex];
2897 var toRespond = !this.toRespond
2899 : oldVal === NONE ? --this.toRespond : this.toRespond;
2900 values[outerIndex] = innerValue;
2901 if (toRespond === 0) {
2902 if (this.resultSelector) {
2903 this._tryResultSelector(values);
2906 this.destination.next(values.slice());
2910 CombineLatestSubscriber.prototype._tryResultSelector = function (values) {
2913 result = this.resultSelector.apply(this, values);
2916 this.destination.error(err);
2919 this.destination.next(result);
2921 return CombineLatestSubscriber;
2922 }(OuterSubscriber));
2924 function scheduleObservable(input, scheduler) {
2925 return new Observable(function (subscriber) {
2926 var sub = new Subscription();
2927 sub.add(scheduler.schedule(function () {
2928 var observable$$1 = input[observable]();
2929 sub.add(observable$$1.subscribe({
2930 next: function (value) { sub.add(scheduler.schedule(function () { return subscriber.next(value); })); },
2931 error: function (err) { sub.add(scheduler.schedule(function () { return subscriber.error(err); })); },
2932 complete: function () { sub.add(scheduler.schedule(function () { return subscriber.complete(); })); },
2939 function schedulePromise(input, scheduler) {
2940 return new Observable(function (subscriber) {
2941 var sub = new Subscription();
2942 sub.add(scheduler.schedule(function () { return input.then(function (value) {
2943 sub.add(scheduler.schedule(function () {
2944 subscriber.next(value);
2945 sub.add(scheduler.schedule(function () { return subscriber.complete(); }));
2948 sub.add(scheduler.schedule(function () { return subscriber.error(err); }));
2954 function scheduleIterable(input, scheduler) {
2956 throw new Error('Iterable cannot be null');
2958 return new Observable(function (subscriber) {
2959 var sub = new Subscription();
2961 sub.add(function () {
2962 if (iterator$$1 && typeof iterator$$1.return === 'function') {
2963 iterator$$1.return();
2966 sub.add(scheduler.schedule(function () {
2967 iterator$$1 = input[iterator]();
2968 sub.add(scheduler.schedule(function () {
2969 if (subscriber.closed) {
2975 var result = iterator$$1.next();
2976 value = result.value;
2980 subscriber.error(err);
2984 subscriber.complete();
2987 subscriber.next(value);
2996 function isInteropObservable(input) {
2997 return input && typeof input[observable] === 'function';
3000 function isIterable(input) {
3001 return input && typeof input[iterator] === 'function';
3004 function scheduled(input, scheduler) {
3005 if (input != null) {
3006 if (isInteropObservable(input)) {
3007 return scheduleObservable(input, scheduler);
3009 else if (isPromise(input)) {
3010 return schedulePromise(input, scheduler);
3012 else if (isArrayLike(input)) {
3013 return scheduleArray(input, scheduler);
3015 else if (isIterable(input) || typeof input === 'string') {
3016 return scheduleIterable(input, scheduler);
3019 throw new TypeError((input !== null && typeof input || input) + ' is not observable');
3022 function from(input, scheduler) {
3024 if (input instanceof Observable) {
3027 return new Observable(subscribeTo(input));
3030 return scheduled(input, scheduler);
3034 function mergeMap(project, resultSelector, concurrent) {
3035 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
3036 if (typeof resultSelector === 'function') {
3037 return function (source) { return source.pipe(mergeMap(function (a, i) { return from(project(a, i)).pipe(map(function (b, ii) { return resultSelector(a, b, i, ii); })); }, concurrent)); };
3039 else if (typeof resultSelector === 'number') {
3040 concurrent = resultSelector;
3042 return function (source) { return source.lift(new MergeMapOperator(project, concurrent)); };
3044 var MergeMapOperator = (function () {
3045 function MergeMapOperator(project, concurrent) {
3046 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
3047 this.project = project;
3048 this.concurrent = concurrent;
3050 MergeMapOperator.prototype.call = function (observer, source) {
3051 return source.subscribe(new MergeMapSubscriber(observer, this.project, this.concurrent));
3053 return MergeMapOperator;
3055 var MergeMapSubscriber = (function (_super) {
3056 __extends(MergeMapSubscriber, _super);
3057 function MergeMapSubscriber(destination, project, concurrent) {
3058 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
3059 var _this = _super.call(this, destination) || this;
3060 _this.project = project;
3061 _this.concurrent = concurrent;
3062 _this.hasCompleted = false;
3068 MergeMapSubscriber.prototype._next = function (value) {
3069 if (this.active < this.concurrent) {
3070 this._tryNext(value);
3073 this.buffer.push(value);
3076 MergeMapSubscriber.prototype._tryNext = function (value) {
3078 var index = this.index++;
3080 result = this.project(value, index);
3083 this.destination.error(err);
3087 this._innerSub(result, value, index);
3089 MergeMapSubscriber.prototype._innerSub = function (ish, value, index) {
3090 var innerSubscriber = new InnerSubscriber(this, value, index);
3091 var destination = this.destination;
3092 destination.add(innerSubscriber);
3093 var innerSubscription = subscribeToResult(this, ish, undefined, undefined, innerSubscriber);
3094 if (innerSubscription !== innerSubscriber) {
3095 destination.add(innerSubscription);
3098 MergeMapSubscriber.prototype._complete = function () {
3099 this.hasCompleted = true;
3100 if (this.active === 0 && this.buffer.length === 0) {
3101 this.destination.complete();
3105 MergeMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
3106 this.destination.next(innerValue);
3108 MergeMapSubscriber.prototype.notifyComplete = function (innerSub) {
3109 var buffer = this.buffer;
3110 this.remove(innerSub);
3112 if (buffer.length > 0) {
3113 this._next(buffer.shift());
3115 else if (this.active === 0 && this.hasCompleted) {
3116 this.destination.complete();
3119 return MergeMapSubscriber;
3120 }(OuterSubscriber));
3121 var flatMap = mergeMap;
3123 function mergeAll(concurrent) {
3124 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
3125 return mergeMap(identity, concurrent);
3128 function concatAll() {
3133 var observables = [];
3134 for (var _i = 0; _i < arguments.length; _i++) {
3135 observables[_i] = arguments[_i];
3137 return concatAll()(of.apply(void 0, observables));
3140 function defer(observableFactory) {
3141 return new Observable(function (subscriber) {
3144 input = observableFactory();
3147 subscriber.error(err);
3150 var source = input ? from(input) : empty$1();
3151 return source.subscribe(subscriber);
3155 function forkJoin() {
3157 for (var _i = 0; _i < arguments.length; _i++) {
3158 sources[_i] = arguments[_i];
3160 if (sources.length === 1) {
3161 var first_1 = sources[0];
3162 if (isArray(first_1)) {
3163 return forkJoinInternal(first_1, null);
3165 if (isObject(first_1) && Object.getPrototypeOf(first_1) === Object.prototype) {
3166 var keys = Object.keys(first_1);
3167 return forkJoinInternal(keys.map(function (key) { return first_1[key]; }), keys);
3170 if (typeof sources[sources.length - 1] === 'function') {
3171 var resultSelector_1 = sources.pop();
3172 sources = (sources.length === 1 && isArray(sources[0])) ? sources[0] : sources;
3173 return forkJoinInternal(sources, null).pipe(map(function (args) { return resultSelector_1.apply(void 0, args); }));
3175 return forkJoinInternal(sources, null);
3177 function forkJoinInternal(sources, keys) {
3178 return new Observable(function (subscriber) {
3179 var len = sources.length;
3181 subscriber.complete();
3184 var values = new Array(len);
3187 var _loop_1 = function (i) {
3188 var source = from(sources[i]);
3189 var hasValue = false;
3190 subscriber.add(source.subscribe({
3191 next: function (value) {
3198 error: function (err) { return subscriber.error(err); },
3199 complete: function () {
3201 if (completed === len || !hasValue) {
3202 if (emitted === len) {
3203 subscriber.next(keys ?
3204 keys.reduce(function (result, key, i) { return (result[key] = values[i], result); }, {}) :
3207 subscriber.complete();
3212 for (var i = 0; i < len; i++) {
3218 function fromEvent(target, eventName, options, resultSelector) {
3219 if (isFunction(options)) {
3220 resultSelector = options;
3221 options = undefined;
3223 if (resultSelector) {
3224 return fromEvent(target, eventName, options).pipe(map(function (args) { return isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
3226 return new Observable(function (subscriber) {
3227 function handler(e) {
3228 if (arguments.length > 1) {
3229 subscriber.next(Array.prototype.slice.call(arguments));
3235 setupSubscription(target, eventName, handler, subscriber, options);
3238 function setupSubscription(sourceObj, eventName, handler, subscriber, options) {
3240 if (isEventTarget(sourceObj)) {
3241 var source_1 = sourceObj;
3242 sourceObj.addEventListener(eventName, handler, options);
3243 unsubscribe = function () { return source_1.removeEventListener(eventName, handler, options); };
3245 else if (isJQueryStyleEventEmitter(sourceObj)) {
3246 var source_2 = sourceObj;
3247 sourceObj.on(eventName, handler);
3248 unsubscribe = function () { return source_2.off(eventName, handler); };
3250 else if (isNodeStyleEventEmitter(sourceObj)) {
3251 var source_3 = sourceObj;
3252 sourceObj.addListener(eventName, handler);
3253 unsubscribe = function () { return source_3.removeListener(eventName, handler); };
3255 else if (sourceObj && sourceObj.length) {
3256 for (var i = 0, len = sourceObj.length; i < len; i++) {
3257 setupSubscription(sourceObj[i], eventName, handler, subscriber, options);
3261 throw new TypeError('Invalid event target');
3263 subscriber.add(unsubscribe);
3265 function isNodeStyleEventEmitter(sourceObj) {
3266 return sourceObj && typeof sourceObj.addListener === 'function' && typeof sourceObj.removeListener === 'function';
3268 function isJQueryStyleEventEmitter(sourceObj) {
3269 return sourceObj && typeof sourceObj.on === 'function' && typeof sourceObj.off === 'function';
3271 function isEventTarget(sourceObj) {
3272 return sourceObj && typeof sourceObj.addEventListener === 'function' && typeof sourceObj.removeEventListener === 'function';
3275 function fromEventPattern(addHandler, removeHandler, resultSelector) {
3276 if (resultSelector) {
3277 return fromEventPattern(addHandler, removeHandler).pipe(map(function (args) { return isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
3279 return new Observable(function (subscriber) {
3280 var handler = function () {
3282 for (var _i = 0; _i < arguments.length; _i++) {
3283 e[_i] = arguments[_i];
3285 return subscriber.next(e.length === 1 ? e[0] : e);
3289 retValue = addHandler(handler);
3292 subscriber.error(err);
3295 if (!isFunction(removeHandler)) {
3298 return function () { return removeHandler(handler, retValue); };
3302 function generate(initialStateOrOptions, condition, iterate, resultSelectorOrObservable, scheduler) {
3305 if (arguments.length == 1) {
3306 var options = initialStateOrOptions;
3307 initialState = options.initialState;
3308 condition = options.condition;
3309 iterate = options.iterate;
3310 resultSelector = options.resultSelector || identity;
3311 scheduler = options.scheduler;
3313 else if (resultSelectorOrObservable === undefined || isScheduler(resultSelectorOrObservable)) {
3314 initialState = initialStateOrOptions;
3315 resultSelector = identity;
3316 scheduler = resultSelectorOrObservable;
3319 initialState = initialStateOrOptions;
3320 resultSelector = resultSelectorOrObservable;
3322 return new Observable(function (subscriber) {
3323 var state = initialState;
3325 return scheduler.schedule(dispatch$3, 0, {
3326 subscriber: subscriber,
3328 condition: condition,
3329 resultSelector: resultSelector,
3335 var conditionResult = void 0;
3337 conditionResult = condition(state);
3340 subscriber.error(err);
3343 if (!conditionResult) {
3344 subscriber.complete();
3350 value = resultSelector(state);
3353 subscriber.error(err);
3356 subscriber.next(value);
3357 if (subscriber.closed) {
3361 state = iterate(state);
3364 subscriber.error(err);
3371 function dispatch$3(state) {
3372 var subscriber = state.subscriber, condition = state.condition;
3373 if (subscriber.closed) {
3376 if (state.needIterate) {
3378 state.state = state.iterate(state.state);
3381 subscriber.error(err);
3386 state.needIterate = true;
3389 var conditionResult = void 0;
3391 conditionResult = condition(state.state);
3394 subscriber.error(err);
3397 if (!conditionResult) {
3398 subscriber.complete();
3401 if (subscriber.closed) {
3407 value = state.resultSelector(state.state);
3410 subscriber.error(err);
3413 if (subscriber.closed) {
3416 subscriber.next(value);
3417 if (subscriber.closed) {
3420 return this.schedule(state);
3423 function iif(condition, trueResult, falseResult) {
3424 if (trueResult === void 0) { trueResult = EMPTY; }
3425 if (falseResult === void 0) { falseResult = EMPTY; }
3426 return defer(function () { return condition() ? trueResult : falseResult; });
3429 function isNumeric(val) {
3430 return !isArray(val) && (val - parseFloat(val) + 1) >= 0;
3433 function interval(period, scheduler) {
3434 if (period === void 0) { period = 0; }
3435 if (scheduler === void 0) { scheduler = async; }
3436 if (!isNumeric(period) || period < 0) {
3439 if (!scheduler || typeof scheduler.schedule !== 'function') {
3442 return new Observable(function (subscriber) {
3443 subscriber.add(scheduler.schedule(dispatch$4, period, { subscriber: subscriber, counter: 0, period: period }));
3447 function dispatch$4(state) {
3448 var subscriber = state.subscriber, counter = state.counter, period = state.period;
3449 subscriber.next(counter);
3450 this.schedule({ subscriber: subscriber, counter: counter + 1, period: period }, period);
3454 var observables = [];
3455 for (var _i = 0; _i < arguments.length; _i++) {
3456 observables[_i] = arguments[_i];
3458 var concurrent = Number.POSITIVE_INFINITY;
3459 var scheduler = null;
3460 var last = observables[observables.length - 1];
3461 if (isScheduler(last)) {
3462 scheduler = observables.pop();
3463 if (observables.length > 1 && typeof observables[observables.length - 1] === 'number') {
3464 concurrent = observables.pop();
3467 else if (typeof last === 'number') {
3468 concurrent = observables.pop();
3470 if (scheduler === null && observables.length === 1 && observables[0] instanceof Observable) {
3471 return observables[0];
3473 return mergeAll(concurrent)(fromArray(observables, scheduler));
3476 var NEVER = new Observable(noop);
3481 function onErrorResumeNext() {
3483 for (var _i = 0; _i < arguments.length; _i++) {
3484 sources[_i] = arguments[_i];
3486 if (sources.length === 0) {
3489 var first = sources[0], remainder = sources.slice(1);
3490 if (sources.length === 1 && isArray(first)) {
3491 return onErrorResumeNext.apply(void 0, first);
3493 return new Observable(function (subscriber) {
3494 var subNext = function () { return subscriber.add(onErrorResumeNext.apply(void 0, remainder).subscribe(subscriber)); };
3495 return from(first).subscribe({
3496 next: function (value) { subscriber.next(value); },
3503 function pairs(obj, scheduler) {
3505 return new Observable(function (subscriber) {
3506 var keys = Object.keys(obj);
3507 for (var i = 0; i < keys.length && !subscriber.closed; i++) {
3509 if (obj.hasOwnProperty(key)) {
3510 subscriber.next([key, obj[key]]);
3513 subscriber.complete();
3517 return new Observable(function (subscriber) {
3518 var keys = Object.keys(obj);
3519 var subscription = new Subscription();
3520 subscription.add(scheduler.schedule(dispatch$5, 0, { keys: keys, index: 0, subscriber: subscriber, subscription: subscription, obj: obj }));
3521 return subscription;
3525 function dispatch$5(state) {
3526 var keys = state.keys, index = state.index, subscriber = state.subscriber, subscription = state.subscription, obj = state.obj;
3527 if (!subscriber.closed) {
3528 if (index < keys.length) {
3529 var key = keys[index];
3530 subscriber.next([key, obj[key]]);
3531 subscription.add(this.schedule({ keys: keys, index: index + 1, subscriber: subscriber, subscription: subscription, obj: obj }));
3534 subscriber.complete();
3539 function not(pred, thisArg) {
3540 function notPred() {
3541 return !(notPred.pred.apply(notPred.thisArg, arguments));
3543 notPred.pred = pred;
3544 notPred.thisArg = thisArg;
3548 function filter(predicate, thisArg) {
3549 return function filterOperatorFunction(source) {
3550 return source.lift(new FilterOperator(predicate, thisArg));
3553 var FilterOperator = (function () {
3554 function FilterOperator(predicate, thisArg) {
3555 this.predicate = predicate;
3556 this.thisArg = thisArg;
3558 FilterOperator.prototype.call = function (subscriber, source) {
3559 return source.subscribe(new FilterSubscriber(subscriber, this.predicate, this.thisArg));
3561 return FilterOperator;
3563 var FilterSubscriber = (function (_super) {
3564 __extends(FilterSubscriber, _super);
3565 function FilterSubscriber(destination, predicate, thisArg) {
3566 var _this = _super.call(this, destination) || this;
3567 _this.predicate = predicate;
3568 _this.thisArg = thisArg;
3572 FilterSubscriber.prototype._next = function (value) {
3575 result = this.predicate.call(this.thisArg, value, this.count++);
3578 this.destination.error(err);
3582 this.destination.next(value);
3585 return FilterSubscriber;
3588 function partition(source, predicate, thisArg) {
3590 filter(predicate, thisArg)(new Observable(subscribeTo(source))),
3591 filter(not(predicate, thisArg))(new Observable(subscribeTo(source)))
3596 var observables = [];
3597 for (var _i = 0; _i < arguments.length; _i++) {
3598 observables[_i] = arguments[_i];
3600 if (observables.length === 1) {
3601 if (isArray(observables[0])) {
3602 observables = observables[0];
3605 return observables[0];
3608 return fromArray(observables, undefined).lift(new RaceOperator());
3610 var RaceOperator = (function () {
3611 function RaceOperator() {
3613 RaceOperator.prototype.call = function (subscriber, source) {
3614 return source.subscribe(new RaceSubscriber(subscriber));
3616 return RaceOperator;
3618 var RaceSubscriber = (function (_super) {
3619 __extends(RaceSubscriber, _super);
3620 function RaceSubscriber(destination) {
3621 var _this = _super.call(this, destination) || this;
3622 _this.hasFirst = false;
3623 _this.observables = [];
3624 _this.subscriptions = [];
3627 RaceSubscriber.prototype._next = function (observable) {
3628 this.observables.push(observable);
3630 RaceSubscriber.prototype._complete = function () {
3631 var observables = this.observables;
3632 var len = observables.length;
3634 this.destination.complete();
3637 for (var i = 0; i < len && !this.hasFirst; i++) {
3638 var observable = observables[i];
3639 var subscription = subscribeToResult(this, observable, observable, i);
3640 if (this.subscriptions) {
3641 this.subscriptions.push(subscription);
3643 this.add(subscription);
3645 this.observables = null;
3648 RaceSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
3649 if (!this.hasFirst) {
3650 this.hasFirst = true;
3651 for (var i = 0; i < this.subscriptions.length; i++) {
3652 if (i !== outerIndex) {
3653 var subscription = this.subscriptions[i];
3654 subscription.unsubscribe();
3655 this.remove(subscription);
3658 this.subscriptions = null;
3660 this.destination.next(innerValue);
3662 return RaceSubscriber;
3663 }(OuterSubscriber));
3665 function range(start, count, scheduler) {
3666 if (start === void 0) { start = 0; }
3667 return new Observable(function (subscriber) {
3668 if (count === undefined) {
3673 var current = start;
3675 return scheduler.schedule(dispatch$6, 0, {
3676 index: index, count: count, start: start, subscriber: subscriber
3681 if (index++ >= count) {
3682 subscriber.complete();
3685 subscriber.next(current++);
3686 if (subscriber.closed) {
3694 function dispatch$6(state) {
3695 var start = state.start, index = state.index, count = state.count, subscriber = state.subscriber;
3696 if (index >= count) {
3697 subscriber.complete();
3700 subscriber.next(start);
3701 if (subscriber.closed) {
3704 state.index = index + 1;
3705 state.start = start + 1;
3706 this.schedule(state);
3709 function timer(dueTime, periodOrScheduler, scheduler) {
3710 if (dueTime === void 0) { dueTime = 0; }
3712 if (isNumeric(periodOrScheduler)) {
3713 period = Number(periodOrScheduler) < 1 && 1 || Number(periodOrScheduler);
3715 else if (isScheduler(periodOrScheduler)) {
3716 scheduler = periodOrScheduler;
3718 if (!isScheduler(scheduler)) {
3721 return new Observable(function (subscriber) {
3722 var due = isNumeric(dueTime)
3724 : (+dueTime - scheduler.now());
3725 return scheduler.schedule(dispatch$7, due, {
3726 index: 0, period: period, subscriber: subscriber
3730 function dispatch$7(state) {
3731 var index = state.index, period = state.period, subscriber = state.subscriber;
3732 subscriber.next(index);
3733 if (subscriber.closed) {
3736 else if (period === -1) {
3737 return subscriber.complete();
3739 state.index = index + 1;
3740 this.schedule(state, period);
3743 function using(resourceFactory, observableFactory) {
3744 return new Observable(function (subscriber) {
3747 resource = resourceFactory();
3750 subscriber.error(err);
3755 result = observableFactory(resource);
3758 subscriber.error(err);
3761 var source = result ? from(result) : EMPTY;
3762 var subscription = source.subscribe(subscriber);
3763 return function () {
3764 subscription.unsubscribe();
3766 resource.unsubscribe();
3773 var observables = [];
3774 for (var _i = 0; _i < arguments.length; _i++) {
3775 observables[_i] = arguments[_i];
3777 var resultSelector = observables[observables.length - 1];
3778 if (typeof resultSelector === 'function') {
3781 return fromArray(observables, undefined).lift(new ZipOperator(resultSelector));
3783 var ZipOperator = (function () {
3784 function ZipOperator(resultSelector) {
3785 this.resultSelector = resultSelector;
3787 ZipOperator.prototype.call = function (subscriber, source) {
3788 return source.subscribe(new ZipSubscriber(subscriber, this.resultSelector));
3792 var ZipSubscriber = (function (_super) {
3793 __extends(ZipSubscriber, _super);
3794 function ZipSubscriber(destination, resultSelector, values) {
3795 if (values === void 0) { values = Object.create(null); }
3796 var _this = _super.call(this, destination) || this;
3797 _this.iterators = [];
3799 _this.resultSelector = (typeof resultSelector === 'function') ? resultSelector : null;
3800 _this.values = values;
3803 ZipSubscriber.prototype._next = function (value) {
3804 var iterators = this.iterators;
3805 if (isArray(value)) {
3806 iterators.push(new StaticArrayIterator(value));
3808 else if (typeof value[iterator] === 'function') {
3809 iterators.push(new StaticIterator(value[iterator]()));
3812 iterators.push(new ZipBufferIterator(this.destination, this, value));
3815 ZipSubscriber.prototype._complete = function () {
3816 var iterators = this.iterators;
3817 var len = iterators.length;
3820 this.destination.complete();
3824 for (var i = 0; i < len; i++) {
3825 var iterator$$1 = iterators[i];
3826 if (iterator$$1.stillUnsubscribed) {
3827 var destination = this.destination;
3828 destination.add(iterator$$1.subscribe(iterator$$1, i));
3835 ZipSubscriber.prototype.notifyInactive = function () {
3837 if (this.active === 0) {
3838 this.destination.complete();
3841 ZipSubscriber.prototype.checkIterators = function () {
3842 var iterators = this.iterators;
3843 var len = iterators.length;
3844 var destination = this.destination;
3845 for (var i = 0; i < len; i++) {
3846 var iterator$$1 = iterators[i];
3847 if (typeof iterator$$1.hasValue === 'function' && !iterator$$1.hasValue()) {
3851 var shouldComplete = false;
3853 for (var i = 0; i < len; i++) {
3854 var iterator$$1 = iterators[i];
3855 var result = iterator$$1.next();
3856 if (iterator$$1.hasCompleted()) {
3857 shouldComplete = true;
3860 destination.complete();
3863 args.push(result.value);
3865 if (this.resultSelector) {
3866 this._tryresultSelector(args);
3869 destination.next(args);
3871 if (shouldComplete) {
3872 destination.complete();
3875 ZipSubscriber.prototype._tryresultSelector = function (args) {
3878 result = this.resultSelector.apply(this, args);
3881 this.destination.error(err);
3884 this.destination.next(result);
3886 return ZipSubscriber;
3888 var StaticIterator = (function () {
3889 function StaticIterator(iterator$$1) {
3890 this.iterator = iterator$$1;
3891 this.nextResult = iterator$$1.next();
3893 StaticIterator.prototype.hasValue = function () {
3896 StaticIterator.prototype.next = function () {
3897 var result = this.nextResult;
3898 this.nextResult = this.iterator.next();
3901 StaticIterator.prototype.hasCompleted = function () {
3902 var nextResult = this.nextResult;
3903 return nextResult && nextResult.done;
3905 return StaticIterator;
3907 var StaticArrayIterator = (function () {
3908 function StaticArrayIterator(array) {
3912 this.length = array.length;
3914 StaticArrayIterator.prototype[iterator] = function () {
3917 StaticArrayIterator.prototype.next = function (value) {
3918 var i = this.index++;
3919 var array = this.array;
3920 return i < this.length ? { value: array[i], done: false } : { value: null, done: true };
3922 StaticArrayIterator.prototype.hasValue = function () {
3923 return this.array.length > this.index;
3925 StaticArrayIterator.prototype.hasCompleted = function () {
3926 return this.array.length === this.index;
3928 return StaticArrayIterator;
3930 var ZipBufferIterator = (function (_super) {
3931 __extends(ZipBufferIterator, _super);
3932 function ZipBufferIterator(destination, parent, observable) {
3933 var _this = _super.call(this, destination) || this;
3934 _this.parent = parent;
3935 _this.observable = observable;
3936 _this.stillUnsubscribed = true;
3938 _this.isComplete = false;
3941 ZipBufferIterator.prototype[iterator] = function () {
3944 ZipBufferIterator.prototype.next = function () {
3945 var buffer = this.buffer;
3946 if (buffer.length === 0 && this.isComplete) {
3947 return { value: null, done: true };
3950 return { value: buffer.shift(), done: false };
3953 ZipBufferIterator.prototype.hasValue = function () {
3954 return this.buffer.length > 0;
3956 ZipBufferIterator.prototype.hasCompleted = function () {
3957 return this.buffer.length === 0 && this.isComplete;
3959 ZipBufferIterator.prototype.notifyComplete = function () {
3960 if (this.buffer.length > 0) {
3961 this.isComplete = true;
3962 this.parent.notifyInactive();
3965 this.destination.complete();
3968 ZipBufferIterator.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
3969 this.buffer.push(innerValue);
3970 this.parent.checkIterators();
3972 ZipBufferIterator.prototype.subscribe = function (value, index) {
3973 return subscribeToResult(this, this.observable, this, index);
3975 return ZipBufferIterator;
3976 }(OuterSubscriber));
3978 function audit(durationSelector) {
3979 return function auditOperatorFunction(source) {
3980 return source.lift(new AuditOperator(durationSelector));
3983 var AuditOperator = (function () {
3984 function AuditOperator(durationSelector) {
3985 this.durationSelector = durationSelector;
3987 AuditOperator.prototype.call = function (subscriber, source) {
3988 return source.subscribe(new AuditSubscriber(subscriber, this.durationSelector));
3990 return AuditOperator;
3992 var AuditSubscriber = (function (_super) {
3993 __extends(AuditSubscriber, _super);
3994 function AuditSubscriber(destination, durationSelector) {
3995 var _this = _super.call(this, destination) || this;
3996 _this.durationSelector = durationSelector;
3997 _this.hasValue = false;
4000 AuditSubscriber.prototype._next = function (value) {
4002 this.hasValue = true;
4003 if (!this.throttled) {
4004 var duration = void 0;
4006 var durationSelector = this.durationSelector;
4007 duration = durationSelector(value);
4010 return this.destination.error(err);
4012 var innerSubscription = subscribeToResult(this, duration);
4013 if (!innerSubscription || innerSubscription.closed) {
4014 this.clearThrottle();
4017 this.add(this.throttled = innerSubscription);
4021 AuditSubscriber.prototype.clearThrottle = function () {
4022 var _a = this, value = _a.value, hasValue = _a.hasValue, throttled = _a.throttled;
4024 this.remove(throttled);
4025 this.throttled = null;
4026 throttled.unsubscribe();
4030 this.hasValue = false;
4031 this.destination.next(value);
4034 AuditSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex) {
4035 this.clearThrottle();
4037 AuditSubscriber.prototype.notifyComplete = function () {
4038 this.clearThrottle();
4040 return AuditSubscriber;
4041 }(OuterSubscriber));
4043 function auditTime(duration, scheduler) {
4044 if (scheduler === void 0) { scheduler = async; }
4045 return audit(function () { return timer(duration, scheduler); });
4048 function buffer(closingNotifier) {
4049 return function bufferOperatorFunction(source) {
4050 return source.lift(new BufferOperator(closingNotifier));
4053 var BufferOperator = (function () {
4054 function BufferOperator(closingNotifier) {
4055 this.closingNotifier = closingNotifier;
4057 BufferOperator.prototype.call = function (subscriber, source) {
4058 return source.subscribe(new BufferSubscriber(subscriber, this.closingNotifier));
4060 return BufferOperator;
4062 var BufferSubscriber = (function (_super) {
4063 __extends(BufferSubscriber, _super);
4064 function BufferSubscriber(destination, closingNotifier) {
4065 var _this = _super.call(this, destination) || this;
4067 _this.add(subscribeToResult(_this, closingNotifier));
4070 BufferSubscriber.prototype._next = function (value) {
4071 this.buffer.push(value);
4073 BufferSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
4074 var buffer = this.buffer;
4076 this.destination.next(buffer);
4078 return BufferSubscriber;
4079 }(OuterSubscriber));
4081 function bufferCount(bufferSize, startBufferEvery) {
4082 if (startBufferEvery === void 0) { startBufferEvery = null; }
4083 return function bufferCountOperatorFunction(source) {
4084 return source.lift(new BufferCountOperator(bufferSize, startBufferEvery));
4087 var BufferCountOperator = (function () {
4088 function BufferCountOperator(bufferSize, startBufferEvery) {
4089 this.bufferSize = bufferSize;
4090 this.startBufferEvery = startBufferEvery;
4091 if (!startBufferEvery || bufferSize === startBufferEvery) {
4092 this.subscriberClass = BufferCountSubscriber;
4095 this.subscriberClass = BufferSkipCountSubscriber;
4098 BufferCountOperator.prototype.call = function (subscriber, source) {
4099 return source.subscribe(new this.subscriberClass(subscriber, this.bufferSize, this.startBufferEvery));
4101 return BufferCountOperator;
4103 var BufferCountSubscriber = (function (_super) {
4104 __extends(BufferCountSubscriber, _super);
4105 function BufferCountSubscriber(destination, bufferSize) {
4106 var _this = _super.call(this, destination) || this;
4107 _this.bufferSize = bufferSize;
4111 BufferCountSubscriber.prototype._next = function (value) {
4112 var buffer = this.buffer;
4114 if (buffer.length == this.bufferSize) {
4115 this.destination.next(buffer);
4119 BufferCountSubscriber.prototype._complete = function () {
4120 var buffer = this.buffer;
4121 if (buffer.length > 0) {
4122 this.destination.next(buffer);
4124 _super.prototype._complete.call(this);
4126 return BufferCountSubscriber;
4128 var BufferSkipCountSubscriber = (function (_super) {
4129 __extends(BufferSkipCountSubscriber, _super);
4130 function BufferSkipCountSubscriber(destination, bufferSize, startBufferEvery) {
4131 var _this = _super.call(this, destination) || this;
4132 _this.bufferSize = bufferSize;
4133 _this.startBufferEvery = startBufferEvery;
4138 BufferSkipCountSubscriber.prototype._next = function (value) {
4139 var _a = this, bufferSize = _a.bufferSize, startBufferEvery = _a.startBufferEvery, buffers = _a.buffers, count = _a.count;
4141 if (count % startBufferEvery === 0) {
4144 for (var i = buffers.length; i--;) {
4145 var buffer = buffers[i];
4147 if (buffer.length === bufferSize) {
4148 buffers.splice(i, 1);
4149 this.destination.next(buffer);
4153 BufferSkipCountSubscriber.prototype._complete = function () {
4154 var _a = this, buffers = _a.buffers, destination = _a.destination;
4155 while (buffers.length > 0) {
4156 var buffer = buffers.shift();
4157 if (buffer.length > 0) {
4158 destination.next(buffer);
4161 _super.prototype._complete.call(this);
4163 return BufferSkipCountSubscriber;
4166 function bufferTime(bufferTimeSpan) {
4167 var length = arguments.length;
4168 var scheduler = async;
4169 if (isScheduler(arguments[arguments.length - 1])) {
4170 scheduler = arguments[arguments.length - 1];
4173 var bufferCreationInterval = null;
4175 bufferCreationInterval = arguments[1];
4177 var maxBufferSize = Number.POSITIVE_INFINITY;
4179 maxBufferSize = arguments[2];
4181 return function bufferTimeOperatorFunction(source) {
4182 return source.lift(new BufferTimeOperator(bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler));
4185 var BufferTimeOperator = (function () {
4186 function BufferTimeOperator(bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler) {
4187 this.bufferTimeSpan = bufferTimeSpan;
4188 this.bufferCreationInterval = bufferCreationInterval;
4189 this.maxBufferSize = maxBufferSize;
4190 this.scheduler = scheduler;
4192 BufferTimeOperator.prototype.call = function (subscriber, source) {
4193 return source.subscribe(new BufferTimeSubscriber(subscriber, this.bufferTimeSpan, this.bufferCreationInterval, this.maxBufferSize, this.scheduler));
4195 return BufferTimeOperator;
4197 var Context = (function () {
4198 function Context() {
4203 var BufferTimeSubscriber = (function (_super) {
4204 __extends(BufferTimeSubscriber, _super);
4205 function BufferTimeSubscriber(destination, bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler) {
4206 var _this = _super.call(this, destination) || this;
4207 _this.bufferTimeSpan = bufferTimeSpan;
4208 _this.bufferCreationInterval = bufferCreationInterval;
4209 _this.maxBufferSize = maxBufferSize;
4210 _this.scheduler = scheduler;
4211 _this.contexts = [];
4212 var context = _this.openContext();
4213 _this.timespanOnly = bufferCreationInterval == null || bufferCreationInterval < 0;
4214 if (_this.timespanOnly) {
4215 var timeSpanOnlyState = { subscriber: _this, context: context, bufferTimeSpan: bufferTimeSpan };
4216 _this.add(context.closeAction = scheduler.schedule(dispatchBufferTimeSpanOnly, bufferTimeSpan, timeSpanOnlyState));
4219 var closeState = { subscriber: _this, context: context };
4220 var creationState = { bufferTimeSpan: bufferTimeSpan, bufferCreationInterval: bufferCreationInterval, subscriber: _this, scheduler: scheduler };
4221 _this.add(context.closeAction = scheduler.schedule(dispatchBufferClose, bufferTimeSpan, closeState));
4222 _this.add(scheduler.schedule(dispatchBufferCreation, bufferCreationInterval, creationState));
4226 BufferTimeSubscriber.prototype._next = function (value) {
4227 var contexts = this.contexts;
4228 var len = contexts.length;
4229 var filledBufferContext;
4230 for (var i = 0; i < len; i++) {
4231 var context_1 = contexts[i];
4232 var buffer = context_1.buffer;
4234 if (buffer.length == this.maxBufferSize) {
4235 filledBufferContext = context_1;
4238 if (filledBufferContext) {
4239 this.onBufferFull(filledBufferContext);
4242 BufferTimeSubscriber.prototype._error = function (err) {
4243 this.contexts.length = 0;
4244 _super.prototype._error.call(this, err);
4246 BufferTimeSubscriber.prototype._complete = function () {
4247 var _a = this, contexts = _a.contexts, destination = _a.destination;
4248 while (contexts.length > 0) {
4249 var context_2 = contexts.shift();
4250 destination.next(context_2.buffer);
4252 _super.prototype._complete.call(this);
4254 BufferTimeSubscriber.prototype._unsubscribe = function () {
4255 this.contexts = null;
4257 BufferTimeSubscriber.prototype.onBufferFull = function (context) {
4258 this.closeContext(context);
4259 var closeAction = context.closeAction;
4260 closeAction.unsubscribe();
4261 this.remove(closeAction);
4262 if (!this.closed && this.timespanOnly) {
4263 context = this.openContext();
4264 var bufferTimeSpan = this.bufferTimeSpan;
4265 var timeSpanOnlyState = { subscriber: this, context: context, bufferTimeSpan: bufferTimeSpan };
4266 this.add(context.closeAction = this.scheduler.schedule(dispatchBufferTimeSpanOnly, bufferTimeSpan, timeSpanOnlyState));
4269 BufferTimeSubscriber.prototype.openContext = function () {
4270 var context = new Context();
4271 this.contexts.push(context);
4274 BufferTimeSubscriber.prototype.closeContext = function (context) {
4275 this.destination.next(context.buffer);
4276 var contexts = this.contexts;
4277 var spliceIndex = contexts ? contexts.indexOf(context) : -1;
4278 if (spliceIndex >= 0) {
4279 contexts.splice(contexts.indexOf(context), 1);
4282 return BufferTimeSubscriber;
4284 function dispatchBufferTimeSpanOnly(state) {
4285 var subscriber = state.subscriber;
4286 var prevContext = state.context;
4288 subscriber.closeContext(prevContext);
4290 if (!subscriber.closed) {
4291 state.context = subscriber.openContext();
4292 state.context.closeAction = this.schedule(state, state.bufferTimeSpan);
4295 function dispatchBufferCreation(state) {
4296 var bufferCreationInterval = state.bufferCreationInterval, bufferTimeSpan = state.bufferTimeSpan, subscriber = state.subscriber, scheduler = state.scheduler;
4297 var context = subscriber.openContext();
4299 if (!subscriber.closed) {
4300 subscriber.add(context.closeAction = scheduler.schedule(dispatchBufferClose, bufferTimeSpan, { subscriber: subscriber, context: context }));
4301 action.schedule(state, bufferCreationInterval);
4304 function dispatchBufferClose(arg) {
4305 var subscriber = arg.subscriber, context = arg.context;
4306 subscriber.closeContext(context);
4309 function bufferToggle(openings, closingSelector) {
4310 return function bufferToggleOperatorFunction(source) {
4311 return source.lift(new BufferToggleOperator(openings, closingSelector));
4314 var BufferToggleOperator = (function () {
4315 function BufferToggleOperator(openings, closingSelector) {
4316 this.openings = openings;
4317 this.closingSelector = closingSelector;
4319 BufferToggleOperator.prototype.call = function (subscriber, source) {
4320 return source.subscribe(new BufferToggleSubscriber(subscriber, this.openings, this.closingSelector));
4322 return BufferToggleOperator;
4324 var BufferToggleSubscriber = (function (_super) {
4325 __extends(BufferToggleSubscriber, _super);
4326 function BufferToggleSubscriber(destination, openings, closingSelector) {
4327 var _this = _super.call(this, destination) || this;
4328 _this.openings = openings;
4329 _this.closingSelector = closingSelector;
4330 _this.contexts = [];
4331 _this.add(subscribeToResult(_this, openings));
4334 BufferToggleSubscriber.prototype._next = function (value) {
4335 var contexts = this.contexts;
4336 var len = contexts.length;
4337 for (var i = 0; i < len; i++) {
4338 contexts[i].buffer.push(value);
4341 BufferToggleSubscriber.prototype._error = function (err) {
4342 var contexts = this.contexts;
4343 while (contexts.length > 0) {
4344 var context_1 = contexts.shift();
4345 context_1.subscription.unsubscribe();
4346 context_1.buffer = null;
4347 context_1.subscription = null;
4349 this.contexts = null;
4350 _super.prototype._error.call(this, err);
4352 BufferToggleSubscriber.prototype._complete = function () {
4353 var contexts = this.contexts;
4354 while (contexts.length > 0) {
4355 var context_2 = contexts.shift();
4356 this.destination.next(context_2.buffer);
4357 context_2.subscription.unsubscribe();
4358 context_2.buffer = null;
4359 context_2.subscription = null;
4361 this.contexts = null;
4362 _super.prototype._complete.call(this);
4364 BufferToggleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
4365 outerValue ? this.closeBuffer(outerValue) : this.openBuffer(innerValue);
4367 BufferToggleSubscriber.prototype.notifyComplete = function (innerSub) {
4368 this.closeBuffer(innerSub.context);
4370 BufferToggleSubscriber.prototype.openBuffer = function (value) {
4372 var closingSelector = this.closingSelector;
4373 var closingNotifier = closingSelector.call(this, value);
4374 if (closingNotifier) {
4375 this.trySubscribe(closingNotifier);
4382 BufferToggleSubscriber.prototype.closeBuffer = function (context) {
4383 var contexts = this.contexts;
4384 if (contexts && context) {
4385 var buffer = context.buffer, subscription = context.subscription;
4386 this.destination.next(buffer);
4387 contexts.splice(contexts.indexOf(context), 1);
4388 this.remove(subscription);
4389 subscription.unsubscribe();
4392 BufferToggleSubscriber.prototype.trySubscribe = function (closingNotifier) {
4393 var contexts = this.contexts;
4395 var subscription = new Subscription();
4396 var context = { buffer: buffer, subscription: subscription };
4397 contexts.push(context);
4398 var innerSubscription = subscribeToResult(this, closingNotifier, context);
4399 if (!innerSubscription || innerSubscription.closed) {
4400 this.closeBuffer(context);
4403 innerSubscription.context = context;
4404 this.add(innerSubscription);
4405 subscription.add(innerSubscription);
4408 return BufferToggleSubscriber;
4409 }(OuterSubscriber));
4411 function bufferWhen(closingSelector) {
4412 return function (source) {
4413 return source.lift(new BufferWhenOperator(closingSelector));
4416 var BufferWhenOperator = (function () {
4417 function BufferWhenOperator(closingSelector) {
4418 this.closingSelector = closingSelector;
4420 BufferWhenOperator.prototype.call = function (subscriber, source) {
4421 return source.subscribe(new BufferWhenSubscriber(subscriber, this.closingSelector));
4423 return BufferWhenOperator;
4425 var BufferWhenSubscriber = (function (_super) {
4426 __extends(BufferWhenSubscriber, _super);
4427 function BufferWhenSubscriber(destination, closingSelector) {
4428 var _this = _super.call(this, destination) || this;
4429 _this.closingSelector = closingSelector;
4430 _this.subscribing = false;
4434 BufferWhenSubscriber.prototype._next = function (value) {
4435 this.buffer.push(value);
4437 BufferWhenSubscriber.prototype._complete = function () {
4438 var buffer = this.buffer;
4440 this.destination.next(buffer);
4442 _super.prototype._complete.call(this);
4444 BufferWhenSubscriber.prototype._unsubscribe = function () {
4446 this.subscribing = false;
4448 BufferWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
4451 BufferWhenSubscriber.prototype.notifyComplete = function () {
4452 if (this.subscribing) {
4459 BufferWhenSubscriber.prototype.openBuffer = function () {
4460 var closingSubscription = this.closingSubscription;
4461 if (closingSubscription) {
4462 this.remove(closingSubscription);
4463 closingSubscription.unsubscribe();
4465 var buffer = this.buffer;
4467 this.destination.next(buffer);
4470 var closingNotifier;
4472 var closingSelector = this.closingSelector;
4473 closingNotifier = closingSelector();
4476 return this.error(err);
4478 closingSubscription = new Subscription();
4479 this.closingSubscription = closingSubscription;
4480 this.add(closingSubscription);
4481 this.subscribing = true;
4482 closingSubscription.add(subscribeToResult(this, closingNotifier));
4483 this.subscribing = false;
4485 return BufferWhenSubscriber;
4486 }(OuterSubscriber));
4488 function catchError(selector) {
4489 return function catchErrorOperatorFunction(source) {
4490 var operator = new CatchOperator(selector);
4491 var caught = source.lift(operator);
4492 return (operator.caught = caught);
4495 var CatchOperator = (function () {
4496 function CatchOperator(selector) {
4497 this.selector = selector;
4499 CatchOperator.prototype.call = function (subscriber, source) {
4500 return source.subscribe(new CatchSubscriber(subscriber, this.selector, this.caught));
4502 return CatchOperator;
4504 var CatchSubscriber = (function (_super) {
4505 __extends(CatchSubscriber, _super);
4506 function CatchSubscriber(destination, selector, caught) {
4507 var _this = _super.call(this, destination) || this;
4508 _this.selector = selector;
4509 _this.caught = caught;
4512 CatchSubscriber.prototype.error = function (err) {
4513 if (!this.isStopped) {
4514 var result = void 0;
4516 result = this.selector(err, this.caught);
4519 _super.prototype.error.call(this, err2);
4522 this._unsubscribeAndRecycle();
4523 var innerSubscriber = new InnerSubscriber(this, undefined, undefined);
4524 this.add(innerSubscriber);
4525 var innerSubscription = subscribeToResult(this, result, undefined, undefined, innerSubscriber);
4526 if (innerSubscription !== innerSubscriber) {
4527 this.add(innerSubscription);
4531 return CatchSubscriber;
4532 }(OuterSubscriber));
4534 function combineAll(project) {
4535 return function (source) { return source.lift(new CombineLatestOperator(project)); };
4538 function combineLatest$1() {
4539 var observables = [];
4540 for (var _i = 0; _i < arguments.length; _i++) {
4541 observables[_i] = arguments[_i];
4544 if (typeof observables[observables.length - 1] === 'function') {
4545 project = observables.pop();
4547 if (observables.length === 1 && isArray(observables[0])) {
4548 observables = observables[0].slice();
4550 return function (source) { return source.lift.call(from([source].concat(observables)), new CombineLatestOperator(project)); };
4553 function concat$1() {
4554 var observables = [];
4555 for (var _i = 0; _i < arguments.length; _i++) {
4556 observables[_i] = arguments[_i];
4558 return function (source) { return source.lift.call(concat.apply(void 0, [source].concat(observables))); };
4561 function concatMap(project, resultSelector) {
4562 return mergeMap(project, resultSelector, 1);
4565 function concatMapTo(innerObservable, resultSelector) {
4566 return concatMap(function () { return innerObservable; }, resultSelector);
4569 function count(predicate) {
4570 return function (source) { return source.lift(new CountOperator(predicate, source)); };
4572 var CountOperator = (function () {
4573 function CountOperator(predicate, source) {
4574 this.predicate = predicate;
4575 this.source = source;
4577 CountOperator.prototype.call = function (subscriber, source) {
4578 return source.subscribe(new CountSubscriber(subscriber, this.predicate, this.source));
4580 return CountOperator;
4582 var CountSubscriber = (function (_super) {
4583 __extends(CountSubscriber, _super);
4584 function CountSubscriber(destination, predicate, source) {
4585 var _this = _super.call(this, destination) || this;
4586 _this.predicate = predicate;
4587 _this.source = source;
4592 CountSubscriber.prototype._next = function (value) {
4593 if (this.predicate) {
4594 this._tryPredicate(value);
4600 CountSubscriber.prototype._tryPredicate = function (value) {
4603 result = this.predicate(value, this.index++, this.source);
4606 this.destination.error(err);
4613 CountSubscriber.prototype._complete = function () {
4614 this.destination.next(this.count);
4615 this.destination.complete();
4617 return CountSubscriber;
4620 function debounce(durationSelector) {
4621 return function (source) { return source.lift(new DebounceOperator(durationSelector)); };
4623 var DebounceOperator = (function () {
4624 function DebounceOperator(durationSelector) {
4625 this.durationSelector = durationSelector;
4627 DebounceOperator.prototype.call = function (subscriber, source) {
4628 return source.subscribe(new DebounceSubscriber(subscriber, this.durationSelector));
4630 return DebounceOperator;
4632 var DebounceSubscriber = (function (_super) {
4633 __extends(DebounceSubscriber, _super);
4634 function DebounceSubscriber(destination, durationSelector) {
4635 var _this = _super.call(this, destination) || this;
4636 _this.durationSelector = durationSelector;
4637 _this.hasValue = false;
4638 _this.durationSubscription = null;
4641 DebounceSubscriber.prototype._next = function (value) {
4643 var result = this.durationSelector.call(this, value);
4645 this._tryNext(value, result);
4649 this.destination.error(err);
4652 DebounceSubscriber.prototype._complete = function () {
4654 this.destination.complete();
4656 DebounceSubscriber.prototype._tryNext = function (value, duration) {
4657 var subscription = this.durationSubscription;
4659 this.hasValue = true;
4661 subscription.unsubscribe();
4662 this.remove(subscription);
4664 subscription = subscribeToResult(this, duration);
4665 if (subscription && !subscription.closed) {
4666 this.add(this.durationSubscription = subscription);
4669 DebounceSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
4672 DebounceSubscriber.prototype.notifyComplete = function () {
4675 DebounceSubscriber.prototype.emitValue = function () {
4676 if (this.hasValue) {
4677 var value = this.value;
4678 var subscription = this.durationSubscription;
4680 this.durationSubscription = null;
4681 subscription.unsubscribe();
4682 this.remove(subscription);
4685 this.hasValue = false;
4686 _super.prototype._next.call(this, value);
4689 return DebounceSubscriber;
4690 }(OuterSubscriber));
4692 function debounceTime(dueTime, scheduler) {
4693 if (scheduler === void 0) { scheduler = async; }
4694 return function (source) { return source.lift(new DebounceTimeOperator(dueTime, scheduler)); };
4696 var DebounceTimeOperator = (function () {
4697 function DebounceTimeOperator(dueTime, scheduler) {
4698 this.dueTime = dueTime;
4699 this.scheduler = scheduler;
4701 DebounceTimeOperator.prototype.call = function (subscriber, source) {
4702 return source.subscribe(new DebounceTimeSubscriber(subscriber, this.dueTime, this.scheduler));
4704 return DebounceTimeOperator;
4706 var DebounceTimeSubscriber = (function (_super) {
4707 __extends(DebounceTimeSubscriber, _super);
4708 function DebounceTimeSubscriber(destination, dueTime, scheduler) {
4709 var _this = _super.call(this, destination) || this;
4710 _this.dueTime = dueTime;
4711 _this.scheduler = scheduler;
4712 _this.debouncedSubscription = null;
4713 _this.lastValue = null;
4714 _this.hasValue = false;
4717 DebounceTimeSubscriber.prototype._next = function (value) {
4718 this.clearDebounce();
4719 this.lastValue = value;
4720 this.hasValue = true;
4721 this.add(this.debouncedSubscription = this.scheduler.schedule(dispatchNext$2, this.dueTime, this));
4723 DebounceTimeSubscriber.prototype._complete = function () {
4724 this.debouncedNext();
4725 this.destination.complete();
4727 DebounceTimeSubscriber.prototype.debouncedNext = function () {
4728 this.clearDebounce();
4729 if (this.hasValue) {
4730 var lastValue = this.lastValue;
4731 this.lastValue = null;
4732 this.hasValue = false;
4733 this.destination.next(lastValue);
4736 DebounceTimeSubscriber.prototype.clearDebounce = function () {
4737 var debouncedSubscription = this.debouncedSubscription;
4738 if (debouncedSubscription !== null) {
4739 this.remove(debouncedSubscription);
4740 debouncedSubscription.unsubscribe();
4741 this.debouncedSubscription = null;
4744 return DebounceTimeSubscriber;
4746 function dispatchNext$2(subscriber) {
4747 subscriber.debouncedNext();
4750 function defaultIfEmpty(defaultValue) {
4751 if (defaultValue === void 0) { defaultValue = null; }
4752 return function (source) { return source.lift(new DefaultIfEmptyOperator(defaultValue)); };
4754 var DefaultIfEmptyOperator = (function () {
4755 function DefaultIfEmptyOperator(defaultValue) {
4756 this.defaultValue = defaultValue;
4758 DefaultIfEmptyOperator.prototype.call = function (subscriber, source) {
4759 return source.subscribe(new DefaultIfEmptySubscriber(subscriber, this.defaultValue));
4761 return DefaultIfEmptyOperator;
4763 var DefaultIfEmptySubscriber = (function (_super) {
4764 __extends(DefaultIfEmptySubscriber, _super);
4765 function DefaultIfEmptySubscriber(destination, defaultValue) {
4766 var _this = _super.call(this, destination) || this;
4767 _this.defaultValue = defaultValue;
4768 _this.isEmpty = true;
4771 DefaultIfEmptySubscriber.prototype._next = function (value) {
4772 this.isEmpty = false;
4773 this.destination.next(value);
4775 DefaultIfEmptySubscriber.prototype._complete = function () {
4777 this.destination.next(this.defaultValue);
4779 this.destination.complete();
4781 return DefaultIfEmptySubscriber;
4784 function isDate(value) {
4785 return value instanceof Date && !isNaN(+value);
4788 function delay(delay, scheduler) {
4789 if (scheduler === void 0) { scheduler = async; }
4790 var absoluteDelay = isDate(delay);
4791 var delayFor = absoluteDelay ? (+delay - scheduler.now()) : Math.abs(delay);
4792 return function (source) { return source.lift(new DelayOperator(delayFor, scheduler)); };
4794 var DelayOperator = (function () {
4795 function DelayOperator(delay, scheduler) {
4797 this.scheduler = scheduler;
4799 DelayOperator.prototype.call = function (subscriber, source) {
4800 return source.subscribe(new DelaySubscriber(subscriber, this.delay, this.scheduler));
4802 return DelayOperator;
4804 var DelaySubscriber = (function (_super) {
4805 __extends(DelaySubscriber, _super);
4806 function DelaySubscriber(destination, delay, scheduler) {
4807 var _this = _super.call(this, destination) || this;
4808 _this.delay = delay;
4809 _this.scheduler = scheduler;
4811 _this.active = false;
4812 _this.errored = false;
4815 DelaySubscriber.dispatch = function (state) {
4816 var source = state.source;
4817 var queue = source.queue;
4818 var scheduler = state.scheduler;
4819 var destination = state.destination;
4820 while (queue.length > 0 && (queue[0].time - scheduler.now()) <= 0) {
4821 queue.shift().notification.observe(destination);
4823 if (queue.length > 0) {
4824 var delay_1 = Math.max(0, queue[0].time - scheduler.now());
4825 this.schedule(state, delay_1);
4829 source.active = false;
4832 DelaySubscriber.prototype._schedule = function (scheduler) {
4834 var destination = this.destination;
4835 destination.add(scheduler.schedule(DelaySubscriber.dispatch, this.delay, {
4836 source: this, destination: this.destination, scheduler: scheduler
4839 DelaySubscriber.prototype.scheduleNotification = function (notification) {
4840 if (this.errored === true) {
4843 var scheduler = this.scheduler;
4844 var message = new DelayMessage(scheduler.now() + this.delay, notification);
4845 this.queue.push(message);
4846 if (this.active === false) {
4847 this._schedule(scheduler);
4850 DelaySubscriber.prototype._next = function (value) {
4851 this.scheduleNotification(Notification.createNext(value));
4853 DelaySubscriber.prototype._error = function (err) {
4854 this.errored = true;
4856 this.destination.error(err);
4859 DelaySubscriber.prototype._complete = function () {
4860 this.scheduleNotification(Notification.createComplete());
4863 return DelaySubscriber;
4865 var DelayMessage = (function () {
4866 function DelayMessage(time, notification) {
4868 this.notification = notification;
4870 return DelayMessage;
4873 function delayWhen(delayDurationSelector, subscriptionDelay) {
4874 if (subscriptionDelay) {
4875 return function (source) {
4876 return new SubscriptionDelayObservable(source, subscriptionDelay)
4877 .lift(new DelayWhenOperator(delayDurationSelector));
4880 return function (source) { return source.lift(new DelayWhenOperator(delayDurationSelector)); };
4882 var DelayWhenOperator = (function () {
4883 function DelayWhenOperator(delayDurationSelector) {
4884 this.delayDurationSelector = delayDurationSelector;
4886 DelayWhenOperator.prototype.call = function (subscriber, source) {
4887 return source.subscribe(new DelayWhenSubscriber(subscriber, this.delayDurationSelector));
4889 return DelayWhenOperator;
4891 var DelayWhenSubscriber = (function (_super) {
4892 __extends(DelayWhenSubscriber, _super);
4893 function DelayWhenSubscriber(destination, delayDurationSelector) {
4894 var _this = _super.call(this, destination) || this;
4895 _this.delayDurationSelector = delayDurationSelector;
4896 _this.completed = false;
4897 _this.delayNotifierSubscriptions = [];
4901 DelayWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
4902 this.destination.next(outerValue);
4903 this.removeSubscription(innerSub);
4906 DelayWhenSubscriber.prototype.notifyError = function (error, innerSub) {
4909 DelayWhenSubscriber.prototype.notifyComplete = function (innerSub) {
4910 var value = this.removeSubscription(innerSub);
4912 this.destination.next(value);
4916 DelayWhenSubscriber.prototype._next = function (value) {
4917 var index = this.index++;
4919 var delayNotifier = this.delayDurationSelector(value, index);
4920 if (delayNotifier) {
4921 this.tryDelay(delayNotifier, value);
4925 this.destination.error(err);
4928 DelayWhenSubscriber.prototype._complete = function () {
4929 this.completed = true;
4933 DelayWhenSubscriber.prototype.removeSubscription = function (subscription) {
4934 subscription.unsubscribe();
4935 var subscriptionIdx = this.delayNotifierSubscriptions.indexOf(subscription);
4936 if (subscriptionIdx !== -1) {
4937 this.delayNotifierSubscriptions.splice(subscriptionIdx, 1);
4939 return subscription.outerValue;
4941 DelayWhenSubscriber.prototype.tryDelay = function (delayNotifier, value) {
4942 var notifierSubscription = subscribeToResult(this, delayNotifier, value);
4943 if (notifierSubscription && !notifierSubscription.closed) {
4944 var destination = this.destination;
4945 destination.add(notifierSubscription);
4946 this.delayNotifierSubscriptions.push(notifierSubscription);
4949 DelayWhenSubscriber.prototype.tryComplete = function () {
4950 if (this.completed && this.delayNotifierSubscriptions.length === 0) {
4951 this.destination.complete();
4954 return DelayWhenSubscriber;
4955 }(OuterSubscriber));
4956 var SubscriptionDelayObservable = (function (_super) {
4957 __extends(SubscriptionDelayObservable, _super);
4958 function SubscriptionDelayObservable(source, subscriptionDelay) {
4959 var _this = _super.call(this) || this;
4960 _this.source = source;
4961 _this.subscriptionDelay = subscriptionDelay;
4964 SubscriptionDelayObservable.prototype._subscribe = function (subscriber) {
4965 this.subscriptionDelay.subscribe(new SubscriptionDelaySubscriber(subscriber, this.source));
4967 return SubscriptionDelayObservable;
4969 var SubscriptionDelaySubscriber = (function (_super) {
4970 __extends(SubscriptionDelaySubscriber, _super);
4971 function SubscriptionDelaySubscriber(parent, source) {
4972 var _this = _super.call(this) || this;
4973 _this.parent = parent;
4974 _this.source = source;
4975 _this.sourceSubscribed = false;
4978 SubscriptionDelaySubscriber.prototype._next = function (unused) {
4979 this.subscribeToSource();
4981 SubscriptionDelaySubscriber.prototype._error = function (err) {
4983 this.parent.error(err);
4985 SubscriptionDelaySubscriber.prototype._complete = function () {
4987 this.subscribeToSource();
4989 SubscriptionDelaySubscriber.prototype.subscribeToSource = function () {
4990 if (!this.sourceSubscribed) {
4991 this.sourceSubscribed = true;
4993 this.source.subscribe(this.parent);
4996 return SubscriptionDelaySubscriber;
4999 function dematerialize() {
5000 return function dematerializeOperatorFunction(source) {
5001 return source.lift(new DeMaterializeOperator());
5004 var DeMaterializeOperator = (function () {
5005 function DeMaterializeOperator() {
5007 DeMaterializeOperator.prototype.call = function (subscriber, source) {
5008 return source.subscribe(new DeMaterializeSubscriber(subscriber));
5010 return DeMaterializeOperator;
5012 var DeMaterializeSubscriber = (function (_super) {
5013 __extends(DeMaterializeSubscriber, _super);
5014 function DeMaterializeSubscriber(destination) {
5015 return _super.call(this, destination) || this;
5017 DeMaterializeSubscriber.prototype._next = function (value) {
5018 value.observe(this.destination);
5020 return DeMaterializeSubscriber;
5023 function distinct(keySelector, flushes) {
5024 return function (source) { return source.lift(new DistinctOperator(keySelector, flushes)); };
5026 var DistinctOperator = (function () {
5027 function DistinctOperator(keySelector, flushes) {
5028 this.keySelector = keySelector;
5029 this.flushes = flushes;
5031 DistinctOperator.prototype.call = function (subscriber, source) {
5032 return source.subscribe(new DistinctSubscriber(subscriber, this.keySelector, this.flushes));
5034 return DistinctOperator;
5036 var DistinctSubscriber = (function (_super) {
5037 __extends(DistinctSubscriber, _super);
5038 function DistinctSubscriber(destination, keySelector, flushes) {
5039 var _this = _super.call(this, destination) || this;
5040 _this.keySelector = keySelector;
5041 _this.values = new Set();
5043 _this.add(subscribeToResult(_this, flushes));
5047 DistinctSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
5048 this.values.clear();
5050 DistinctSubscriber.prototype.notifyError = function (error, innerSub) {
5053 DistinctSubscriber.prototype._next = function (value) {
5054 if (this.keySelector) {
5055 this._useKeySelector(value);
5058 this._finalizeNext(value, value);
5061 DistinctSubscriber.prototype._useKeySelector = function (value) {
5063 var destination = this.destination;
5065 key = this.keySelector(value);
5068 destination.error(err);
5071 this._finalizeNext(key, value);
5073 DistinctSubscriber.prototype._finalizeNext = function (key, value) {
5074 var values = this.values;
5075 if (!values.has(key)) {
5077 this.destination.next(value);
5080 return DistinctSubscriber;
5081 }(OuterSubscriber));
5083 function distinctUntilChanged(compare, keySelector) {
5084 return function (source) { return source.lift(new DistinctUntilChangedOperator(compare, keySelector)); };
5086 var DistinctUntilChangedOperator = (function () {
5087 function DistinctUntilChangedOperator(compare, keySelector) {
5088 this.compare = compare;
5089 this.keySelector = keySelector;
5091 DistinctUntilChangedOperator.prototype.call = function (subscriber, source) {
5092 return source.subscribe(new DistinctUntilChangedSubscriber(subscriber, this.compare, this.keySelector));
5094 return DistinctUntilChangedOperator;
5096 var DistinctUntilChangedSubscriber = (function (_super) {
5097 __extends(DistinctUntilChangedSubscriber, _super);
5098 function DistinctUntilChangedSubscriber(destination, compare, keySelector) {
5099 var _this = _super.call(this, destination) || this;
5100 _this.keySelector = keySelector;
5101 _this.hasKey = false;
5102 if (typeof compare === 'function') {
5103 _this.compare = compare;
5107 DistinctUntilChangedSubscriber.prototype.compare = function (x, y) {
5110 DistinctUntilChangedSubscriber.prototype._next = function (value) {
5113 var keySelector = this.keySelector;
5114 key = keySelector ? keySelector(value) : value;
5117 return this.destination.error(err);
5122 var compare = this.compare;
5123 result = compare(this.key, key);
5126 return this.destination.error(err);
5134 this.destination.next(value);
5137 return DistinctUntilChangedSubscriber;
5140 function distinctUntilKeyChanged(key, compare) {
5141 return distinctUntilChanged(function (x, y) { return compare ? compare(x[key], y[key]) : x[key] === y[key]; });
5144 function throwIfEmpty(errorFactory) {
5145 if (errorFactory === void 0) { errorFactory = defaultErrorFactory; }
5146 return function (source) {
5147 return source.lift(new ThrowIfEmptyOperator(errorFactory));
5150 var ThrowIfEmptyOperator = (function () {
5151 function ThrowIfEmptyOperator(errorFactory) {
5152 this.errorFactory = errorFactory;
5154 ThrowIfEmptyOperator.prototype.call = function (subscriber, source) {
5155 return source.subscribe(new ThrowIfEmptySubscriber(subscriber, this.errorFactory));
5157 return ThrowIfEmptyOperator;
5159 var ThrowIfEmptySubscriber = (function (_super) {
5160 __extends(ThrowIfEmptySubscriber, _super);
5161 function ThrowIfEmptySubscriber(destination, errorFactory) {
5162 var _this = _super.call(this, destination) || this;
5163 _this.errorFactory = errorFactory;
5164 _this.hasValue = false;
5167 ThrowIfEmptySubscriber.prototype._next = function (value) {
5168 this.hasValue = true;
5169 this.destination.next(value);
5171 ThrowIfEmptySubscriber.prototype._complete = function () {
5172 if (!this.hasValue) {
5175 err = this.errorFactory();
5180 this.destination.error(err);
5183 return this.destination.complete();
5186 return ThrowIfEmptySubscriber;
5188 function defaultErrorFactory() {
5189 return new EmptyError();
5192 function take(count) {
5193 return function (source) {
5198 return source.lift(new TakeOperator(count));
5202 var TakeOperator = (function () {
5203 function TakeOperator(total) {
5205 if (this.total < 0) {
5206 throw new ArgumentOutOfRangeError;
5209 TakeOperator.prototype.call = function (subscriber, source) {
5210 return source.subscribe(new TakeSubscriber(subscriber, this.total));
5212 return TakeOperator;
5214 var TakeSubscriber = (function (_super) {
5215 __extends(TakeSubscriber, _super);
5216 function TakeSubscriber(destination, total) {
5217 var _this = _super.call(this, destination) || this;
5218 _this.total = total;
5222 TakeSubscriber.prototype._next = function (value) {
5223 var total = this.total;
5224 var count = ++this.count;
5225 if (count <= total) {
5226 this.destination.next(value);
5227 if (count === total) {
5228 this.destination.complete();
5233 return TakeSubscriber;
5236 function elementAt(index, defaultValue) {
5238 throw new ArgumentOutOfRangeError();
5240 var hasDefaultValue = arguments.length >= 2;
5241 return function (source) { return source.pipe(filter(function (v, i) { return i === index; }), take(1), hasDefaultValue
5242 ? defaultIfEmpty(defaultValue)
5243 : throwIfEmpty(function () { return new ArgumentOutOfRangeError(); })); };
5246 function endWith() {
5248 for (var _i = 0; _i < arguments.length; _i++) {
5249 array[_i] = arguments[_i];
5251 return function (source) { return concat(source, of.apply(void 0, array)); };
5254 function every(predicate, thisArg) {
5255 return function (source) { return source.lift(new EveryOperator(predicate, thisArg, source)); };
5257 var EveryOperator = (function () {
5258 function EveryOperator(predicate, thisArg, source) {
5259 this.predicate = predicate;
5260 this.thisArg = thisArg;
5261 this.source = source;
5263 EveryOperator.prototype.call = function (observer, source) {
5264 return source.subscribe(new EverySubscriber(observer, this.predicate, this.thisArg, this.source));
5266 return EveryOperator;
5268 var EverySubscriber = (function (_super) {
5269 __extends(EverySubscriber, _super);
5270 function EverySubscriber(destination, predicate, thisArg, source) {
5271 var _this = _super.call(this, destination) || this;
5272 _this.predicate = predicate;
5273 _this.thisArg = thisArg;
5274 _this.source = source;
5276 _this.thisArg = thisArg || _this;
5279 EverySubscriber.prototype.notifyComplete = function (everyValueMatch) {
5280 this.destination.next(everyValueMatch);
5281 this.destination.complete();
5283 EverySubscriber.prototype._next = function (value) {
5286 result = this.predicate.call(this.thisArg, value, this.index++, this.source);
5289 this.destination.error(err);
5293 this.notifyComplete(false);
5296 EverySubscriber.prototype._complete = function () {
5297 this.notifyComplete(true);
5299 return EverySubscriber;
5302 function exhaust() {
5303 return function (source) { return source.lift(new SwitchFirstOperator()); };
5305 var SwitchFirstOperator = (function () {
5306 function SwitchFirstOperator() {
5308 SwitchFirstOperator.prototype.call = function (subscriber, source) {
5309 return source.subscribe(new SwitchFirstSubscriber(subscriber));
5311 return SwitchFirstOperator;
5313 var SwitchFirstSubscriber = (function (_super) {
5314 __extends(SwitchFirstSubscriber, _super);
5315 function SwitchFirstSubscriber(destination) {
5316 var _this = _super.call(this, destination) || this;
5317 _this.hasCompleted = false;
5318 _this.hasSubscription = false;
5321 SwitchFirstSubscriber.prototype._next = function (value) {
5322 if (!this.hasSubscription) {
5323 this.hasSubscription = true;
5324 this.add(subscribeToResult(this, value));
5327 SwitchFirstSubscriber.prototype._complete = function () {
5328 this.hasCompleted = true;
5329 if (!this.hasSubscription) {
5330 this.destination.complete();
5333 SwitchFirstSubscriber.prototype.notifyComplete = function (innerSub) {
5334 this.remove(innerSub);
5335 this.hasSubscription = false;
5336 if (this.hasCompleted) {
5337 this.destination.complete();
5340 return SwitchFirstSubscriber;
5341 }(OuterSubscriber));
5343 function exhaustMap(project, resultSelector) {
5344 if (resultSelector) {
5345 return function (source) { return source.pipe(exhaustMap(function (a, i) { return from(project(a, i)).pipe(map(function (b, ii) { return resultSelector(a, b, i, ii); })); })); };
5347 return function (source) {
5348 return source.lift(new ExhaustMapOperator(project));
5351 var ExhaustMapOperator = (function () {
5352 function ExhaustMapOperator(project) {
5353 this.project = project;
5355 ExhaustMapOperator.prototype.call = function (subscriber, source) {
5356 return source.subscribe(new ExhaustMapSubscriber(subscriber, this.project));
5358 return ExhaustMapOperator;
5360 var ExhaustMapSubscriber = (function (_super) {
5361 __extends(ExhaustMapSubscriber, _super);
5362 function ExhaustMapSubscriber(destination, project) {
5363 var _this = _super.call(this, destination) || this;
5364 _this.project = project;
5365 _this.hasSubscription = false;
5366 _this.hasCompleted = false;
5370 ExhaustMapSubscriber.prototype._next = function (value) {
5371 if (!this.hasSubscription) {
5372 this.tryNext(value);
5375 ExhaustMapSubscriber.prototype.tryNext = function (value) {
5377 var index = this.index++;
5379 result = this.project(value, index);
5382 this.destination.error(err);
5385 this.hasSubscription = true;
5386 this._innerSub(result, value, index);
5388 ExhaustMapSubscriber.prototype._innerSub = function (result, value, index) {
5389 var innerSubscriber = new InnerSubscriber(this, value, index);
5390 var destination = this.destination;
5391 destination.add(innerSubscriber);
5392 var innerSubscription = subscribeToResult(this, result, undefined, undefined, innerSubscriber);
5393 if (innerSubscription !== innerSubscriber) {
5394 destination.add(innerSubscription);
5397 ExhaustMapSubscriber.prototype._complete = function () {
5398 this.hasCompleted = true;
5399 if (!this.hasSubscription) {
5400 this.destination.complete();
5404 ExhaustMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
5405 this.destination.next(innerValue);
5407 ExhaustMapSubscriber.prototype.notifyError = function (err) {
5408 this.destination.error(err);
5410 ExhaustMapSubscriber.prototype.notifyComplete = function (innerSub) {
5411 var destination = this.destination;
5412 destination.remove(innerSub);
5413 this.hasSubscription = false;
5414 if (this.hasCompleted) {
5415 this.destination.complete();
5418 return ExhaustMapSubscriber;
5419 }(OuterSubscriber));
5421 function expand(project, concurrent, scheduler) {
5422 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
5423 if (scheduler === void 0) { scheduler = undefined; }
5424 concurrent = (concurrent || 0) < 1 ? Number.POSITIVE_INFINITY : concurrent;
5425 return function (source) { return source.lift(new ExpandOperator(project, concurrent, scheduler)); };
5427 var ExpandOperator = (function () {
5428 function ExpandOperator(project, concurrent, scheduler) {
5429 this.project = project;
5430 this.concurrent = concurrent;
5431 this.scheduler = scheduler;
5433 ExpandOperator.prototype.call = function (subscriber, source) {
5434 return source.subscribe(new ExpandSubscriber(subscriber, this.project, this.concurrent, this.scheduler));
5436 return ExpandOperator;
5438 var ExpandSubscriber = (function (_super) {
5439 __extends(ExpandSubscriber, _super);
5440 function ExpandSubscriber(destination, project, concurrent, scheduler) {
5441 var _this = _super.call(this, destination) || this;
5442 _this.project = project;
5443 _this.concurrent = concurrent;
5444 _this.scheduler = scheduler;
5447 _this.hasCompleted = false;
5448 if (concurrent < Number.POSITIVE_INFINITY) {
5453 ExpandSubscriber.dispatch = function (arg) {
5454 var subscriber = arg.subscriber, result = arg.result, value = arg.value, index = arg.index;
5455 subscriber.subscribeToProjection(result, value, index);
5457 ExpandSubscriber.prototype._next = function (value) {
5458 var destination = this.destination;
5459 if (destination.closed) {
5463 var index = this.index++;
5464 if (this.active < this.concurrent) {
5465 destination.next(value);
5467 var project = this.project;
5468 var result = project(value, index);
5469 if (!this.scheduler) {
5470 this.subscribeToProjection(result, value, index);
5473 var state = { subscriber: this, result: result, value: value, index: index };
5474 var destination_1 = this.destination;
5475 destination_1.add(this.scheduler.schedule(ExpandSubscriber.dispatch, 0, state));
5479 destination.error(e);
5483 this.buffer.push(value);
5486 ExpandSubscriber.prototype.subscribeToProjection = function (result, value, index) {
5488 var destination = this.destination;
5489 destination.add(subscribeToResult(this, result, value, index));
5491 ExpandSubscriber.prototype._complete = function () {
5492 this.hasCompleted = true;
5493 if (this.hasCompleted && this.active === 0) {
5494 this.destination.complete();
5498 ExpandSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
5499 this._next(innerValue);
5501 ExpandSubscriber.prototype.notifyComplete = function (innerSub) {
5502 var buffer = this.buffer;
5503 var destination = this.destination;
5504 destination.remove(innerSub);
5506 if (buffer && buffer.length > 0) {
5507 this._next(buffer.shift());
5509 if (this.hasCompleted && this.active === 0) {
5510 this.destination.complete();
5513 return ExpandSubscriber;
5514 }(OuterSubscriber));
5516 function finalize(callback) {
5517 return function (source) { return source.lift(new FinallyOperator(callback)); };
5519 var FinallyOperator = (function () {
5520 function FinallyOperator(callback) {
5521 this.callback = callback;
5523 FinallyOperator.prototype.call = function (subscriber, source) {
5524 return source.subscribe(new FinallySubscriber(subscriber, this.callback));
5526 return FinallyOperator;
5528 var FinallySubscriber = (function (_super) {
5529 __extends(FinallySubscriber, _super);
5530 function FinallySubscriber(destination, callback) {
5531 var _this = _super.call(this, destination) || this;
5532 _this.add(new Subscription(callback));
5535 return FinallySubscriber;
5538 function find(predicate, thisArg) {
5539 if (typeof predicate !== 'function') {
5540 throw new TypeError('predicate is not a function');
5542 return function (source) { return source.lift(new FindValueOperator(predicate, source, false, thisArg)); };
5544 var FindValueOperator = (function () {
5545 function FindValueOperator(predicate, source, yieldIndex, thisArg) {
5546 this.predicate = predicate;
5547 this.source = source;
5548 this.yieldIndex = yieldIndex;
5549 this.thisArg = thisArg;
5551 FindValueOperator.prototype.call = function (observer, source) {
5552 return source.subscribe(new FindValueSubscriber(observer, this.predicate, this.source, this.yieldIndex, this.thisArg));
5554 return FindValueOperator;
5556 var FindValueSubscriber = (function (_super) {
5557 __extends(FindValueSubscriber, _super);
5558 function FindValueSubscriber(destination, predicate, source, yieldIndex, thisArg) {
5559 var _this = _super.call(this, destination) || this;
5560 _this.predicate = predicate;
5561 _this.source = source;
5562 _this.yieldIndex = yieldIndex;
5563 _this.thisArg = thisArg;
5567 FindValueSubscriber.prototype.notifyComplete = function (value) {
5568 var destination = this.destination;
5569 destination.next(value);
5570 destination.complete();
5573 FindValueSubscriber.prototype._next = function (value) {
5574 var _a = this, predicate = _a.predicate, thisArg = _a.thisArg;
5575 var index = this.index++;
5577 var result = predicate.call(thisArg || this, value, index, this.source);
5579 this.notifyComplete(this.yieldIndex ? index : value);
5583 this.destination.error(err);
5586 FindValueSubscriber.prototype._complete = function () {
5587 this.notifyComplete(this.yieldIndex ? -1 : undefined);
5589 return FindValueSubscriber;
5592 function findIndex(predicate, thisArg) {
5593 return function (source) { return source.lift(new FindValueOperator(predicate, source, true, thisArg)); };
5596 function first(predicate, defaultValue) {
5597 var hasDefaultValue = arguments.length >= 2;
5598 return function (source) { return source.pipe(predicate ? filter(function (v, i) { return predicate(v, i, source); }) : identity, take(1), hasDefaultValue ? defaultIfEmpty(defaultValue) : throwIfEmpty(function () { return new EmptyError(); })); };
5601 function ignoreElements() {
5602 return function ignoreElementsOperatorFunction(source) {
5603 return source.lift(new IgnoreElementsOperator());
5606 var IgnoreElementsOperator = (function () {
5607 function IgnoreElementsOperator() {
5609 IgnoreElementsOperator.prototype.call = function (subscriber, source) {
5610 return source.subscribe(new IgnoreElementsSubscriber(subscriber));
5612 return IgnoreElementsOperator;
5614 var IgnoreElementsSubscriber = (function (_super) {
5615 __extends(IgnoreElementsSubscriber, _super);
5616 function IgnoreElementsSubscriber() {
5617 return _super !== null && _super.apply(this, arguments) || this;
5619 IgnoreElementsSubscriber.prototype._next = function (unused) {
5621 return IgnoreElementsSubscriber;
5624 function isEmpty() {
5625 return function (source) { return source.lift(new IsEmptyOperator()); };
5627 var IsEmptyOperator = (function () {
5628 function IsEmptyOperator() {
5630 IsEmptyOperator.prototype.call = function (observer, source) {
5631 return source.subscribe(new IsEmptySubscriber(observer));
5633 return IsEmptyOperator;
5635 var IsEmptySubscriber = (function (_super) {
5636 __extends(IsEmptySubscriber, _super);
5637 function IsEmptySubscriber(destination) {
5638 return _super.call(this, destination) || this;
5640 IsEmptySubscriber.prototype.notifyComplete = function (isEmpty) {
5641 var destination = this.destination;
5642 destination.next(isEmpty);
5643 destination.complete();
5645 IsEmptySubscriber.prototype._next = function (value) {
5646 this.notifyComplete(false);
5648 IsEmptySubscriber.prototype._complete = function () {
5649 this.notifyComplete(true);
5651 return IsEmptySubscriber;
5654 function takeLast(count) {
5655 return function takeLastOperatorFunction(source) {
5660 return source.lift(new TakeLastOperator(count));
5664 var TakeLastOperator = (function () {
5665 function TakeLastOperator(total) {
5667 if (this.total < 0) {
5668 throw new ArgumentOutOfRangeError;
5671 TakeLastOperator.prototype.call = function (subscriber, source) {
5672 return source.subscribe(new TakeLastSubscriber(subscriber, this.total));
5674 return TakeLastOperator;
5676 var TakeLastSubscriber = (function (_super) {
5677 __extends(TakeLastSubscriber, _super);
5678 function TakeLastSubscriber(destination, total) {
5679 var _this = _super.call(this, destination) || this;
5680 _this.total = total;
5681 _this.ring = new Array();
5685 TakeLastSubscriber.prototype._next = function (value) {
5686 var ring = this.ring;
5687 var total = this.total;
5688 var count = this.count++;
5689 if (ring.length < total) {
5693 var index = count % total;
5694 ring[index] = value;
5697 TakeLastSubscriber.prototype._complete = function () {
5698 var destination = this.destination;
5699 var count = this.count;
5701 var total = this.count >= this.total ? this.total : this.count;
5702 var ring = this.ring;
5703 for (var i = 0; i < total; i++) {
5704 var idx = (count++) % total;
5705 destination.next(ring[idx]);
5708 destination.complete();
5710 return TakeLastSubscriber;
5713 function last(predicate, defaultValue) {
5714 var hasDefaultValue = arguments.length >= 2;
5715 return function (source) { return source.pipe(predicate ? filter(function (v, i) { return predicate(v, i, source); }) : identity, takeLast(1), hasDefaultValue ? defaultIfEmpty(defaultValue) : throwIfEmpty(function () { return new EmptyError(); })); };
5718 function mapTo(value) {
5719 return function (source) { return source.lift(new MapToOperator(value)); };
5721 var MapToOperator = (function () {
5722 function MapToOperator(value) {
5725 MapToOperator.prototype.call = function (subscriber, source) {
5726 return source.subscribe(new MapToSubscriber(subscriber, this.value));
5728 return MapToOperator;
5730 var MapToSubscriber = (function (_super) {
5731 __extends(MapToSubscriber, _super);
5732 function MapToSubscriber(destination, value) {
5733 var _this = _super.call(this, destination) || this;
5734 _this.value = value;
5737 MapToSubscriber.prototype._next = function (x) {
5738 this.destination.next(this.value);
5740 return MapToSubscriber;
5743 function materialize() {
5744 return function materializeOperatorFunction(source) {
5745 return source.lift(new MaterializeOperator());
5748 var MaterializeOperator = (function () {
5749 function MaterializeOperator() {
5751 MaterializeOperator.prototype.call = function (subscriber, source) {
5752 return source.subscribe(new MaterializeSubscriber(subscriber));
5754 return MaterializeOperator;
5756 var MaterializeSubscriber = (function (_super) {
5757 __extends(MaterializeSubscriber, _super);
5758 function MaterializeSubscriber(destination) {
5759 return _super.call(this, destination) || this;
5761 MaterializeSubscriber.prototype._next = function (value) {
5762 this.destination.next(Notification.createNext(value));
5764 MaterializeSubscriber.prototype._error = function (err) {
5765 var destination = this.destination;
5766 destination.next(Notification.createError(err));
5767 destination.complete();
5769 MaterializeSubscriber.prototype._complete = function () {
5770 var destination = this.destination;
5771 destination.next(Notification.createComplete());
5772 destination.complete();
5774 return MaterializeSubscriber;
5777 function scan(accumulator, seed) {
5778 var hasSeed = false;
5779 if (arguments.length >= 2) {
5782 return function scanOperatorFunction(source) {
5783 return source.lift(new ScanOperator(accumulator, seed, hasSeed));
5786 var ScanOperator = (function () {
5787 function ScanOperator(accumulator, seed, hasSeed) {
5788 if (hasSeed === void 0) { hasSeed = false; }
5789 this.accumulator = accumulator;
5791 this.hasSeed = hasSeed;
5793 ScanOperator.prototype.call = function (subscriber, source) {
5794 return source.subscribe(new ScanSubscriber(subscriber, this.accumulator, this.seed, this.hasSeed));
5796 return ScanOperator;
5798 var ScanSubscriber = (function (_super) {
5799 __extends(ScanSubscriber, _super);
5800 function ScanSubscriber(destination, accumulator, _seed, hasSeed) {
5801 var _this = _super.call(this, destination) || this;
5802 _this.accumulator = accumulator;
5803 _this._seed = _seed;
5804 _this.hasSeed = hasSeed;
5808 Object.defineProperty(ScanSubscriber.prototype, "seed", {
5812 set: function (value) {
5813 this.hasSeed = true;
5819 ScanSubscriber.prototype._next = function (value) {
5820 if (!this.hasSeed) {
5822 this.destination.next(value);
5825 return this._tryNext(value);
5828 ScanSubscriber.prototype._tryNext = function (value) {
5829 var index = this.index++;
5832 result = this.accumulator(this.seed, value, index);
5835 this.destination.error(err);
5838 this.destination.next(result);
5840 return ScanSubscriber;
5843 function reduce(accumulator, seed) {
5844 if (arguments.length >= 2) {
5845 return function reduceOperatorFunctionWithSeed(source) {
5846 return pipe(scan(accumulator, seed), takeLast(1), defaultIfEmpty(seed))(source);
5849 return function reduceOperatorFunction(source) {
5850 return pipe(scan(function (acc, value, index) { return accumulator(acc, value, index + 1); }), takeLast(1))(source);
5854 function max(comparer) {
5855 var max = (typeof comparer === 'function')
5856 ? function (x, y) { return comparer(x, y) > 0 ? x : y; }
5857 : function (x, y) { return x > y ? x : y; };
5861 function merge$1() {
5862 var observables = [];
5863 for (var _i = 0; _i < arguments.length; _i++) {
5864 observables[_i] = arguments[_i];
5866 return function (source) { return source.lift.call(merge.apply(void 0, [source].concat(observables))); };
5869 function mergeMapTo(innerObservable, resultSelector, concurrent) {
5870 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
5871 if (typeof resultSelector === 'function') {
5872 return mergeMap(function () { return innerObservable; }, resultSelector, concurrent);
5874 if (typeof resultSelector === 'number') {
5875 concurrent = resultSelector;
5877 return mergeMap(function () { return innerObservable; }, concurrent);
5880 function mergeScan(accumulator, seed, concurrent) {
5881 if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
5882 return function (source) { return source.lift(new MergeScanOperator(accumulator, seed, concurrent)); };
5884 var MergeScanOperator = (function () {
5885 function MergeScanOperator(accumulator, seed, concurrent) {
5886 this.accumulator = accumulator;
5888 this.concurrent = concurrent;
5890 MergeScanOperator.prototype.call = function (subscriber, source) {
5891 return source.subscribe(new MergeScanSubscriber(subscriber, this.accumulator, this.seed, this.concurrent));
5893 return MergeScanOperator;
5895 var MergeScanSubscriber = (function (_super) {
5896 __extends(MergeScanSubscriber, _super);
5897 function MergeScanSubscriber(destination, accumulator, acc, concurrent) {
5898 var _this = _super.call(this, destination) || this;
5899 _this.accumulator = accumulator;
5901 _this.concurrent = concurrent;
5902 _this.hasValue = false;
5903 _this.hasCompleted = false;
5909 MergeScanSubscriber.prototype._next = function (value) {
5910 if (this.active < this.concurrent) {
5911 var index = this.index++;
5912 var destination = this.destination;
5915 var accumulator = this.accumulator;
5916 ish = accumulator(this.acc, value, index);
5919 return destination.error(e);
5922 this._innerSub(ish, value, index);
5925 this.buffer.push(value);
5928 MergeScanSubscriber.prototype._innerSub = function (ish, value, index) {
5929 var innerSubscriber = new InnerSubscriber(this, value, index);
5930 var destination = this.destination;
5931 destination.add(innerSubscriber);
5932 var innerSubscription = subscribeToResult(this, ish, undefined, undefined, innerSubscriber);
5933 if (innerSubscription !== innerSubscriber) {
5934 destination.add(innerSubscription);
5937 MergeScanSubscriber.prototype._complete = function () {
5938 this.hasCompleted = true;
5939 if (this.active === 0 && this.buffer.length === 0) {
5940 if (this.hasValue === false) {
5941 this.destination.next(this.acc);
5943 this.destination.complete();
5947 MergeScanSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
5948 var destination = this.destination;
5949 this.acc = innerValue;
5950 this.hasValue = true;
5951 destination.next(innerValue);
5953 MergeScanSubscriber.prototype.notifyComplete = function (innerSub) {
5954 var buffer = this.buffer;
5955 var destination = this.destination;
5956 destination.remove(innerSub);
5958 if (buffer.length > 0) {
5959 this._next(buffer.shift());
5961 else if (this.active === 0 && this.hasCompleted) {
5962 if (this.hasValue === false) {
5963 this.destination.next(this.acc);
5965 this.destination.complete();
5968 return MergeScanSubscriber;
5969 }(OuterSubscriber));
5971 function min(comparer) {
5972 var min = (typeof comparer === 'function')
5973 ? function (x, y) { return comparer(x, y) < 0 ? x : y; }
5974 : function (x, y) { return x < y ? x : y; };
5978 function multicast(subjectOrSubjectFactory, selector) {
5979 return function multicastOperatorFunction(source) {
5981 if (typeof subjectOrSubjectFactory === 'function') {
5982 subjectFactory = subjectOrSubjectFactory;
5985 subjectFactory = function subjectFactory() {
5986 return subjectOrSubjectFactory;
5989 if (typeof selector === 'function') {
5990 return source.lift(new MulticastOperator(subjectFactory, selector));
5992 var connectable = Object.create(source, connectableObservableDescriptor);
5993 connectable.source = source;
5994 connectable.subjectFactory = subjectFactory;
5998 var MulticastOperator = (function () {
5999 function MulticastOperator(subjectFactory, selector) {
6000 this.subjectFactory = subjectFactory;
6001 this.selector = selector;
6003 MulticastOperator.prototype.call = function (subscriber, source) {
6004 var selector = this.selector;
6005 var subject = this.subjectFactory();
6006 var subscription = selector(subject).subscribe(subscriber);
6007 subscription.add(source.subscribe(subject));
6008 return subscription;
6010 return MulticastOperator;
6013 function onErrorResumeNext$1() {
6014 var nextSources = [];
6015 for (var _i = 0; _i < arguments.length; _i++) {
6016 nextSources[_i] = arguments[_i];
6018 if (nextSources.length === 1 && isArray(nextSources[0])) {
6019 nextSources = nextSources[0];
6021 return function (source) { return source.lift(new OnErrorResumeNextOperator(nextSources)); };
6023 var OnErrorResumeNextOperator = (function () {
6024 function OnErrorResumeNextOperator(nextSources) {
6025 this.nextSources = nextSources;
6027 OnErrorResumeNextOperator.prototype.call = function (subscriber, source) {
6028 return source.subscribe(new OnErrorResumeNextSubscriber(subscriber, this.nextSources));
6030 return OnErrorResumeNextOperator;
6032 var OnErrorResumeNextSubscriber = (function (_super) {
6033 __extends(OnErrorResumeNextSubscriber, _super);
6034 function OnErrorResumeNextSubscriber(destination, nextSources) {
6035 var _this = _super.call(this, destination) || this;
6036 _this.destination = destination;
6037 _this.nextSources = nextSources;
6040 OnErrorResumeNextSubscriber.prototype.notifyError = function (error, innerSub) {
6041 this.subscribeToNextSource();
6043 OnErrorResumeNextSubscriber.prototype.notifyComplete = function (innerSub) {
6044 this.subscribeToNextSource();
6046 OnErrorResumeNextSubscriber.prototype._error = function (err) {
6047 this.subscribeToNextSource();
6050 OnErrorResumeNextSubscriber.prototype._complete = function () {
6051 this.subscribeToNextSource();
6054 OnErrorResumeNextSubscriber.prototype.subscribeToNextSource = function () {
6055 var next = this.nextSources.shift();
6057 var innerSubscriber = new InnerSubscriber(this, undefined, undefined);
6058 var destination = this.destination;
6059 destination.add(innerSubscriber);
6060 var innerSubscription = subscribeToResult(this, next, undefined, undefined, innerSubscriber);
6061 if (innerSubscription !== innerSubscriber) {
6062 destination.add(innerSubscription);
6066 this.destination.complete();
6069 return OnErrorResumeNextSubscriber;
6070 }(OuterSubscriber));
6072 function pairwise() {
6073 return function (source) { return source.lift(new PairwiseOperator()); };
6075 var PairwiseOperator = (function () {
6076 function PairwiseOperator() {
6078 PairwiseOperator.prototype.call = function (subscriber, source) {
6079 return source.subscribe(new PairwiseSubscriber(subscriber));
6081 return PairwiseOperator;
6083 var PairwiseSubscriber = (function (_super) {
6084 __extends(PairwiseSubscriber, _super);
6085 function PairwiseSubscriber(destination) {
6086 var _this = _super.call(this, destination) || this;
6087 _this.hasPrev = false;
6090 PairwiseSubscriber.prototype._next = function (value) {
6093 pair = [this.prev, value];
6096 this.hasPrev = true;
6100 this.destination.next(pair);
6103 return PairwiseSubscriber;
6106 function partition$1(predicate, thisArg) {
6107 return function (source) { return [
6108 filter(predicate, thisArg)(source),
6109 filter(not(predicate, thisArg))(source)
6114 var properties = [];
6115 for (var _i = 0; _i < arguments.length; _i++) {
6116 properties[_i] = arguments[_i];
6118 var length = properties.length;
6120 throw new Error('list of properties cannot be empty.');
6122 return function (source) { return map(plucker(properties, length))(source); };
6124 function plucker(props, length) {
6125 var mapper = function (x) {
6126 var currentProp = x;
6127 for (var i = 0; i < length; i++) {
6128 var p = currentProp != null ? currentProp[props[i]] : undefined;
6141 function publish(selector) {
6143 multicast(function () { return new Subject(); }, selector) :
6144 multicast(new Subject());
6147 function publishBehavior(value) {
6148 return function (source) { return multicast(new BehaviorSubject(value))(source); };
6151 function publishLast() {
6152 return function (source) { return multicast(new AsyncSubject())(source); };
6155 function publishReplay(bufferSize, windowTime, selectorOrScheduler, scheduler) {
6156 if (selectorOrScheduler && typeof selectorOrScheduler !== 'function') {
6157 scheduler = selectorOrScheduler;
6159 var selector = typeof selectorOrScheduler === 'function' ? selectorOrScheduler : undefined;
6160 var subject = new ReplaySubject(bufferSize, windowTime, scheduler);
6161 return function (source) { return multicast(function () { return subject; }, selector)(source); };
6165 var observables = [];
6166 for (var _i = 0; _i < arguments.length; _i++) {
6167 observables[_i] = arguments[_i];
6169 return function raceOperatorFunction(source) {
6170 if (observables.length === 1 && isArray(observables[0])) {
6171 observables = observables[0];
6173 return source.lift.call(race.apply(void 0, [source].concat(observables)));
6177 function repeat(count) {
6178 if (count === void 0) { count = -1; }
6179 return function (source) {
6183 else if (count < 0) {
6184 return source.lift(new RepeatOperator(-1, source));
6187 return source.lift(new RepeatOperator(count - 1, source));
6191 var RepeatOperator = (function () {
6192 function RepeatOperator(count, source) {
6194 this.source = source;
6196 RepeatOperator.prototype.call = function (subscriber, source) {
6197 return source.subscribe(new RepeatSubscriber(subscriber, this.count, this.source));
6199 return RepeatOperator;
6201 var RepeatSubscriber = (function (_super) {
6202 __extends(RepeatSubscriber, _super);
6203 function RepeatSubscriber(destination, count, source) {
6204 var _this = _super.call(this, destination) || this;
6205 _this.count = count;
6206 _this.source = source;
6209 RepeatSubscriber.prototype.complete = function () {
6210 if (!this.isStopped) {
6211 var _a = this, source = _a.source, count = _a.count;
6213 return _super.prototype.complete.call(this);
6215 else if (count > -1) {
6216 this.count = count - 1;
6218 source.subscribe(this._unsubscribeAndRecycle());
6221 return RepeatSubscriber;
6224 function repeatWhen(notifier) {
6225 return function (source) { return source.lift(new RepeatWhenOperator(notifier)); };
6227 var RepeatWhenOperator = (function () {
6228 function RepeatWhenOperator(notifier) {
6229 this.notifier = notifier;
6231 RepeatWhenOperator.prototype.call = function (subscriber, source) {
6232 return source.subscribe(new RepeatWhenSubscriber(subscriber, this.notifier, source));
6234 return RepeatWhenOperator;
6236 var RepeatWhenSubscriber = (function (_super) {
6237 __extends(RepeatWhenSubscriber, _super);
6238 function RepeatWhenSubscriber(destination, notifier, source) {
6239 var _this = _super.call(this, destination) || this;
6240 _this.notifier = notifier;
6241 _this.source = source;
6242 _this.sourceIsBeingSubscribedTo = true;
6245 RepeatWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
6246 this.sourceIsBeingSubscribedTo = true;
6247 this.source.subscribe(this);
6249 RepeatWhenSubscriber.prototype.notifyComplete = function (innerSub) {
6250 if (this.sourceIsBeingSubscribedTo === false) {
6251 return _super.prototype.complete.call(this);
6254 RepeatWhenSubscriber.prototype.complete = function () {
6255 this.sourceIsBeingSubscribedTo = false;
6256 if (!this.isStopped) {
6257 if (!this.retries) {
6258 this.subscribeToRetries();
6260 if (!this.retriesSubscription || this.retriesSubscription.closed) {
6261 return _super.prototype.complete.call(this);
6263 this._unsubscribeAndRecycle();
6264 this.notifications.next();
6267 RepeatWhenSubscriber.prototype._unsubscribe = function () {
6268 var _a = this, notifications = _a.notifications, retriesSubscription = _a.retriesSubscription;
6269 if (notifications) {
6270 notifications.unsubscribe();
6271 this.notifications = null;
6273 if (retriesSubscription) {
6274 retriesSubscription.unsubscribe();
6275 this.retriesSubscription = null;
6277 this.retries = null;
6279 RepeatWhenSubscriber.prototype._unsubscribeAndRecycle = function () {
6280 var _unsubscribe = this._unsubscribe;
6281 this._unsubscribe = null;
6282 _super.prototype._unsubscribeAndRecycle.call(this);
6283 this._unsubscribe = _unsubscribe;
6286 RepeatWhenSubscriber.prototype.subscribeToRetries = function () {
6287 this.notifications = new Subject();
6290 var notifier = this.notifier;
6291 retries = notifier(this.notifications);
6294 return _super.prototype.complete.call(this);
6296 this.retries = retries;
6297 this.retriesSubscription = subscribeToResult(this, retries);
6299 return RepeatWhenSubscriber;
6300 }(OuterSubscriber));
6302 function retry(count) {
6303 if (count === void 0) { count = -1; }
6304 return function (source) { return source.lift(new RetryOperator(count, source)); };
6306 var RetryOperator = (function () {
6307 function RetryOperator(count, source) {
6309 this.source = source;
6311 RetryOperator.prototype.call = function (subscriber, source) {
6312 return source.subscribe(new RetrySubscriber(subscriber, this.count, this.source));
6314 return RetryOperator;
6316 var RetrySubscriber = (function (_super) {
6317 __extends(RetrySubscriber, _super);
6318 function RetrySubscriber(destination, count, source) {
6319 var _this = _super.call(this, destination) || this;
6320 _this.count = count;
6321 _this.source = source;
6324 RetrySubscriber.prototype.error = function (err) {
6325 if (!this.isStopped) {
6326 var _a = this, source = _a.source, count = _a.count;
6328 return _super.prototype.error.call(this, err);
6330 else if (count > -1) {
6331 this.count = count - 1;
6333 source.subscribe(this._unsubscribeAndRecycle());
6336 return RetrySubscriber;
6339 function retryWhen(notifier) {
6340 return function (source) { return source.lift(new RetryWhenOperator(notifier, source)); };
6342 var RetryWhenOperator = (function () {
6343 function RetryWhenOperator(notifier, source) {
6344 this.notifier = notifier;
6345 this.source = source;
6347 RetryWhenOperator.prototype.call = function (subscriber, source) {
6348 return source.subscribe(new RetryWhenSubscriber(subscriber, this.notifier, this.source));
6350 return RetryWhenOperator;
6352 var RetryWhenSubscriber = (function (_super) {
6353 __extends(RetryWhenSubscriber, _super);
6354 function RetryWhenSubscriber(destination, notifier, source) {
6355 var _this = _super.call(this, destination) || this;
6356 _this.notifier = notifier;
6357 _this.source = source;
6360 RetryWhenSubscriber.prototype.error = function (err) {
6361 if (!this.isStopped) {
6362 var errors = this.errors;
6363 var retries = this.retries;
6364 var retriesSubscription = this.retriesSubscription;
6366 errors = new Subject();
6368 var notifier = this.notifier;
6369 retries = notifier(errors);
6372 return _super.prototype.error.call(this, e);
6374 retriesSubscription = subscribeToResult(this, retries);
6378 this.retriesSubscription = null;
6380 this._unsubscribeAndRecycle();
6381 this.errors = errors;
6382 this.retries = retries;
6383 this.retriesSubscription = retriesSubscription;
6387 RetryWhenSubscriber.prototype._unsubscribe = function () {
6388 var _a = this, errors = _a.errors, retriesSubscription = _a.retriesSubscription;
6390 errors.unsubscribe();
6393 if (retriesSubscription) {
6394 retriesSubscription.unsubscribe();
6395 this.retriesSubscription = null;
6397 this.retries = null;
6399 RetryWhenSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
6400 var _unsubscribe = this._unsubscribe;
6401 this._unsubscribe = null;
6402 this._unsubscribeAndRecycle();
6403 this._unsubscribe = _unsubscribe;
6404 this.source.subscribe(this);
6406 return RetryWhenSubscriber;
6407 }(OuterSubscriber));
6409 function sample(notifier) {
6410 return function (source) { return source.lift(new SampleOperator(notifier)); };
6412 var SampleOperator = (function () {
6413 function SampleOperator(notifier) {
6414 this.notifier = notifier;
6416 SampleOperator.prototype.call = function (subscriber, source) {
6417 var sampleSubscriber = new SampleSubscriber(subscriber);
6418 var subscription = source.subscribe(sampleSubscriber);
6419 subscription.add(subscribeToResult(sampleSubscriber, this.notifier));
6420 return subscription;
6422 return SampleOperator;
6424 var SampleSubscriber = (function (_super) {
6425 __extends(SampleSubscriber, _super);
6426 function SampleSubscriber() {
6427 var _this = _super !== null && _super.apply(this, arguments) || this;
6428 _this.hasValue = false;
6431 SampleSubscriber.prototype._next = function (value) {
6433 this.hasValue = true;
6435 SampleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
6438 SampleSubscriber.prototype.notifyComplete = function () {
6441 SampleSubscriber.prototype.emitValue = function () {
6442 if (this.hasValue) {
6443 this.hasValue = false;
6444 this.destination.next(this.value);
6447 return SampleSubscriber;
6448 }(OuterSubscriber));
6450 function sampleTime(period, scheduler) {
6451 if (scheduler === void 0) { scheduler = async; }
6452 return function (source) { return source.lift(new SampleTimeOperator(period, scheduler)); };
6454 var SampleTimeOperator = (function () {
6455 function SampleTimeOperator(period, scheduler) {
6456 this.period = period;
6457 this.scheduler = scheduler;
6459 SampleTimeOperator.prototype.call = function (subscriber, source) {
6460 return source.subscribe(new SampleTimeSubscriber(subscriber, this.period, this.scheduler));
6462 return SampleTimeOperator;
6464 var SampleTimeSubscriber = (function (_super) {
6465 __extends(SampleTimeSubscriber, _super);
6466 function SampleTimeSubscriber(destination, period, scheduler) {
6467 var _this = _super.call(this, destination) || this;
6468 _this.period = period;
6469 _this.scheduler = scheduler;
6470 _this.hasValue = false;
6471 _this.add(scheduler.schedule(dispatchNotification, period, { subscriber: _this, period: period }));
6474 SampleTimeSubscriber.prototype._next = function (value) {
6475 this.lastValue = value;
6476 this.hasValue = true;
6478 SampleTimeSubscriber.prototype.notifyNext = function () {
6479 if (this.hasValue) {
6480 this.hasValue = false;
6481 this.destination.next(this.lastValue);
6484 return SampleTimeSubscriber;
6486 function dispatchNotification(state) {
6487 var subscriber = state.subscriber, period = state.period;
6488 subscriber.notifyNext();
6489 this.schedule(state, period);
6492 function sequenceEqual(compareTo, comparator) {
6493 return function (source) { return source.lift(new SequenceEqualOperator(compareTo, comparator)); };
6495 var SequenceEqualOperator = (function () {
6496 function SequenceEqualOperator(compareTo, comparator) {
6497 this.compareTo = compareTo;
6498 this.comparator = comparator;
6500 SequenceEqualOperator.prototype.call = function (subscriber, source) {
6501 return source.subscribe(new SequenceEqualSubscriber(subscriber, this.compareTo, this.comparator));
6503 return SequenceEqualOperator;
6505 var SequenceEqualSubscriber = (function (_super) {
6506 __extends(SequenceEqualSubscriber, _super);
6507 function SequenceEqualSubscriber(destination, compareTo, comparator) {
6508 var _this = _super.call(this, destination) || this;
6509 _this.compareTo = compareTo;
6510 _this.comparator = comparator;
6513 _this._oneComplete = false;
6514 _this.destination.add(compareTo.subscribe(new SequenceEqualCompareToSubscriber(destination, _this)));
6517 SequenceEqualSubscriber.prototype._next = function (value) {
6518 if (this._oneComplete && this._b.length === 0) {
6522 this._a.push(value);
6526 SequenceEqualSubscriber.prototype._complete = function () {
6527 if (this._oneComplete) {
6528 this.emit(this._a.length === 0 && this._b.length === 0);
6531 this._oneComplete = true;
6535 SequenceEqualSubscriber.prototype.checkValues = function () {
6536 var _c = this, _a = _c._a, _b = _c._b, comparator = _c.comparator;
6537 while (_a.length > 0 && _b.length > 0) {
6540 var areEqual = false;
6542 areEqual = comparator ? comparator(a, b) : a === b;
6545 this.destination.error(e);
6552 SequenceEqualSubscriber.prototype.emit = function (value) {
6553 var destination = this.destination;
6554 destination.next(value);
6555 destination.complete();
6557 SequenceEqualSubscriber.prototype.nextB = function (value) {
6558 if (this._oneComplete && this._a.length === 0) {
6562 this._b.push(value);
6566 SequenceEqualSubscriber.prototype.completeB = function () {
6567 if (this._oneComplete) {
6568 this.emit(this._a.length === 0 && this._b.length === 0);
6571 this._oneComplete = true;
6574 return SequenceEqualSubscriber;
6576 var SequenceEqualCompareToSubscriber = (function (_super) {
6577 __extends(SequenceEqualCompareToSubscriber, _super);
6578 function SequenceEqualCompareToSubscriber(destination, parent) {
6579 var _this = _super.call(this, destination) || this;
6580 _this.parent = parent;
6583 SequenceEqualCompareToSubscriber.prototype._next = function (value) {
6584 this.parent.nextB(value);
6586 SequenceEqualCompareToSubscriber.prototype._error = function (err) {
6587 this.parent.error(err);
6590 SequenceEqualCompareToSubscriber.prototype._complete = function () {
6591 this.parent.completeB();
6594 return SequenceEqualCompareToSubscriber;
6597 function shareSubjectFactory() {
6598 return new Subject();
6601 return function (source) { return refCount()(multicast(shareSubjectFactory)(source)); };
6604 function shareReplay(configOrBufferSize, windowTime, scheduler) {
6606 if (configOrBufferSize && typeof configOrBufferSize === 'object') {
6607 config = configOrBufferSize;
6611 bufferSize: configOrBufferSize,
6612 windowTime: windowTime,
6614 scheduler: scheduler
6617 return function (source) { return source.lift(shareReplayOperator(config)); };
6619 function shareReplayOperator(_a) {
6620 var _b = _a.bufferSize, bufferSize = _b === void 0 ? Number.POSITIVE_INFINITY : _b, _c = _a.windowTime, windowTime = _c === void 0 ? Number.POSITIVE_INFINITY : _c, useRefCount = _a.refCount, scheduler = _a.scheduler;
6624 var hasError = false;
6625 var isComplete = false;
6626 return function shareReplayOperation(source) {
6629 if (!subject || hasError) {
6631 subject = new ReplaySubject(bufferSize, windowTime, scheduler);
6632 innerSub = subject.subscribe(this);
6633 subscription = source.subscribe({
6634 next: function (value) { subject.next(value); },
6635 error: function (err) {
6639 complete: function () {
6641 subscription = undefined;
6647 innerSub = subject.subscribe(this);
6649 this.add(function () {
6651 innerSub.unsubscribe();
6652 if (subscription && !isComplete && useRefCount && refCount === 0) {
6653 subscription.unsubscribe();
6654 subscription = undefined;
6655 subject = undefined;
6661 function single(predicate) {
6662 return function (source) { return source.lift(new SingleOperator(predicate, source)); };
6664 var SingleOperator = (function () {
6665 function SingleOperator(predicate, source) {
6666 this.predicate = predicate;
6667 this.source = source;
6669 SingleOperator.prototype.call = function (subscriber, source) {
6670 return source.subscribe(new SingleSubscriber(subscriber, this.predicate, this.source));
6672 return SingleOperator;
6674 var SingleSubscriber = (function (_super) {
6675 __extends(SingleSubscriber, _super);
6676 function SingleSubscriber(destination, predicate, source) {
6677 var _this = _super.call(this, destination) || this;
6678 _this.predicate = predicate;
6679 _this.source = source;
6680 _this.seenValue = false;
6684 SingleSubscriber.prototype.applySingleValue = function (value) {
6685 if (this.seenValue) {
6686 this.destination.error('Sequence contains more than one element');
6689 this.seenValue = true;
6690 this.singleValue = value;
6693 SingleSubscriber.prototype._next = function (value) {
6694 var index = this.index++;
6695 if (this.predicate) {
6696 this.tryNext(value, index);
6699 this.applySingleValue(value);
6702 SingleSubscriber.prototype.tryNext = function (value, index) {
6704 if (this.predicate(value, index, this.source)) {
6705 this.applySingleValue(value);
6709 this.destination.error(err);
6712 SingleSubscriber.prototype._complete = function () {
6713 var destination = this.destination;
6714 if (this.index > 0) {
6715 destination.next(this.seenValue ? this.singleValue : undefined);
6716 destination.complete();
6719 destination.error(new EmptyError);
6722 return SingleSubscriber;
6725 function skip(count) {
6726 return function (source) { return source.lift(new SkipOperator(count)); };
6728 var SkipOperator = (function () {
6729 function SkipOperator(total) {
6732 SkipOperator.prototype.call = function (subscriber, source) {
6733 return source.subscribe(new SkipSubscriber(subscriber, this.total));
6735 return SkipOperator;
6737 var SkipSubscriber = (function (_super) {
6738 __extends(SkipSubscriber, _super);
6739 function SkipSubscriber(destination, total) {
6740 var _this = _super.call(this, destination) || this;
6741 _this.total = total;
6745 SkipSubscriber.prototype._next = function (x) {
6746 if (++this.count > this.total) {
6747 this.destination.next(x);
6750 return SkipSubscriber;
6753 function skipLast(count) {
6754 return function (source) { return source.lift(new SkipLastOperator(count)); };
6756 var SkipLastOperator = (function () {
6757 function SkipLastOperator(_skipCount) {
6758 this._skipCount = _skipCount;
6759 if (this._skipCount < 0) {
6760 throw new ArgumentOutOfRangeError;
6763 SkipLastOperator.prototype.call = function (subscriber, source) {
6764 if (this._skipCount === 0) {
6765 return source.subscribe(new Subscriber(subscriber));
6768 return source.subscribe(new SkipLastSubscriber(subscriber, this._skipCount));
6771 return SkipLastOperator;
6773 var SkipLastSubscriber = (function (_super) {
6774 __extends(SkipLastSubscriber, _super);
6775 function SkipLastSubscriber(destination, _skipCount) {
6776 var _this = _super.call(this, destination) || this;
6777 _this._skipCount = _skipCount;
6779 _this._ring = new Array(_skipCount);
6782 SkipLastSubscriber.prototype._next = function (value) {
6783 var skipCount = this._skipCount;
6784 var count = this._count++;
6785 if (count < skipCount) {
6786 this._ring[count] = value;
6789 var currentIndex = count % skipCount;
6790 var ring = this._ring;
6791 var oldValue = ring[currentIndex];
6792 ring[currentIndex] = value;
6793 this.destination.next(oldValue);
6796 return SkipLastSubscriber;
6799 function skipUntil(notifier) {
6800 return function (source) { return source.lift(new SkipUntilOperator(notifier)); };
6802 var SkipUntilOperator = (function () {
6803 function SkipUntilOperator(notifier) {
6804 this.notifier = notifier;
6806 SkipUntilOperator.prototype.call = function (destination, source) {
6807 return source.subscribe(new SkipUntilSubscriber(destination, this.notifier));
6809 return SkipUntilOperator;
6811 var SkipUntilSubscriber = (function (_super) {
6812 __extends(SkipUntilSubscriber, _super);
6813 function SkipUntilSubscriber(destination, notifier) {
6814 var _this = _super.call(this, destination) || this;
6815 _this.hasValue = false;
6816 var innerSubscriber = new InnerSubscriber(_this, undefined, undefined);
6817 _this.add(innerSubscriber);
6818 _this.innerSubscription = innerSubscriber;
6819 var innerSubscription = subscribeToResult(_this, notifier, undefined, undefined, innerSubscriber);
6820 if (innerSubscription !== innerSubscriber) {
6821 _this.add(innerSubscription);
6822 _this.innerSubscription = innerSubscription;
6826 SkipUntilSubscriber.prototype._next = function (value) {
6827 if (this.hasValue) {
6828 _super.prototype._next.call(this, value);
6831 SkipUntilSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
6832 this.hasValue = true;
6833 if (this.innerSubscription) {
6834 this.innerSubscription.unsubscribe();
6837 SkipUntilSubscriber.prototype.notifyComplete = function () {
6839 return SkipUntilSubscriber;
6840 }(OuterSubscriber));
6842 function skipWhile(predicate) {
6843 return function (source) { return source.lift(new SkipWhileOperator(predicate)); };
6845 var SkipWhileOperator = (function () {
6846 function SkipWhileOperator(predicate) {
6847 this.predicate = predicate;
6849 SkipWhileOperator.prototype.call = function (subscriber, source) {
6850 return source.subscribe(new SkipWhileSubscriber(subscriber, this.predicate));
6852 return SkipWhileOperator;
6854 var SkipWhileSubscriber = (function (_super) {
6855 __extends(SkipWhileSubscriber, _super);
6856 function SkipWhileSubscriber(destination, predicate) {
6857 var _this = _super.call(this, destination) || this;
6858 _this.predicate = predicate;
6859 _this.skipping = true;
6863 SkipWhileSubscriber.prototype._next = function (value) {
6864 var destination = this.destination;
6865 if (this.skipping) {
6866 this.tryCallPredicate(value);
6868 if (!this.skipping) {
6869 destination.next(value);
6872 SkipWhileSubscriber.prototype.tryCallPredicate = function (value) {
6874 var result = this.predicate(value, this.index++);
6875 this.skipping = Boolean(result);
6878 this.destination.error(err);
6881 return SkipWhileSubscriber;
6884 function startWith() {
6886 for (var _i = 0; _i < arguments.length; _i++) {
6887 array[_i] = arguments[_i];
6889 var scheduler = array[array.length - 1];
6890 if (isScheduler(scheduler)) {
6892 return function (source) { return concat(array, source, scheduler); };
6895 return function (source) { return concat(array, source); };
6899 var SubscribeOnObservable = (function (_super) {
6900 __extends(SubscribeOnObservable, _super);
6901 function SubscribeOnObservable(source, delayTime, scheduler) {
6902 if (delayTime === void 0) { delayTime = 0; }
6903 if (scheduler === void 0) { scheduler = asap; }
6904 var _this = _super.call(this) || this;
6905 _this.source = source;
6906 _this.delayTime = delayTime;
6907 _this.scheduler = scheduler;
6908 if (!isNumeric(delayTime) || delayTime < 0) {
6909 _this.delayTime = 0;
6911 if (!scheduler || typeof scheduler.schedule !== 'function') {
6912 _this.scheduler = asap;
6916 SubscribeOnObservable.create = function (source, delay, scheduler) {
6917 if (delay === void 0) { delay = 0; }
6918 if (scheduler === void 0) { scheduler = asap; }
6919 return new SubscribeOnObservable(source, delay, scheduler);
6921 SubscribeOnObservable.dispatch = function (arg) {
6922 var source = arg.source, subscriber = arg.subscriber;
6923 return this.add(source.subscribe(subscriber));
6925 SubscribeOnObservable.prototype._subscribe = function (subscriber) {
6926 var delay = this.delayTime;
6927 var source = this.source;
6928 var scheduler = this.scheduler;
6929 return scheduler.schedule(SubscribeOnObservable.dispatch, delay, {
6930 source: source, subscriber: subscriber
6933 return SubscribeOnObservable;
6936 function subscribeOn(scheduler, delay) {
6937 if (delay === void 0) { delay = 0; }
6938 return function subscribeOnOperatorFunction(source) {
6939 return source.lift(new SubscribeOnOperator(scheduler, delay));
6942 var SubscribeOnOperator = (function () {
6943 function SubscribeOnOperator(scheduler, delay) {
6944 this.scheduler = scheduler;
6947 SubscribeOnOperator.prototype.call = function (subscriber, source) {
6948 return new SubscribeOnObservable(source, this.delay, this.scheduler).subscribe(subscriber);
6950 return SubscribeOnOperator;
6953 function switchMap(project, resultSelector) {
6954 if (typeof resultSelector === 'function') {
6955 return function (source) { return source.pipe(switchMap(function (a, i) { return from(project(a, i)).pipe(map(function (b, ii) { return resultSelector(a, b, i, ii); })); })); };
6957 return function (source) { return source.lift(new SwitchMapOperator(project)); };
6959 var SwitchMapOperator = (function () {
6960 function SwitchMapOperator(project) {
6961 this.project = project;
6963 SwitchMapOperator.prototype.call = function (subscriber, source) {
6964 return source.subscribe(new SwitchMapSubscriber(subscriber, this.project));
6966 return SwitchMapOperator;
6968 var SwitchMapSubscriber = (function (_super) {
6969 __extends(SwitchMapSubscriber, _super);
6970 function SwitchMapSubscriber(destination, project) {
6971 var _this = _super.call(this, destination) || this;
6972 _this.project = project;
6976 SwitchMapSubscriber.prototype._next = function (value) {
6978 var index = this.index++;
6980 result = this.project(value, index);
6983 this.destination.error(error);
6986 this._innerSub(result, value, index);
6988 SwitchMapSubscriber.prototype._innerSub = function (result, value, index) {
6989 var innerSubscription = this.innerSubscription;
6990 if (innerSubscription) {
6991 innerSubscription.unsubscribe();
6993 var innerSubscriber = new InnerSubscriber(this, value, index);
6994 var destination = this.destination;
6995 destination.add(innerSubscriber);
6996 this.innerSubscription = subscribeToResult(this, result, undefined, undefined, innerSubscriber);
6997 if (this.innerSubscription !== innerSubscriber) {
6998 destination.add(this.innerSubscription);
7001 SwitchMapSubscriber.prototype._complete = function () {
7002 var innerSubscription = this.innerSubscription;
7003 if (!innerSubscription || innerSubscription.closed) {
7004 _super.prototype._complete.call(this);
7008 SwitchMapSubscriber.prototype._unsubscribe = function () {
7009 this.innerSubscription = null;
7011 SwitchMapSubscriber.prototype.notifyComplete = function (innerSub) {
7012 var destination = this.destination;
7013 destination.remove(innerSub);
7014 this.innerSubscription = null;
7015 if (this.isStopped) {
7016 _super.prototype._complete.call(this);
7019 SwitchMapSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
7020 this.destination.next(innerValue);
7022 return SwitchMapSubscriber;
7023 }(OuterSubscriber));
7025 function switchAll() {
7026 return switchMap(identity);
7029 function switchMapTo(innerObservable, resultSelector) {
7030 return resultSelector ? switchMap(function () { return innerObservable; }, resultSelector) : switchMap(function () { return innerObservable; });
7033 function takeUntil(notifier) {
7034 return function (source) { return source.lift(new TakeUntilOperator(notifier)); };
7036 var TakeUntilOperator = (function () {
7037 function TakeUntilOperator(notifier) {
7038 this.notifier = notifier;
7040 TakeUntilOperator.prototype.call = function (subscriber, source) {
7041 var takeUntilSubscriber = new TakeUntilSubscriber(subscriber);
7042 var notifierSubscription = subscribeToResult(takeUntilSubscriber, this.notifier);
7043 if (notifierSubscription && !takeUntilSubscriber.seenValue) {
7044 takeUntilSubscriber.add(notifierSubscription);
7045 return source.subscribe(takeUntilSubscriber);
7047 return takeUntilSubscriber;
7049 return TakeUntilOperator;
7051 var TakeUntilSubscriber = (function (_super) {
7052 __extends(TakeUntilSubscriber, _super);
7053 function TakeUntilSubscriber(destination) {
7054 var _this = _super.call(this, destination) || this;
7055 _this.seenValue = false;
7058 TakeUntilSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
7059 this.seenValue = true;
7062 TakeUntilSubscriber.prototype.notifyComplete = function () {
7064 return TakeUntilSubscriber;
7065 }(OuterSubscriber));
7067 function takeWhile(predicate, inclusive) {
7068 if (inclusive === void 0) { inclusive = false; }
7069 return function (source) {
7070 return source.lift(new TakeWhileOperator(predicate, inclusive));
7073 var TakeWhileOperator = (function () {
7074 function TakeWhileOperator(predicate, inclusive) {
7075 this.predicate = predicate;
7076 this.inclusive = inclusive;
7078 TakeWhileOperator.prototype.call = function (subscriber, source) {
7079 return source.subscribe(new TakeWhileSubscriber(subscriber, this.predicate, this.inclusive));
7081 return TakeWhileOperator;
7083 var TakeWhileSubscriber = (function (_super) {
7084 __extends(TakeWhileSubscriber, _super);
7085 function TakeWhileSubscriber(destination, predicate, inclusive) {
7086 var _this = _super.call(this, destination) || this;
7087 _this.predicate = predicate;
7088 _this.inclusive = inclusive;
7092 TakeWhileSubscriber.prototype._next = function (value) {
7093 var destination = this.destination;
7096 result = this.predicate(value, this.index++);
7099 destination.error(err);
7102 this.nextOrComplete(value, result);
7104 TakeWhileSubscriber.prototype.nextOrComplete = function (value, predicateResult) {
7105 var destination = this.destination;
7106 if (Boolean(predicateResult)) {
7107 destination.next(value);
7110 if (this.inclusive) {
7111 destination.next(value);
7113 destination.complete();
7116 return TakeWhileSubscriber;
7119 function tap(nextOrObserver, error, complete) {
7120 return function tapOperatorFunction(source) {
7121 return source.lift(new DoOperator(nextOrObserver, error, complete));
7124 var DoOperator = (function () {
7125 function DoOperator(nextOrObserver, error, complete) {
7126 this.nextOrObserver = nextOrObserver;
7128 this.complete = complete;
7130 DoOperator.prototype.call = function (subscriber, source) {
7131 return source.subscribe(new TapSubscriber(subscriber, this.nextOrObserver, this.error, this.complete));
7135 var TapSubscriber = (function (_super) {
7136 __extends(TapSubscriber, _super);
7137 function TapSubscriber(destination, observerOrNext, error, complete) {
7138 var _this = _super.call(this, destination) || this;
7139 _this._tapNext = noop;
7140 _this._tapError = noop;
7141 _this._tapComplete = noop;
7142 _this._tapError = error || noop;
7143 _this._tapComplete = complete || noop;
7144 if (isFunction(observerOrNext)) {
7145 _this._context = _this;
7146 _this._tapNext = observerOrNext;
7148 else if (observerOrNext) {
7149 _this._context = observerOrNext;
7150 _this._tapNext = observerOrNext.next || noop;
7151 _this._tapError = observerOrNext.error || noop;
7152 _this._tapComplete = observerOrNext.complete || noop;
7156 TapSubscriber.prototype._next = function (value) {
7158 this._tapNext.call(this._context, value);
7161 this.destination.error(err);
7164 this.destination.next(value);
7166 TapSubscriber.prototype._error = function (err) {
7168 this._tapError.call(this._context, err);
7171 this.destination.error(err);
7174 this.destination.error(err);
7176 TapSubscriber.prototype._complete = function () {
7178 this._tapComplete.call(this._context);
7181 this.destination.error(err);
7184 return this.destination.complete();
7186 return TapSubscriber;
7189 var defaultThrottleConfig = {
7193 function throttle(durationSelector, config) {
7194 if (config === void 0) { config = defaultThrottleConfig; }
7195 return function (source) { return source.lift(new ThrottleOperator(durationSelector, config.leading, config.trailing)); };
7197 var ThrottleOperator = (function () {
7198 function ThrottleOperator(durationSelector, leading, trailing) {
7199 this.durationSelector = durationSelector;
7200 this.leading = leading;
7201 this.trailing = trailing;
7203 ThrottleOperator.prototype.call = function (subscriber, source) {
7204 return source.subscribe(new ThrottleSubscriber(subscriber, this.durationSelector, this.leading, this.trailing));
7206 return ThrottleOperator;
7208 var ThrottleSubscriber = (function (_super) {
7209 __extends(ThrottleSubscriber, _super);
7210 function ThrottleSubscriber(destination, durationSelector, _leading, _trailing) {
7211 var _this = _super.call(this, destination) || this;
7212 _this.destination = destination;
7213 _this.durationSelector = durationSelector;
7214 _this._leading = _leading;
7215 _this._trailing = _trailing;
7216 _this._hasValue = false;
7219 ThrottleSubscriber.prototype._next = function (value) {
7220 this._hasValue = true;
7221 this._sendValue = value;
7222 if (!this._throttled) {
7223 if (this._leading) {
7227 this.throttle(value);
7231 ThrottleSubscriber.prototype.send = function () {
7232 var _a = this, _hasValue = _a._hasValue, _sendValue = _a._sendValue;
7234 this.destination.next(_sendValue);
7235 this.throttle(_sendValue);
7237 this._hasValue = false;
7238 this._sendValue = null;
7240 ThrottleSubscriber.prototype.throttle = function (value) {
7241 var duration = this.tryDurationSelector(value);
7243 this.add(this._throttled = subscribeToResult(this, duration));
7246 ThrottleSubscriber.prototype.tryDurationSelector = function (value) {
7248 return this.durationSelector(value);
7251 this.destination.error(err);
7255 ThrottleSubscriber.prototype.throttlingDone = function () {
7256 var _a = this, _throttled = _a._throttled, _trailing = _a._trailing;
7258 _throttled.unsubscribe();
7260 this._throttled = null;
7265 ThrottleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
7266 this.throttlingDone();
7268 ThrottleSubscriber.prototype.notifyComplete = function () {
7269 this.throttlingDone();
7271 return ThrottleSubscriber;
7272 }(OuterSubscriber));
7274 function throttleTime(duration, scheduler, config) {
7275 if (scheduler === void 0) { scheduler = async; }
7276 if (config === void 0) { config = defaultThrottleConfig; }
7277 return function (source) { return source.lift(new ThrottleTimeOperator(duration, scheduler, config.leading, config.trailing)); };
7279 var ThrottleTimeOperator = (function () {
7280 function ThrottleTimeOperator(duration, scheduler, leading, trailing) {
7281 this.duration = duration;
7282 this.scheduler = scheduler;
7283 this.leading = leading;
7284 this.trailing = trailing;
7286 ThrottleTimeOperator.prototype.call = function (subscriber, source) {
7287 return source.subscribe(new ThrottleTimeSubscriber(subscriber, this.duration, this.scheduler, this.leading, this.trailing));
7289 return ThrottleTimeOperator;
7291 var ThrottleTimeSubscriber = (function (_super) {
7292 __extends(ThrottleTimeSubscriber, _super);
7293 function ThrottleTimeSubscriber(destination, duration, scheduler, leading, trailing) {
7294 var _this = _super.call(this, destination) || this;
7295 _this.duration = duration;
7296 _this.scheduler = scheduler;
7297 _this.leading = leading;
7298 _this.trailing = trailing;
7299 _this._hasTrailingValue = false;
7300 _this._trailingValue = null;
7303 ThrottleTimeSubscriber.prototype._next = function (value) {
7304 if (this.throttled) {
7305 if (this.trailing) {
7306 this._trailingValue = value;
7307 this._hasTrailingValue = true;
7311 this.add(this.throttled = this.scheduler.schedule(dispatchNext$3, this.duration, { subscriber: this }));
7313 this.destination.next(value);
7315 else if (this.trailing) {
7316 this._trailingValue = value;
7317 this._hasTrailingValue = true;
7321 ThrottleTimeSubscriber.prototype._complete = function () {
7322 if (this._hasTrailingValue) {
7323 this.destination.next(this._trailingValue);
7324 this.destination.complete();
7327 this.destination.complete();
7330 ThrottleTimeSubscriber.prototype.clearThrottle = function () {
7331 var throttled = this.throttled;
7333 if (this.trailing && this._hasTrailingValue) {
7334 this.destination.next(this._trailingValue);
7335 this._trailingValue = null;
7336 this._hasTrailingValue = false;
7338 throttled.unsubscribe();
7339 this.remove(throttled);
7340 this.throttled = null;
7343 return ThrottleTimeSubscriber;
7345 function dispatchNext$3(arg) {
7346 var subscriber = arg.subscriber;
7347 subscriber.clearThrottle();
7350 function timeInterval(scheduler) {
7351 if (scheduler === void 0) { scheduler = async; }
7352 return function (source) { return defer(function () {
7353 return source.pipe(scan(function (_a, value) {
7354 var current = _a.current;
7355 return ({ value: value, current: scheduler.now(), last: current });
7356 }, { current: scheduler.now(), value: undefined, last: undefined }), map(function (_a) {
7357 var current = _a.current, last = _a.last, value = _a.value;
7358 return new TimeInterval(value, current - last);
7362 var TimeInterval = (function () {
7363 function TimeInterval(value, interval) {
7365 this.interval = interval;
7367 return TimeInterval;
7370 function timeoutWith(due, withObservable, scheduler) {
7371 if (scheduler === void 0) { scheduler = async; }
7372 return function (source) {
7373 var absoluteTimeout = isDate(due);
7374 var waitFor = absoluteTimeout ? (+due - scheduler.now()) : Math.abs(due);
7375 return source.lift(new TimeoutWithOperator(waitFor, absoluteTimeout, withObservable, scheduler));
7378 var TimeoutWithOperator = (function () {
7379 function TimeoutWithOperator(waitFor, absoluteTimeout, withObservable, scheduler) {
7380 this.waitFor = waitFor;
7381 this.absoluteTimeout = absoluteTimeout;
7382 this.withObservable = withObservable;
7383 this.scheduler = scheduler;
7385 TimeoutWithOperator.prototype.call = function (subscriber, source) {
7386 return source.subscribe(new TimeoutWithSubscriber(subscriber, this.absoluteTimeout, this.waitFor, this.withObservable, this.scheduler));
7388 return TimeoutWithOperator;
7390 var TimeoutWithSubscriber = (function (_super) {
7391 __extends(TimeoutWithSubscriber, _super);
7392 function TimeoutWithSubscriber(destination, absoluteTimeout, waitFor, withObservable, scheduler) {
7393 var _this = _super.call(this, destination) || this;
7394 _this.absoluteTimeout = absoluteTimeout;
7395 _this.waitFor = waitFor;
7396 _this.withObservable = withObservable;
7397 _this.scheduler = scheduler;
7398 _this.action = null;
7399 _this.scheduleTimeout();
7402 TimeoutWithSubscriber.dispatchTimeout = function (subscriber) {
7403 var withObservable = subscriber.withObservable;
7404 subscriber._unsubscribeAndRecycle();
7405 subscriber.add(subscribeToResult(subscriber, withObservable));
7407 TimeoutWithSubscriber.prototype.scheduleTimeout = function () {
7408 var action = this.action;
7410 this.action = action.schedule(this, this.waitFor);
7413 this.add(this.action = this.scheduler.schedule(TimeoutWithSubscriber.dispatchTimeout, this.waitFor, this));
7416 TimeoutWithSubscriber.prototype._next = function (value) {
7417 if (!this.absoluteTimeout) {
7418 this.scheduleTimeout();
7420 _super.prototype._next.call(this, value);
7422 TimeoutWithSubscriber.prototype._unsubscribe = function () {
7424 this.scheduler = null;
7425 this.withObservable = null;
7427 return TimeoutWithSubscriber;
7428 }(OuterSubscriber));
7430 function timeout(due, scheduler) {
7431 if (scheduler === void 0) { scheduler = async; }
7432 return timeoutWith(due, throwError(new TimeoutError()), scheduler);
7435 function timestamp(scheduler) {
7436 if (scheduler === void 0) { scheduler = async; }
7437 return map(function (value) { return new Timestamp(value, scheduler.now()); });
7439 var Timestamp = (function () {
7440 function Timestamp(value, timestamp) {
7442 this.timestamp = timestamp;
7447 function toArrayReducer(arr, item, index) {
7454 function toArray() {
7455 return reduce(toArrayReducer, []);
7458 function window$1(windowBoundaries) {
7459 return function windowOperatorFunction(source) {
7460 return source.lift(new WindowOperator(windowBoundaries));
7463 var WindowOperator = (function () {
7464 function WindowOperator(windowBoundaries) {
7465 this.windowBoundaries = windowBoundaries;
7467 WindowOperator.prototype.call = function (subscriber, source) {
7468 var windowSubscriber = new WindowSubscriber(subscriber);
7469 var sourceSubscription = source.subscribe(windowSubscriber);
7470 if (!sourceSubscription.closed) {
7471 windowSubscriber.add(subscribeToResult(windowSubscriber, this.windowBoundaries));
7473 return sourceSubscription;
7475 return WindowOperator;
7477 var WindowSubscriber = (function (_super) {
7478 __extends(WindowSubscriber, _super);
7479 function WindowSubscriber(destination) {
7480 var _this = _super.call(this, destination) || this;
7481 _this.window = new Subject();
7482 destination.next(_this.window);
7485 WindowSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
7488 WindowSubscriber.prototype.notifyError = function (error, innerSub) {
7491 WindowSubscriber.prototype.notifyComplete = function (innerSub) {
7494 WindowSubscriber.prototype._next = function (value) {
7495 this.window.next(value);
7497 WindowSubscriber.prototype._error = function (err) {
7498 this.window.error(err);
7499 this.destination.error(err);
7501 WindowSubscriber.prototype._complete = function () {
7502 this.window.complete();
7503 this.destination.complete();
7505 WindowSubscriber.prototype._unsubscribe = function () {
7508 WindowSubscriber.prototype.openWindow = function () {
7509 var prevWindow = this.window;
7511 prevWindow.complete();
7513 var destination = this.destination;
7514 var newWindow = this.window = new Subject();
7515 destination.next(newWindow);
7517 return WindowSubscriber;
7518 }(OuterSubscriber));
7520 function windowCount(windowSize, startWindowEvery) {
7521 if (startWindowEvery === void 0) { startWindowEvery = 0; }
7522 return function windowCountOperatorFunction(source) {
7523 return source.lift(new WindowCountOperator(windowSize, startWindowEvery));
7526 var WindowCountOperator = (function () {
7527 function WindowCountOperator(windowSize, startWindowEvery) {
7528 this.windowSize = windowSize;
7529 this.startWindowEvery = startWindowEvery;
7531 WindowCountOperator.prototype.call = function (subscriber, source) {
7532 return source.subscribe(new WindowCountSubscriber(subscriber, this.windowSize, this.startWindowEvery));
7534 return WindowCountOperator;
7536 var WindowCountSubscriber = (function (_super) {
7537 __extends(WindowCountSubscriber, _super);
7538 function WindowCountSubscriber(destination, windowSize, startWindowEvery) {
7539 var _this = _super.call(this, destination) || this;
7540 _this.destination = destination;
7541 _this.windowSize = windowSize;
7542 _this.startWindowEvery = startWindowEvery;
7543 _this.windows = [new Subject()];
7545 destination.next(_this.windows[0]);
7548 WindowCountSubscriber.prototype._next = function (value) {
7549 var startWindowEvery = (this.startWindowEvery > 0) ? this.startWindowEvery : this.windowSize;
7550 var destination = this.destination;
7551 var windowSize = this.windowSize;
7552 var windows = this.windows;
7553 var len = windows.length;
7554 for (var i = 0; i < len && !this.closed; i++) {
7555 windows[i].next(value);
7557 var c = this.count - windowSize + 1;
7558 if (c >= 0 && c % startWindowEvery === 0 && !this.closed) {
7559 windows.shift().complete();
7561 if (++this.count % startWindowEvery === 0 && !this.closed) {
7562 var window_1 = new Subject();
7563 windows.push(window_1);
7564 destination.next(window_1);
7567 WindowCountSubscriber.prototype._error = function (err) {
7568 var windows = this.windows;
7570 while (windows.length > 0 && !this.closed) {
7571 windows.shift().error(err);
7574 this.destination.error(err);
7576 WindowCountSubscriber.prototype._complete = function () {
7577 var windows = this.windows;
7579 while (windows.length > 0 && !this.closed) {
7580 windows.shift().complete();
7583 this.destination.complete();
7585 WindowCountSubscriber.prototype._unsubscribe = function () {
7587 this.windows = null;
7589 return WindowCountSubscriber;
7592 function windowTime(windowTimeSpan) {
7593 var scheduler = async;
7594 var windowCreationInterval = null;
7595 var maxWindowSize = Number.POSITIVE_INFINITY;
7596 if (isScheduler(arguments[3])) {
7597 scheduler = arguments[3];
7599 if (isScheduler(arguments[2])) {
7600 scheduler = arguments[2];
7602 else if (isNumeric(arguments[2])) {
7603 maxWindowSize = Number(arguments[2]);
7605 if (isScheduler(arguments[1])) {
7606 scheduler = arguments[1];
7608 else if (isNumeric(arguments[1])) {
7609 windowCreationInterval = Number(arguments[1]);
7611 return function windowTimeOperatorFunction(source) {
7612 return source.lift(new WindowTimeOperator(windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler));
7615 var WindowTimeOperator = (function () {
7616 function WindowTimeOperator(windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler) {
7617 this.windowTimeSpan = windowTimeSpan;
7618 this.windowCreationInterval = windowCreationInterval;
7619 this.maxWindowSize = maxWindowSize;
7620 this.scheduler = scheduler;
7622 WindowTimeOperator.prototype.call = function (subscriber, source) {
7623 return source.subscribe(new WindowTimeSubscriber(subscriber, this.windowTimeSpan, this.windowCreationInterval, this.maxWindowSize, this.scheduler));
7625 return WindowTimeOperator;
7627 var CountedSubject = (function (_super) {
7628 __extends(CountedSubject, _super);
7629 function CountedSubject() {
7630 var _this = _super !== null && _super.apply(this, arguments) || this;
7631 _this._numberOfNextedValues = 0;
7634 CountedSubject.prototype.next = function (value) {
7635 this._numberOfNextedValues++;
7636 _super.prototype.next.call(this, value);
7638 Object.defineProperty(CountedSubject.prototype, "numberOfNextedValues", {
7640 return this._numberOfNextedValues;
7645 return CountedSubject;
7647 var WindowTimeSubscriber = (function (_super) {
7648 __extends(WindowTimeSubscriber, _super);
7649 function WindowTimeSubscriber(destination, windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler) {
7650 var _this = _super.call(this, destination) || this;
7651 _this.destination = destination;
7652 _this.windowTimeSpan = windowTimeSpan;
7653 _this.windowCreationInterval = windowCreationInterval;
7654 _this.maxWindowSize = maxWindowSize;
7655 _this.scheduler = scheduler;
7657 var window = _this.openWindow();
7658 if (windowCreationInterval !== null && windowCreationInterval >= 0) {
7659 var closeState = { subscriber: _this, window: window, context: null };
7660 var creationState = { windowTimeSpan: windowTimeSpan, windowCreationInterval: windowCreationInterval, subscriber: _this, scheduler: scheduler };
7661 _this.add(scheduler.schedule(dispatchWindowClose, windowTimeSpan, closeState));
7662 _this.add(scheduler.schedule(dispatchWindowCreation, windowCreationInterval, creationState));
7665 var timeSpanOnlyState = { subscriber: _this, window: window, windowTimeSpan: windowTimeSpan };
7666 _this.add(scheduler.schedule(dispatchWindowTimeSpanOnly, windowTimeSpan, timeSpanOnlyState));
7670 WindowTimeSubscriber.prototype._next = function (value) {
7671 var windows = this.windows;
7672 var len = windows.length;
7673 for (var i = 0; i < len; i++) {
7674 var window_1 = windows[i];
7675 if (!window_1.closed) {
7676 window_1.next(value);
7677 if (window_1.numberOfNextedValues >= this.maxWindowSize) {
7678 this.closeWindow(window_1);
7683 WindowTimeSubscriber.prototype._error = function (err) {
7684 var windows = this.windows;
7685 while (windows.length > 0) {
7686 windows.shift().error(err);
7688 this.destination.error(err);
7690 WindowTimeSubscriber.prototype._complete = function () {
7691 var windows = this.windows;
7692 while (windows.length > 0) {
7693 var window_2 = windows.shift();
7694 if (!window_2.closed) {
7695 window_2.complete();
7698 this.destination.complete();
7700 WindowTimeSubscriber.prototype.openWindow = function () {
7701 var window = new CountedSubject();
7702 this.windows.push(window);
7703 var destination = this.destination;
7704 destination.next(window);
7707 WindowTimeSubscriber.prototype.closeWindow = function (window) {
7709 var windows = this.windows;
7710 windows.splice(windows.indexOf(window), 1);
7712 return WindowTimeSubscriber;
7714 function dispatchWindowTimeSpanOnly(state) {
7715 var subscriber = state.subscriber, windowTimeSpan = state.windowTimeSpan, window = state.window;
7717 subscriber.closeWindow(window);
7719 state.window = subscriber.openWindow();
7720 this.schedule(state, windowTimeSpan);
7722 function dispatchWindowCreation(state) {
7723 var windowTimeSpan = state.windowTimeSpan, subscriber = state.subscriber, scheduler = state.scheduler, windowCreationInterval = state.windowCreationInterval;
7724 var window = subscriber.openWindow();
7726 var context = { action: action, subscription: null };
7727 var timeSpanState = { subscriber: subscriber, window: window, context: context };
7728 context.subscription = scheduler.schedule(dispatchWindowClose, windowTimeSpan, timeSpanState);
7729 action.add(context.subscription);
7730 action.schedule(state, windowCreationInterval);
7732 function dispatchWindowClose(state) {
7733 var subscriber = state.subscriber, window = state.window, context = state.context;
7734 if (context && context.action && context.subscription) {
7735 context.action.remove(context.subscription);
7737 subscriber.closeWindow(window);
7740 function windowToggle(openings, closingSelector) {
7741 return function (source) { return source.lift(new WindowToggleOperator(openings, closingSelector)); };
7743 var WindowToggleOperator = (function () {
7744 function WindowToggleOperator(openings, closingSelector) {
7745 this.openings = openings;
7746 this.closingSelector = closingSelector;
7748 WindowToggleOperator.prototype.call = function (subscriber, source) {
7749 return source.subscribe(new WindowToggleSubscriber(subscriber, this.openings, this.closingSelector));
7751 return WindowToggleOperator;
7753 var WindowToggleSubscriber = (function (_super) {
7754 __extends(WindowToggleSubscriber, _super);
7755 function WindowToggleSubscriber(destination, openings, closingSelector) {
7756 var _this = _super.call(this, destination) || this;
7757 _this.openings = openings;
7758 _this.closingSelector = closingSelector;
7759 _this.contexts = [];
7760 _this.add(_this.openSubscription = subscribeToResult(_this, openings, openings));
7763 WindowToggleSubscriber.prototype._next = function (value) {
7764 var contexts = this.contexts;
7766 var len = contexts.length;
7767 for (var i = 0; i < len; i++) {
7768 contexts[i].window.next(value);
7772 WindowToggleSubscriber.prototype._error = function (err) {
7773 var contexts = this.contexts;
7774 this.contexts = null;
7776 var len = contexts.length;
7778 while (++index < len) {
7779 var context_1 = contexts[index];
7780 context_1.window.error(err);
7781 context_1.subscription.unsubscribe();
7784 _super.prototype._error.call(this, err);
7786 WindowToggleSubscriber.prototype._complete = function () {
7787 var contexts = this.contexts;
7788 this.contexts = null;
7790 var len = contexts.length;
7792 while (++index < len) {
7793 var context_2 = contexts[index];
7794 context_2.window.complete();
7795 context_2.subscription.unsubscribe();
7798 _super.prototype._complete.call(this);
7800 WindowToggleSubscriber.prototype._unsubscribe = function () {
7801 var contexts = this.contexts;
7802 this.contexts = null;
7804 var len = contexts.length;
7806 while (++index < len) {
7807 var context_3 = contexts[index];
7808 context_3.window.unsubscribe();
7809 context_3.subscription.unsubscribe();
7813 WindowToggleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
7814 if (outerValue === this.openings) {
7815 var closingNotifier = void 0;
7817 var closingSelector = this.closingSelector;
7818 closingNotifier = closingSelector(innerValue);
7821 return this.error(e);
7823 var window_1 = new Subject();
7824 var subscription = new Subscription();
7825 var context_4 = { window: window_1, subscription: subscription };
7826 this.contexts.push(context_4);
7827 var innerSubscription = subscribeToResult(this, closingNotifier, context_4);
7828 if (innerSubscription.closed) {
7829 this.closeWindow(this.contexts.length - 1);
7832 innerSubscription.context = context_4;
7833 subscription.add(innerSubscription);
7835 this.destination.next(window_1);
7838 this.closeWindow(this.contexts.indexOf(outerValue));
7841 WindowToggleSubscriber.prototype.notifyError = function (err) {
7844 WindowToggleSubscriber.prototype.notifyComplete = function (inner) {
7845 if (inner !== this.openSubscription) {
7846 this.closeWindow(this.contexts.indexOf(inner.context));
7849 WindowToggleSubscriber.prototype.closeWindow = function (index) {
7853 var contexts = this.contexts;
7854 var context = contexts[index];
7855 var window = context.window, subscription = context.subscription;
7856 contexts.splice(index, 1);
7858 subscription.unsubscribe();
7860 return WindowToggleSubscriber;
7861 }(OuterSubscriber));
7863 function windowWhen(closingSelector) {
7864 return function windowWhenOperatorFunction(source) {
7865 return source.lift(new WindowOperator$1(closingSelector));
7868 var WindowOperator$1 = (function () {
7869 function WindowOperator(closingSelector) {
7870 this.closingSelector = closingSelector;
7872 WindowOperator.prototype.call = function (subscriber, source) {
7873 return source.subscribe(new WindowSubscriber$1(subscriber, this.closingSelector));
7875 return WindowOperator;
7877 var WindowSubscriber$1 = (function (_super) {
7878 __extends(WindowSubscriber, _super);
7879 function WindowSubscriber(destination, closingSelector) {
7880 var _this = _super.call(this, destination) || this;
7881 _this.destination = destination;
7882 _this.closingSelector = closingSelector;
7886 WindowSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
7887 this.openWindow(innerSub);
7889 WindowSubscriber.prototype.notifyError = function (error, innerSub) {
7892 WindowSubscriber.prototype.notifyComplete = function (innerSub) {
7893 this.openWindow(innerSub);
7895 WindowSubscriber.prototype._next = function (value) {
7896 this.window.next(value);
7898 WindowSubscriber.prototype._error = function (err) {
7899 this.window.error(err);
7900 this.destination.error(err);
7901 this.unsubscribeClosingNotification();
7903 WindowSubscriber.prototype._complete = function () {
7904 this.window.complete();
7905 this.destination.complete();
7906 this.unsubscribeClosingNotification();
7908 WindowSubscriber.prototype.unsubscribeClosingNotification = function () {
7909 if (this.closingNotification) {
7910 this.closingNotification.unsubscribe();
7913 WindowSubscriber.prototype.openWindow = function (innerSub) {
7914 if (innerSub === void 0) { innerSub = null; }
7916 this.remove(innerSub);
7917 innerSub.unsubscribe();
7919 var prevWindow = this.window;
7921 prevWindow.complete();
7923 var window = this.window = new Subject();
7924 this.destination.next(window);
7925 var closingNotifier;
7927 var closingSelector = this.closingSelector;
7928 closingNotifier = closingSelector();
7931 this.destination.error(e);
7932 this.window.error(e);
7935 this.add(this.closingNotification = subscribeToResult(this, closingNotifier));
7937 return WindowSubscriber;
7938 }(OuterSubscriber));
7940 function withLatestFrom() {
7942 for (var _i = 0; _i < arguments.length; _i++) {
7943 args[_i] = arguments[_i];
7945 return function (source) {
7947 if (typeof args[args.length - 1] === 'function') {
7948 project = args.pop();
7950 var observables = args;
7951 return source.lift(new WithLatestFromOperator(observables, project));
7954 var WithLatestFromOperator = (function () {
7955 function WithLatestFromOperator(observables, project) {
7956 this.observables = observables;
7957 this.project = project;
7959 WithLatestFromOperator.prototype.call = function (subscriber, source) {
7960 return source.subscribe(new WithLatestFromSubscriber(subscriber, this.observables, this.project));
7962 return WithLatestFromOperator;
7964 var WithLatestFromSubscriber = (function (_super) {
7965 __extends(WithLatestFromSubscriber, _super);
7966 function WithLatestFromSubscriber(destination, observables, project) {
7967 var _this = _super.call(this, destination) || this;
7968 _this.observables = observables;
7969 _this.project = project;
7970 _this.toRespond = [];
7971 var len = observables.length;
7972 _this.values = new Array(len);
7973 for (var i = 0; i < len; i++) {
7974 _this.toRespond.push(i);
7976 for (var i = 0; i < len; i++) {
7977 var observable = observables[i];
7978 _this.add(subscribeToResult(_this, observable, observable, i));
7982 WithLatestFromSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
7983 this.values[outerIndex] = innerValue;
7984 var toRespond = this.toRespond;
7985 if (toRespond.length > 0) {
7986 var found = toRespond.indexOf(outerIndex);
7988 toRespond.splice(found, 1);
7992 WithLatestFromSubscriber.prototype.notifyComplete = function () {
7994 WithLatestFromSubscriber.prototype._next = function (value) {
7995 if (this.toRespond.length === 0) {
7996 var args = [value].concat(this.values);
7998 this._tryProject(args);
8001 this.destination.next(args);
8005 WithLatestFromSubscriber.prototype._tryProject = function (args) {
8008 result = this.project.apply(this, args);
8011 this.destination.error(err);
8014 this.destination.next(result);
8016 return WithLatestFromSubscriber;
8017 }(OuterSubscriber));
8020 var observables = [];
8021 for (var _i = 0; _i < arguments.length; _i++) {
8022 observables[_i] = arguments[_i];
8024 return function zipOperatorFunction(source) {
8025 return source.lift.call(zip.apply(void 0, [source].concat(observables)));
8029 function zipAll(project) {
8030 return function (source) { return source.lift(new ZipOperator(project)); };
8035 var _operators = /*#__PURE__*/Object.freeze({
8037 auditTime: auditTime,
8039 bufferCount: bufferCount,
8040 bufferTime: bufferTime,
8041 bufferToggle: bufferToggle,
8042 bufferWhen: bufferWhen,
8043 catchError: catchError,
8044 combineAll: combineAll,
8045 combineLatest: combineLatest$1,
8047 concatAll: concatAll,
8048 concatMap: concatMap,
8049 concatMapTo: concatMapTo,
8052 debounceTime: debounceTime,
8053 defaultIfEmpty: defaultIfEmpty,
8055 delayWhen: delayWhen,
8056 dematerialize: dematerialize,
8058 distinctUntilChanged: distinctUntilChanged,
8059 distinctUntilKeyChanged: distinctUntilKeyChanged,
8060 elementAt: elementAt,
8064 exhaustMap: exhaustMap,
8069 findIndex: findIndex,
8072 ignoreElements: ignoreElements,
8077 materialize: materialize,
8083 mergeMapTo: mergeMapTo,
8084 mergeScan: mergeScan,
8086 multicast: multicast,
8087 observeOn: observeOn,
8088 onErrorResumeNext: onErrorResumeNext$1,
8090 partition: partition$1,
8093 publishBehavior: publishBehavior,
8094 publishLast: publishLast,
8095 publishReplay: publishReplay,
8099 repeatWhen: repeatWhen,
8101 retryWhen: retryWhen,
8104 sampleTime: sampleTime,
8106 sequenceEqual: sequenceEqual,
8108 shareReplay: shareReplay,
8112 skipUntil: skipUntil,
8113 skipWhile: skipWhile,
8114 startWith: startWith,
8115 subscribeOn: subscribeOn,
8116 switchAll: switchAll,
8117 switchMap: switchMap,
8118 switchMapTo: switchMapTo,
8121 takeUntil: takeUntil,
8122 takeWhile: takeWhile,
8125 throttleTime: throttleTime,
8126 throwIfEmpty: throwIfEmpty,
8127 timeInterval: timeInterval,
8129 timeoutWith: timeoutWith,
8130 timestamp: timestamp,
8133 windowCount: windowCount,
8134 windowTime: windowTime,
8135 windowToggle: windowToggle,
8136 windowWhen: windowWhen,
8137 withLatestFrom: withLatestFrom,
8142 var SubscriptionLog = (function () {
8143 function SubscriptionLog(subscribedFrame, unsubscribedFrame) {
8144 if (unsubscribedFrame === void 0) { unsubscribedFrame = Number.POSITIVE_INFINITY; }
8145 this.subscribedFrame = subscribedFrame;
8146 this.unsubscribedFrame = unsubscribedFrame;
8148 return SubscriptionLog;
8151 var SubscriptionLoggable = (function () {
8152 function SubscriptionLoggable() {
8153 this.subscriptions = [];
8155 SubscriptionLoggable.prototype.logSubscribedFrame = function () {
8156 this.subscriptions.push(new SubscriptionLog(this.scheduler.now()));
8157 return this.subscriptions.length - 1;
8159 SubscriptionLoggable.prototype.logUnsubscribedFrame = function (index) {
8160 var subscriptionLogs = this.subscriptions;
8161 var oldSubscriptionLog = subscriptionLogs[index];
8162 subscriptionLogs[index] = new SubscriptionLog(oldSubscriptionLog.subscribedFrame, this.scheduler.now());
8164 return SubscriptionLoggable;
8167 function applyMixins(derivedCtor, baseCtors) {
8168 for (var i = 0, len = baseCtors.length; i < len; i++) {
8169 var baseCtor = baseCtors[i];
8170 var propertyKeys = Object.getOwnPropertyNames(baseCtor.prototype);
8171 for (var j = 0, len2 = propertyKeys.length; j < len2; j++) {
8172 var name_1 = propertyKeys[j];
8173 derivedCtor.prototype[name_1] = baseCtor.prototype[name_1];
8178 var ColdObservable = (function (_super) {
8179 __extends(ColdObservable, _super);
8180 function ColdObservable(messages, scheduler) {
8181 var _this = _super.call(this, function (subscriber) {
8182 var observable = this;
8183 var index = observable.logSubscribedFrame();
8184 var subscription = new Subscription();
8185 subscription.add(new Subscription(function () {
8186 observable.logUnsubscribedFrame(index);
8188 observable.scheduleMessages(subscriber);
8189 return subscription;
8191 _this.messages = messages;
8192 _this.subscriptions = [];
8193 _this.scheduler = scheduler;
8196 ColdObservable.prototype.scheduleMessages = function (subscriber) {
8197 var messagesLength = this.messages.length;
8198 for (var i = 0; i < messagesLength; i++) {
8199 var message = this.messages[i];
8200 subscriber.add(this.scheduler.schedule(function (_a) {
8201 var message = _a.message, subscriber = _a.subscriber;
8202 message.notification.observe(subscriber);
8203 }, message.frame, { message: message, subscriber: subscriber }));
8206 return ColdObservable;
8208 applyMixins(ColdObservable, [SubscriptionLoggable]);
8210 var HotObservable = (function (_super) {
8211 __extends(HotObservable, _super);
8212 function HotObservable(messages, scheduler) {
8213 var _this = _super.call(this) || this;
8214 _this.messages = messages;
8215 _this.subscriptions = [];
8216 _this.scheduler = scheduler;
8219 HotObservable.prototype._subscribe = function (subscriber) {
8221 var index = subject.logSubscribedFrame();
8222 var subscription = new Subscription();
8223 subscription.add(new Subscription(function () {
8224 subject.logUnsubscribedFrame(index);
8226 subscription.add(_super.prototype._subscribe.call(this, subscriber));
8227 return subscription;
8229 HotObservable.prototype.setup = function () {
8231 var messagesLength = subject.messages.length;
8232 for (var i = 0; i < messagesLength; i++) {
8234 var message = subject.messages[i];
8235 subject.scheduler.schedule(function () { message.notification.observe(subject); }, message.frame);
8239 return HotObservable;
8241 applyMixins(HotObservable, [SubscriptionLoggable]);
8243 var defaultMaxFrame = 750;
8244 var TestScheduler = (function (_super) {
8245 __extends(TestScheduler, _super);
8246 function TestScheduler(assertDeepEqual) {
8247 var _this = _super.call(this, VirtualAction, defaultMaxFrame) || this;
8248 _this.assertDeepEqual = assertDeepEqual;
8249 _this.hotObservables = [];
8250 _this.coldObservables = [];
8251 _this.flushTests = [];
8252 _this.runMode = false;
8255 TestScheduler.prototype.createTime = function (marbles) {
8256 var indexOf = marbles.indexOf('|');
8257 if (indexOf === -1) {
8258 throw new Error('marble diagram for time should have a completion marker "|"');
8260 return indexOf * TestScheduler.frameTimeFactor;
8262 TestScheduler.prototype.createColdObservable = function (marbles, values, error) {
8263 if (marbles.indexOf('^') !== -1) {
8264 throw new Error('cold observable cannot have subscription offset "^"');
8266 if (marbles.indexOf('!') !== -1) {
8267 throw new Error('cold observable cannot have unsubscription marker "!"');
8269 var messages = TestScheduler.parseMarbles(marbles, values, error, undefined, this.runMode);
8270 var cold = new ColdObservable(messages, this);
8271 this.coldObservables.push(cold);
8274 TestScheduler.prototype.createHotObservable = function (marbles, values, error) {
8275 if (marbles.indexOf('!') !== -1) {
8276 throw new Error('hot observable cannot have unsubscription marker "!"');
8278 var messages = TestScheduler.parseMarbles(marbles, values, error, undefined, this.runMode);
8279 var subject = new HotObservable(messages, this);
8280 this.hotObservables.push(subject);
8283 TestScheduler.prototype.materializeInnerObservable = function (observable, outerFrame) {
8286 observable.subscribe(function (value) {
8287 messages.push({ frame: _this.frame - outerFrame, notification: Notification.createNext(value) });
8289 messages.push({ frame: _this.frame - outerFrame, notification: Notification.createError(err) });
8291 messages.push({ frame: _this.frame - outerFrame, notification: Notification.createComplete() });
8295 TestScheduler.prototype.expectObservable = function (observable, subscriptionMarbles) {
8297 if (subscriptionMarbles === void 0) { subscriptionMarbles = null; }
8299 var flushTest = { actual: actual, ready: false };
8300 var subscriptionParsed = TestScheduler.parseMarblesAsSubscriptions(subscriptionMarbles, this.runMode);
8301 var subscriptionFrame = subscriptionParsed.subscribedFrame === Number.POSITIVE_INFINITY ?
8302 0 : subscriptionParsed.subscribedFrame;
8303 var unsubscriptionFrame = subscriptionParsed.unsubscribedFrame;
8305 this.schedule(function () {
8306 subscription = observable.subscribe(function (x) {
8308 if (x instanceof Observable) {
8309 value = _this.materializeInnerObservable(value, _this.frame);
8311 actual.push({ frame: _this.frame, notification: Notification.createNext(value) });
8313 actual.push({ frame: _this.frame, notification: Notification.createError(err) });
8315 actual.push({ frame: _this.frame, notification: Notification.createComplete() });
8317 }, subscriptionFrame);
8318 if (unsubscriptionFrame !== Number.POSITIVE_INFINITY) {
8319 this.schedule(function () { return subscription.unsubscribe(); }, unsubscriptionFrame);
8321 this.flushTests.push(flushTest);
8322 var runMode = this.runMode;
8324 toBe: function (marbles, values, errorValue) {
8325 flushTest.ready = true;
8326 flushTest.expected = TestScheduler.parseMarbles(marbles, values, errorValue, true, runMode);
8330 TestScheduler.prototype.expectSubscriptions = function (actualSubscriptionLogs) {
8331 var flushTest = { actual: actualSubscriptionLogs, ready: false };
8332 this.flushTests.push(flushTest);
8333 var runMode = this.runMode;
8335 toBe: function (marbles) {
8336 var marblesArray = (typeof marbles === 'string') ? [marbles] : marbles;
8337 flushTest.ready = true;
8338 flushTest.expected = marblesArray.map(function (marbles) {
8339 return TestScheduler.parseMarblesAsSubscriptions(marbles, runMode);
8344 TestScheduler.prototype.flush = function () {
8346 var hotObservables = this.hotObservables;
8347 while (hotObservables.length > 0) {
8348 hotObservables.shift().setup();
8350 _super.prototype.flush.call(this);
8351 this.flushTests = this.flushTests.filter(function (test) {
8353 _this.assertDeepEqual(test.actual, test.expected);
8359 TestScheduler.parseMarblesAsSubscriptions = function (marbles, runMode) {
8361 if (runMode === void 0) { runMode = false; }
8362 if (typeof marbles !== 'string') {
8363 return new SubscriptionLog(Number.POSITIVE_INFINITY);
8365 var len = marbles.length;
8366 var groupStart = -1;
8367 var subscriptionFrame = Number.POSITIVE_INFINITY;
8368 var unsubscriptionFrame = Number.POSITIVE_INFINITY;
8370 var _loop_1 = function (i) {
8371 var nextFrame = frame;
8372 var advanceFrameBy = function (count) {
8373 nextFrame += count * _this.frameTimeFactor;
8394 if (subscriptionFrame !== Number.POSITIVE_INFINITY) {
8395 throw new Error('found a second subscription point \'^\' in a ' +
8396 'subscription marble diagram. There can only be one.');
8398 subscriptionFrame = groupStart > -1 ? groupStart : frame;
8402 if (unsubscriptionFrame !== Number.POSITIVE_INFINITY) {
8403 throw new Error('found a second subscription point \'^\' in a ' +
8404 'subscription marble diagram. There can only be one.');
8406 unsubscriptionFrame = groupStart > -1 ? groupStart : frame;
8409 if (runMode && c.match(/^[0-9]$/)) {
8410 if (i === 0 || marbles[i - 1] === ' ') {
8411 var buffer = marbles.slice(i);
8412 var match = buffer.match(/^([0-9]+(?:\.[0-9]+)?)(ms|s|m) /);
8414 i += match[0].length - 1;
8415 var duration = parseFloat(match[1]);
8416 var unit = match[2];
8417 var durationInMs = void 0;
8420 durationInMs = duration;
8423 durationInMs = duration * 1000;
8426 durationInMs = duration * 1000 * 60;
8431 advanceFrameBy(durationInMs / this_1.frameTimeFactor);
8436 throw new Error('there can only be \'^\' and \'!\' markers in a ' +
8437 'subscription marble diagram. Found instead \'' + c + '\'.');
8442 var this_1 = this, out_i_1;
8443 for (var i = 0; i < len; i++) {
8447 if (unsubscriptionFrame < 0) {
8448 return new SubscriptionLog(subscriptionFrame);
8451 return new SubscriptionLog(subscriptionFrame, unsubscriptionFrame);
8454 TestScheduler.parseMarbles = function (marbles, values, errorValue, materializeInnerObservables, runMode) {
8456 if (materializeInnerObservables === void 0) { materializeInnerObservables = false; }
8457 if (runMode === void 0) { runMode = false; }
8458 if (marbles.indexOf('!') !== -1) {
8459 throw new Error('conventional marble diagrams cannot have the ' +
8460 'unsubscription marker "!"');
8462 var len = marbles.length;
8463 var testMessages = [];
8464 var subIndex = runMode ? marbles.replace(/^[ ]+/, '').indexOf('^') : marbles.indexOf('^');
8465 var frame = subIndex === -1 ? 0 : (subIndex * -this.frameTimeFactor);
8466 var getValue = typeof values !== 'object' ?
8467 function (x) { return x; } :
8469 if (materializeInnerObservables && values[x] instanceof ColdObservable) {
8470 return values[x].messages;
8474 var groupStart = -1;
8475 var _loop_2 = function (i) {
8476 var nextFrame = frame;
8477 var advanceFrameBy = function (count) {
8478 nextFrame += count * _this.frameTimeFactor;
8480 var notification = void 0;
8500 notification = Notification.createComplete();
8507 notification = Notification.createError(errorValue || 'error');
8511 if (runMode && c.match(/^[0-9]$/)) {
8512 if (i === 0 || marbles[i - 1] === ' ') {
8513 var buffer = marbles.slice(i);
8514 var match = buffer.match(/^([0-9]+(?:\.[0-9]+)?)(ms|s|m) /);
8516 i += match[0].length - 1;
8517 var duration = parseFloat(match[1]);
8518 var unit = match[2];
8519 var durationInMs = void 0;
8522 durationInMs = duration;
8525 durationInMs = duration * 1000;
8528 durationInMs = duration * 1000 * 60;
8533 advanceFrameBy(durationInMs / this_2.frameTimeFactor);
8538 notification = Notification.createNext(getValue(c));
8543 testMessages.push({ frame: groupStart > -1 ? groupStart : frame, notification: notification });
8548 var this_2 = this, out_i_2;
8549 for (var i = 0; i < len; i++) {
8553 return testMessages;
8555 TestScheduler.prototype.run = function (callback) {
8556 var prevFrameTimeFactor = TestScheduler.frameTimeFactor;
8557 var prevMaxFrames = this.maxFrames;
8558 TestScheduler.frameTimeFactor = 1;
8559 this.maxFrames = Number.POSITIVE_INFINITY;
8560 this.runMode = true;
8561 AsyncScheduler.delegate = this;
8563 cold: this.createColdObservable.bind(this),
8564 hot: this.createHotObservable.bind(this),
8565 flush: this.flush.bind(this),
8566 expectObservable: this.expectObservable.bind(this),
8567 expectSubscriptions: this.expectSubscriptions.bind(this),
8570 var ret = callback(helpers);
8575 TestScheduler.frameTimeFactor = prevFrameTimeFactor;
8576 this.maxFrames = prevMaxFrames;
8577 this.runMode = false;
8578 AsyncScheduler.delegate = undefined;
8581 return TestScheduler;
8582 }(VirtualTimeScheduler));
8586 var _testing = /*#__PURE__*/Object.freeze({
8587 TestScheduler: TestScheduler
8590 var __window = typeof window !== 'undefined' && window;
8591 var __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' &&
8592 self instanceof WorkerGlobalScope && self;
8593 var __global = typeof global !== 'undefined' && global;
8594 var _root = __window || __global || __self;
8597 throw new Error('RxJS could not find any global context (window, self, global)');
8601 function getCORSRequest() {
8602 if (_root.XMLHttpRequest) {
8603 return new _root.XMLHttpRequest();
8605 else if (!!_root.XDomainRequest) {
8606 return new _root.XDomainRequest();
8609 throw new Error('CORS is not supported by your browser');
8612 function getXMLHttpRequest() {
8613 if (_root.XMLHttpRequest) {
8614 return new _root.XMLHttpRequest();
8617 var progId = void 0;
8619 var progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];
8620 for (var i = 0; i < 3; i++) {
8622 progId = progIds[i];
8623 if (new _root.ActiveXObject(progId)) {
8630 return new _root.ActiveXObject(progId);
8633 throw new Error('XMLHttpRequest is not supported by your browser');
8637 function ajaxGet(url, headers) {
8638 if (headers === void 0) { headers = null; }
8639 return new AjaxObservable({ method: 'GET', url: url, headers: headers });
8641 function ajaxPost(url, body, headers) {
8642 return new AjaxObservable({ method: 'POST', url: url, body: body, headers: headers });
8644 function ajaxDelete(url, headers) {
8645 return new AjaxObservable({ method: 'DELETE', url: url, headers: headers });
8647 function ajaxPut(url, body, headers) {
8648 return new AjaxObservable({ method: 'PUT', url: url, body: body, headers: headers });
8650 function ajaxPatch(url, body, headers) {
8651 return new AjaxObservable({ method: 'PATCH', url: url, body: body, headers: headers });
8653 var mapResponse = map(function (x, index) { return x.response; });
8654 function ajaxGetJSON(url, headers) {
8655 return mapResponse(new AjaxObservable({
8658 responseType: 'json',
8662 var AjaxObservable = (function (_super) {
8663 __extends(AjaxObservable, _super);
8664 function AjaxObservable(urlOrRequest) {
8665 var _this = _super.call(this) || this;
8668 createXHR: function () {
8669 return this.crossDomain ? getCORSRequest() : getXMLHttpRequest();
8672 withCredentials: false,
8675 responseType: 'json',
8678 if (typeof urlOrRequest === 'string') {
8679 request.url = urlOrRequest;
8682 for (var prop in urlOrRequest) {
8683 if (urlOrRequest.hasOwnProperty(prop)) {
8684 request[prop] = urlOrRequest[prop];
8688 _this.request = request;
8691 AjaxObservable.prototype._subscribe = function (subscriber) {
8692 return new AjaxSubscriber(subscriber, this.request);
8694 AjaxObservable.create = (function () {
8695 var create = function (urlOrRequest) {
8696 return new AjaxObservable(urlOrRequest);
8698 create.get = ajaxGet;
8699 create.post = ajaxPost;
8700 create.delete = ajaxDelete;
8701 create.put = ajaxPut;
8702 create.patch = ajaxPatch;
8703 create.getJSON = ajaxGetJSON;
8706 return AjaxObservable;
8708 var AjaxSubscriber = (function (_super) {
8709 __extends(AjaxSubscriber, _super);
8710 function AjaxSubscriber(destination, request) {
8711 var _this = _super.call(this, destination) || this;
8712 _this.request = request;
8714 var headers = request.headers = request.headers || {};
8715 if (!request.crossDomain && !_this.getHeader(headers, 'X-Requested-With')) {
8716 headers['X-Requested-With'] = 'XMLHttpRequest';
8718 var contentTypeHeader = _this.getHeader(headers, 'Content-Type');
8719 if (!contentTypeHeader && !(_root.FormData && request.body instanceof _root.FormData) && typeof request.body !== 'undefined') {
8720 headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
8722 request.body = _this.serializeBody(request.body, _this.getHeader(request.headers, 'Content-Type'));
8726 AjaxSubscriber.prototype.next = function (e) {
8728 var _a = this, xhr = _a.xhr, request = _a.request, destination = _a.destination;
8731 result = new AjaxResponse(e, xhr, request);
8734 return destination.error(err);
8736 destination.next(result);
8738 AjaxSubscriber.prototype.send = function () {
8739 var _a = this, request = _a.request, _b = _a.request, user = _b.user, method = _b.method, url = _b.url, async = _b.async, password = _b.password, headers = _b.headers, body = _b.body;
8741 var xhr = this.xhr = request.createXHR();
8742 this.setupEvents(xhr, request);
8744 xhr.open(method, url, async, user, password);
8747 xhr.open(method, url, async);
8750 xhr.timeout = request.timeout;
8751 xhr.responseType = request.responseType;
8753 if ('withCredentials' in xhr) {
8754 xhr.withCredentials = !!request.withCredentials;
8756 this.setHeaders(xhr, headers);
8768 AjaxSubscriber.prototype.serializeBody = function (body, contentType) {
8769 if (!body || typeof body === 'string') {
8772 else if (_root.FormData && body instanceof _root.FormData) {
8776 var splitIndex = contentType.indexOf(';');
8777 if (splitIndex !== -1) {
8778 contentType = contentType.substring(0, splitIndex);
8781 switch (contentType) {
8782 case 'application/x-www-form-urlencoded':
8783 return Object.keys(body).map(function (key) { return encodeURIComponent(key) + "=" + encodeURIComponent(body[key]); }).join('&');
8784 case 'application/json':
8785 return JSON.stringify(body);
8790 AjaxSubscriber.prototype.setHeaders = function (xhr, headers) {
8791 for (var key in headers) {
8792 if (headers.hasOwnProperty(key)) {
8793 xhr.setRequestHeader(key, headers[key]);
8797 AjaxSubscriber.prototype.getHeader = function (headers, headerName) {
8798 for (var key in headers) {
8799 if (key.toLowerCase() === headerName.toLowerCase()) {
8800 return headers[key];
8805 AjaxSubscriber.prototype.setupEvents = function (xhr, request) {
8806 var progressSubscriber = request.progressSubscriber;
8807 function xhrTimeout(e) {
8808 var _a = xhrTimeout, subscriber = _a.subscriber, progressSubscriber = _a.progressSubscriber, request = _a.request;
8809 if (progressSubscriber) {
8810 progressSubscriber.error(e);
8814 error = new AjaxTimeoutError(this, request);
8819 subscriber.error(error);
8821 xhr.ontimeout = xhrTimeout;
8822 xhrTimeout.request = request;
8823 xhrTimeout.subscriber = this;
8824 xhrTimeout.progressSubscriber = progressSubscriber;
8825 if (xhr.upload && 'withCredentials' in xhr) {
8826 if (progressSubscriber) {
8828 xhrProgress_1 = function (e) {
8829 var progressSubscriber = xhrProgress_1.progressSubscriber;
8830 progressSubscriber.next(e);
8832 if (_root.XDomainRequest) {
8833 xhr.onprogress = xhrProgress_1;
8836 xhr.upload.onprogress = xhrProgress_1;
8838 xhrProgress_1.progressSubscriber = progressSubscriber;
8841 xhrError_1 = function (e) {
8842 var _a = xhrError_1, progressSubscriber = _a.progressSubscriber, subscriber = _a.subscriber, request = _a.request;
8843 if (progressSubscriber) {
8844 progressSubscriber.error(e);
8848 error = new AjaxError('ajax error', this, request);
8853 subscriber.error(error);
8855 xhr.onerror = xhrError_1;
8856 xhrError_1.request = request;
8857 xhrError_1.subscriber = this;
8858 xhrError_1.progressSubscriber = progressSubscriber;
8860 function xhrReadyStateChange(e) {
8863 xhr.onreadystatechange = xhrReadyStateChange;
8864 xhrReadyStateChange.subscriber = this;
8865 xhrReadyStateChange.progressSubscriber = progressSubscriber;
8866 xhrReadyStateChange.request = request;
8867 function xhrLoad(e) {
8868 var _a = xhrLoad, subscriber = _a.subscriber, progressSubscriber = _a.progressSubscriber, request = _a.request;
8869 if (this.readyState === 4) {
8870 var status_1 = this.status === 1223 ? 204 : this.status;
8871 var response = (this.responseType === 'text' ? (this.response || this.responseText) : this.response);
8872 if (status_1 === 0) {
8873 status_1 = response ? 200 : 0;
8875 if (status_1 < 400) {
8876 if (progressSubscriber) {
8877 progressSubscriber.complete();
8880 subscriber.complete();
8883 if (progressSubscriber) {
8884 progressSubscriber.error(e);
8888 error = new AjaxError('ajax error ' + status_1, this, request);
8893 subscriber.error(error);
8897 xhr.onload = xhrLoad;
8898 xhrLoad.subscriber = this;
8899 xhrLoad.progressSubscriber = progressSubscriber;
8900 xhrLoad.request = request;
8902 AjaxSubscriber.prototype.unsubscribe = function () {
8903 var _a = this, done = _a.done, xhr = _a.xhr;
8904 if (!done && xhr && xhr.readyState !== 4 && typeof xhr.abort === 'function') {
8907 _super.prototype.unsubscribe.call(this);
8909 return AjaxSubscriber;
8911 var AjaxResponse = (function () {
8912 function AjaxResponse(originalEvent, xhr, request) {
8913 this.originalEvent = originalEvent;
8915 this.request = request;
8916 this.status = xhr.status;
8917 this.responseType = xhr.responseType || request.responseType;
8918 this.response = parseXhrResponse(this.responseType, xhr);
8920 return AjaxResponse;
8922 var AjaxErrorImpl = (function () {
8923 function AjaxErrorImpl(message, xhr, request) {
8925 this.message = message;
8926 this.name = 'AjaxError';
8928 this.request = request;
8929 this.status = xhr.status;
8930 this.responseType = xhr.responseType || request.responseType;
8931 this.response = parseXhrResponse(this.responseType, xhr);
8934 AjaxErrorImpl.prototype = Object.create(Error.prototype);
8935 return AjaxErrorImpl;
8937 var AjaxError = AjaxErrorImpl;
8938 function parseJson(xhr) {
8939 if ('response' in xhr) {
8940 return xhr.responseType ? xhr.response : JSON.parse(xhr.response || xhr.responseText || 'null');
8943 return JSON.parse(xhr.responseText || 'null');
8946 function parseXhrResponse(responseType, xhr) {
8947 switch (responseType) {
8949 return parseJson(xhr);
8951 return xhr.responseXML;
8954 return ('response' in xhr) ? xhr.response : xhr.responseText;
8957 function AjaxTimeoutErrorImpl(xhr, request) {
8958 AjaxError.call(this, 'ajax timeout', xhr, request);
8959 this.name = 'AjaxTimeoutError';
8962 var AjaxTimeoutError = AjaxTimeoutErrorImpl;
8964 var ajax = (function () { return AjaxObservable.create; })();
8968 var _ajax = /*#__PURE__*/Object.freeze({
8970 AjaxResponse: AjaxResponse,
8971 AjaxError: AjaxError,
8972 AjaxTimeoutError: AjaxTimeoutError
8975 var DEFAULT_WEBSOCKET_CONFIG = {
8977 deserializer: function (e) { return JSON.parse(e.data); },
8978 serializer: function (value) { return JSON.stringify(value); },
8980 var WEBSOCKETSUBJECT_INVALID_ERROR_OBJECT = 'WebSocketSubject.error must be called with an object with an error code, and an optional reason: { code: number, reason: string }';
8981 var WebSocketSubject = (function (_super) {
8982 __extends(WebSocketSubject, _super);
8983 function WebSocketSubject(urlConfigOrSource, destination) {
8984 var _this = _super.call(this) || this;
8985 if (urlConfigOrSource instanceof Observable) {
8986 _this.destination = destination;
8987 _this.source = urlConfigOrSource;
8990 var config = _this._config = __assign({}, DEFAULT_WEBSOCKET_CONFIG);
8991 _this._output = new Subject();
8992 if (typeof urlConfigOrSource === 'string') {
8993 config.url = urlConfigOrSource;
8996 for (var key in urlConfigOrSource) {
8997 if (urlConfigOrSource.hasOwnProperty(key)) {
8998 config[key] = urlConfigOrSource[key];
9002 if (!config.WebSocketCtor && WebSocket) {
9003 config.WebSocketCtor = WebSocket;
9005 else if (!config.WebSocketCtor) {
9006 throw new Error('no WebSocket constructor can be found');
9008 _this.destination = new ReplaySubject();
9012 WebSocketSubject.prototype.lift = function (operator) {
9013 var sock = new WebSocketSubject(this._config, this.destination);
9014 sock.operator = operator;
9018 WebSocketSubject.prototype._resetState = function () {
9019 this._socket = null;
9021 this.destination = new ReplaySubject();
9023 this._output = new Subject();
9025 WebSocketSubject.prototype.multiplex = function (subMsg, unsubMsg, messageFilter) {
9027 return new Observable(function (observer) {
9029 self.next(subMsg());
9032 observer.error(err);
9034 var subscription = self.subscribe(function (x) {
9036 if (messageFilter(x)) {
9041 observer.error(err);
9043 }, function (err) { return observer.error(err); }, function () { return observer.complete(); });
9044 return function () {
9046 self.next(unsubMsg());
9049 observer.error(err);
9051 subscription.unsubscribe();
9055 WebSocketSubject.prototype._connectSocket = function () {
9057 var _a = this._config, WebSocketCtor = _a.WebSocketCtor, protocol = _a.protocol, url = _a.url, binaryType = _a.binaryType;
9058 var observer = this._output;
9062 new WebSocketCtor(url, protocol) :
9063 new WebSocketCtor(url);
9064 this._socket = socket;
9066 this._socket.binaryType = binaryType;
9073 var subscription = new Subscription(function () {
9074 _this._socket = null;
9075 if (socket && socket.readyState === 1) {
9079 socket.onopen = function (e) {
9080 var _socket = _this._socket;
9083 _this._resetState();
9086 var openObserver = _this._config.openObserver;
9088 openObserver.next(e);
9090 var queue = _this.destination;
9091 _this.destination = Subscriber.create(function (x) {
9092 if (socket.readyState === 1) {
9094 var serializer = _this._config.serializer;
9095 socket.send(serializer(x));
9098 _this.destination.error(e);
9102 var closingObserver = _this._config.closingObserver;
9103 if (closingObserver) {
9104 closingObserver.next(undefined);
9107 socket.close(e.code, e.reason);
9110 observer.error(new TypeError(WEBSOCKETSUBJECT_INVALID_ERROR_OBJECT));
9112 _this._resetState();
9114 var closingObserver = _this._config.closingObserver;
9115 if (closingObserver) {
9116 closingObserver.next(undefined);
9119 _this._resetState();
9121 if (queue && queue instanceof ReplaySubject) {
9122 subscription.add(queue.subscribe(_this.destination));
9125 socket.onerror = function (e) {
9126 _this._resetState();
9129 socket.onclose = function (e) {
9130 _this._resetState();
9131 var closeObserver = _this._config.closeObserver;
9132 if (closeObserver) {
9133 closeObserver.next(e);
9136 observer.complete();
9142 socket.onmessage = function (e) {
9144 var deserializer = _this._config.deserializer;
9145 observer.next(deserializer(e));
9148 observer.error(err);
9152 WebSocketSubject.prototype._subscribe = function (subscriber) {
9154 var source = this.source;
9156 return source.subscribe(subscriber);
9158 if (!this._socket) {
9159 this._connectSocket();
9161 this._output.subscribe(subscriber);
9162 subscriber.add(function () {
9163 var _socket = _this._socket;
9164 if (_this._output.observers.length === 0) {
9165 if (_socket && _socket.readyState === 1) {
9168 _this._resetState();
9173 WebSocketSubject.prototype.unsubscribe = function () {
9174 var _socket = this._socket;
9175 if (_socket && _socket.readyState === 1) {
9179 _super.prototype.unsubscribe.call(this);
9181 return WebSocketSubject;
9182 }(AnonymousSubject));
9184 function webSocket(urlConfigOrSource) {
9185 return new WebSocketSubject(urlConfigOrSource);
9190 var _webSocket = /*#__PURE__*/Object.freeze({
9191 webSocket: webSocket,
9192 WebSocketSubject: WebSocketSubject
9195 function fromFetch(input, initWithSelector) {
9196 if (initWithSelector === void 0) { initWithSelector = {}; }
9197 var selector = initWithSelector.selector, init = __rest(initWithSelector, ["selector"]);
9198 return new Observable(function (subscriber) {
9199 var controller = new AbortController();
9200 var signal = controller.signal;
9201 var abortable = true;
9202 var unsubscribed = false;
9203 var subscription = new Subscription();
9204 subscription.add(function () {
9205 unsubscribed = true;
9210 var perSubscriberInit;
9213 if (init.signal.aborted) {
9217 var outerSignal_1 = init.signal;
9218 var outerSignalHandler_1 = function () {
9219 if (!signal.aborted) {
9223 outerSignal_1.addEventListener('abort', outerSignalHandler_1);
9224 subscription.add(function () { return outerSignal_1.removeEventListener('abort', outerSignalHandler_1); });
9227 perSubscriberInit = __assign({}, init, { signal: signal });
9230 perSubscriberInit = { signal: signal };
9232 fetch(input, perSubscriberInit).then(function (response) {
9234 subscription.add(from(selector(response)).subscribe(function (value) { return subscriber.next(value); }, function (err) {
9236 if (!unsubscribed) {
9237 subscriber.error(err);
9241 subscriber.complete();
9246 subscriber.next(response);
9247 subscriber.complete();
9249 }).catch(function (err) {
9251 if (!unsubscribed) {
9252 subscriber.error(err);
9255 return subscription;
9261 var _fetch = /*#__PURE__*/Object.freeze({
9262 fromFetch: fromFetch
9265 var operators = _operators;
9266 var testing = _testing;
9268 var webSocket$1 = _webSocket;
9269 var fetch$1 = _fetch;
9271 exports.operators = operators;
9272 exports.testing = testing;
9273 exports.ajax = ajax$1;
9274 exports.webSocket = webSocket$1;
9275 exports.fetch = fetch$1;
9276 exports.Observable = Observable;
9277 exports.ConnectableObservable = ConnectableObservable;
9278 exports.GroupedObservable = GroupedObservable;
9279 exports.observable = observable;
9280 exports.Subject = Subject;
9281 exports.BehaviorSubject = BehaviorSubject;
9282 exports.ReplaySubject = ReplaySubject;
9283 exports.AsyncSubject = AsyncSubject;
9284 exports.asap = asap;
9285 exports.asapScheduler = asapScheduler;
9286 exports.async = async;
9287 exports.asyncScheduler = asyncScheduler;
9288 exports.queue = queue;
9289 exports.queueScheduler = queueScheduler;
9290 exports.animationFrame = animationFrame;
9291 exports.animationFrameScheduler = animationFrameScheduler;
9292 exports.VirtualTimeScheduler = VirtualTimeScheduler;
9293 exports.VirtualAction = VirtualAction;
9294 exports.Scheduler = Scheduler;
9295 exports.Subscription = Subscription;
9296 exports.Subscriber = Subscriber;
9297 exports.Notification = Notification;
9298 exports.pipe = pipe;
9299 exports.noop = noop;
9300 exports.identity = identity;
9301 exports.isObservable = isObservable;
9302 exports.ArgumentOutOfRangeError = ArgumentOutOfRangeError;
9303 exports.EmptyError = EmptyError;
9304 exports.ObjectUnsubscribedError = ObjectUnsubscribedError;
9305 exports.UnsubscriptionError = UnsubscriptionError;
9306 exports.TimeoutError = TimeoutError;
9307 exports.bindCallback = bindCallback;
9308 exports.bindNodeCallback = bindNodeCallback;
9309 exports.combineLatest = combineLatest;
9310 exports.concat = concat;
9311 exports.defer = defer;
9312 exports.empty = empty$1;
9313 exports.forkJoin = forkJoin;
9314 exports.from = from;
9315 exports.fromEvent = fromEvent;
9316 exports.fromEventPattern = fromEventPattern;
9317 exports.generate = generate;
9319 exports.interval = interval;
9320 exports.merge = merge;
9321 exports.never = never;
9323 exports.onErrorResumeNext = onErrorResumeNext;
9324 exports.pairs = pairs;
9325 exports.partition = partition;
9326 exports.race = race;
9327 exports.range = range;
9328 exports.throwError = throwError;
9329 exports.timer = timer;
9330 exports.using = using;
9332 exports.scheduled = scheduled;
9333 exports.EMPTY = EMPTY;
9334 exports.NEVER = NEVER;
9335 exports.config = config;
9337 Object.defineProperty(exports, '__esModule', { value: true });
9341 //# sourceMappingURL=rxjs.umd.js.map