aboutsummaryrefslogtreecommitdiffstats
path: root/node_modules/rxjs/dist/esm/internal/operators/bufferToggle.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/rxjs/dist/esm/internal/operators/bufferToggle.js')
-rw-r--r--node_modules/rxjs/dist/esm/internal/operators/bufferToggle.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/node_modules/rxjs/dist/esm/internal/operators/bufferToggle.js b/node_modules/rxjs/dist/esm/internal/operators/bufferToggle.js
new file mode 100644
index 0000000..dfefe4a
--- /dev/null
+++ b/node_modules/rxjs/dist/esm/internal/operators/bufferToggle.js
@@ -0,0 +1,33 @@
+import { Subscription } from '../Subscription';
+import { operate } from '../util/lift';
+import { innerFrom } from '../observable/innerFrom';
+import { createOperatorSubscriber } from './OperatorSubscriber';
+import { noop } from '../util/noop';
+import { arrRemove } from '../util/arrRemove';
+export function bufferToggle(openings, closingSelector) {
+ return operate((source, subscriber) => {
+ const buffers = [];
+ innerFrom(openings).subscribe(createOperatorSubscriber(subscriber, (openValue) => {
+ const buffer = [];
+ buffers.push(buffer);
+ const closingSubscription = new Subscription();
+ const emitBuffer = () => {
+ arrRemove(buffers, buffer);
+ subscriber.next(buffer);
+ closingSubscription.unsubscribe();
+ };
+ closingSubscription.add(innerFrom(closingSelector(openValue)).subscribe(createOperatorSubscriber(subscriber, emitBuffer, noop)));
+ }, noop));
+ source.subscribe(createOperatorSubscriber(subscriber, (value) => {
+ for (const buffer of buffers) {
+ buffer.push(value);
+ }
+ }, () => {
+ while (buffers.length > 0) {
+ subscriber.next(buffers.shift());
+ }
+ subscriber.complete();
+ }));
+ });
+}
+//# sourceMappingURL=bufferToggle.js.map \ No newline at end of file
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage