aboutsummaryrefslogtreecommitdiffstats
path: root/node_modules/rxjs/dist/esm5/internal/operators/windowTime.js
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2025-06-28 17:26:46 -0700
committerPinapelz <yukais@pinapelz.com>2025-06-28 17:43:56 -0700
commite4fa1e69e7ebfb627c7198fd1a9881e9327ec4d4 (patch)
tree06284a538a6008eca75051399e47db4e5d50301c /node_modules/rxjs/dist/esm5/internal/operators/windowTime.js
initial commit: scaffolding
Diffstat (limited to 'node_modules/rxjs/dist/esm5/internal/operators/windowTime.js')
-rw-r--r--node_modules/rxjs/dist/esm5/internal/operators/windowTime.js70
1 files changed, 70 insertions, 0 deletions
diff --git a/node_modules/rxjs/dist/esm5/internal/operators/windowTime.js b/node_modules/rxjs/dist/esm5/internal/operators/windowTime.js
new file mode 100644
index 0000000..6c16342
--- /dev/null
+++ b/node_modules/rxjs/dist/esm5/internal/operators/windowTime.js
@@ -0,0 +1,70 @@
+import { Subject } from '../Subject';
+import { asyncScheduler } from '../scheduler/async';
+import { Subscription } from '../Subscription';
+import { operate } from '../util/lift';
+import { createOperatorSubscriber } from './OperatorSubscriber';
+import { arrRemove } from '../util/arrRemove';
+import { popScheduler } from '../util/args';
+import { executeSchedule } from '../util/executeSchedule';
+export function windowTime(windowTimeSpan) {
+ var _a, _b;
+ var otherArgs = [];
+ for (var _i = 1; _i < arguments.length; _i++) {
+ otherArgs[_i - 1] = arguments[_i];
+ }
+ var scheduler = (_a = popScheduler(otherArgs)) !== null && _a !== void 0 ? _a : asyncScheduler;
+ var windowCreationInterval = (_b = otherArgs[0]) !== null && _b !== void 0 ? _b : null;
+ var maxWindowSize = otherArgs[1] || Infinity;
+ return operate(function (source, subscriber) {
+ var windowRecords = [];
+ var restartOnClose = false;
+ var closeWindow = function (record) {
+ var window = record.window, subs = record.subs;
+ window.complete();
+ subs.unsubscribe();
+ arrRemove(windowRecords, record);
+ restartOnClose && startWindow();
+ };
+ var startWindow = function () {
+ if (windowRecords) {
+ var subs = new Subscription();
+ subscriber.add(subs);
+ var window_1 = new Subject();
+ var record_1 = {
+ window: window_1,
+ subs: subs,
+ seen: 0,
+ };
+ windowRecords.push(record_1);
+ subscriber.next(window_1.asObservable());
+ executeSchedule(subs, scheduler, function () { return closeWindow(record_1); }, windowTimeSpan);
+ }
+ };
+ if (windowCreationInterval !== null && windowCreationInterval >= 0) {
+ executeSchedule(subscriber, scheduler, startWindow, windowCreationInterval, true);
+ }
+ else {
+ restartOnClose = true;
+ }
+ startWindow();
+ var loop = function (cb) { return windowRecords.slice().forEach(cb); };
+ var terminate = function (cb) {
+ loop(function (_a) {
+ var window = _a.window;
+ return cb(window);
+ });
+ cb(subscriber);
+ subscriber.unsubscribe();
+ };
+ source.subscribe(createOperatorSubscriber(subscriber, function (value) {
+ loop(function (record) {
+ record.window.next(value);
+ maxWindowSize <= ++record.seen && closeWindow(record);
+ });
+ }, function () { return terminate(function (consumer) { return consumer.complete(); }); }, function (err) { return terminate(function (consumer) { return consumer.error(err); }); }));
+ return function () {
+ windowRecords = null;
+ };
+ });
+}
+//# sourceMappingURL=windowTime.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