Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@reactive-js/scheduler

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@reactive-js/scheduler - npm Package Compare versions

Comparing version 0.0.34 to 0.0.35

2

dist/cjs/index.d.ts
export { SchedulerContinuationRunStatusChangedListenerLike, SchedulerContinuationLike, SchedulerLike, VirtualTimeSchedulerLike, PrioritySchedulerLike, CallbackSchedulerLike, } from "./internal/interfaces";
export { AbstractSchedulerContinuation } from "./internal/abstractSchedulerContinuation";
export { createPriorityScheduler } from "./internal/priorityScheduler";
export { toPriorityScheduler, toPausableScheduler } from "./internal/priorityScheduler";
export { scheduleCallback } from "./internal/scheduleCallback";

@@ -5,0 +5,0 @@ export { toSchedulerWithPriority } from "./internal/schedulerWithPriority";

@@ -6,3 +6,4 @@ "use strict";

var priorityScheduler_1 = require("./internal/priorityScheduler");
exports.createPriorityScheduler = priorityScheduler_1.createPriorityScheduler;
exports.toPriorityScheduler = priorityScheduler_1.toPriorityScheduler;
exports.toPausableScheduler = priorityScheduler_1.toPausableScheduler;
var scheduleCallback_1 = require("./internal/scheduleCallback");

@@ -9,0 +10,0 @@ exports.scheduleCallback = scheduleCallback_1.scheduleCallback;

@@ -18,2 +18,6 @@ import { DisposableLike } from "@reactive-js/disposable";

}
export interface PausableSchedulerLike extends SchedulerLike {
pause(): void;
resume(): void;
}
export interface PrioritySchedulerLike {

@@ -26,4 +30,3 @@ readonly inContinuation: boolean;

inContinuation: boolean;
readonly shouldYield: Option<() => boolean>;
scheduleCallback(callback: () => void, delay: number): DisposableLike;
scheduleCallback(callback: (shouldYield: Option<() => boolean>) => void, delay: number): DisposableLike;
}
import { DisposableLike } from "@reactive-js/disposable";
import { SchedulerLike, PrioritySchedulerLike } from "./interfaces";
export declare const createPriorityScheduler: (hostScheduler: SchedulerLike) => DisposableLike & PrioritySchedulerLike;
import { SchedulerLike, PrioritySchedulerLike, PausableSchedulerLike } from "./interfaces";
export declare const toPriorityScheduler: (hostScheduler: SchedulerLike) => DisposableLike & PrioritySchedulerLike;
export declare const toPausableScheduler: (hostScheduler: SchedulerLike) => DisposableLike & PausableSchedulerLike;

@@ -22,6 +22,9 @@ "use strict";

next.priority < current.priority;
return nextTaskIsHigherPriority || this.hostShouldYield();
return scheduler.isPaused || nextTaskIsHigherPriority || this.hostShouldYield();
};
}
produce(hostShouldYield) {
if (this.scheduler.isPaused) {
return -1;
}
this.hostShouldYield = hostShouldYield !== null && hostShouldYield !== void 0 ? hostShouldYield : alwaysFalse;

@@ -35,2 +38,3 @@ const { scheduler } = this;

if (delay > 0) {
scheduler.dueTime = dueTime;
return delay;

@@ -49,2 +53,5 @@ }

}
if (this.scheduler.isPaused) {
return -1;
}
isDisposed = this.isDisposed;

@@ -114,2 +121,3 @@ if (!isDisposed && this.hostShouldYield()) {

this.inContinuation = false;
this.isPaused = false;
this.queue = collections_1.createPriorityQueue(comparator);

@@ -121,3 +129,6 @@ this.delayed = collections_1.createPriorityQueue(delayedComparator);

this.dueTime = 0;
this.add(() => this.queue.clear());
this.add(() => {
this.queue.clear();
this.delayed.clear();
});
}

@@ -127,3 +138,19 @@ get now() {

}
schedule(continuation, priority, delay = 0) {
pause() {
this.isPaused = true;
this.inner.dispose();
}
resume() {
this.isPaused = false;
const head = peek(this);
if (this.inner.isDisposed && option_1.isSome(head)) {
const continuation = new PrioritySchedulerContinuation(this);
const dueTime = head.dueTime;
this.dueTime = dueTime;
this.inner = continuation;
const delay = dueTime - this.now;
this.hostScheduler.schedule(continuation, delay);
}
}
schedule(continuation, priority = Number.MAX_SAFE_INTEGER, delay = 0) {
this.add(continuation);

@@ -145,3 +172,3 @@ if (!continuation.isDisposed) {

(!this.inner.isDisposed && this.dueTime <= dueTime);
if (head === task && !continuationActive) {
if (head === task && !continuationActive && !this.isPaused) {
const continuation = new PrioritySchedulerContinuation(this);

@@ -155,3 +182,8 @@ this.dueTime = dueTime;

}
exports.createPriorityScheduler = (hostScheduler) => new PrioritySchedulerImpl(hostScheduler);
exports.toPriorityScheduler = (hostScheduler) => new PrioritySchedulerImpl(hostScheduler);
exports.toPausableScheduler = (hostScheduler) => {
const retval = new PrioritySchedulerImpl(hostScheduler);
retval.pause();
return retval;
};
//# sourceMappingURL=priorityScheduler.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function createCallback(scheduler, continuation) {
const callback = () => {
const callback = (shouldYield) => {
if (!continuation.isDisposed) {
scheduler.inContinuation = true;
const delay = continuation.run(scheduler.shouldYield);
const delay = continuation.run(shouldYield);
scheduler.inContinuation = false;

@@ -9,0 +9,0 @@ if (!continuation.isDisposed) {

export { SchedulerContinuationRunStatusChangedListenerLike, SchedulerContinuationLike, SchedulerLike, VirtualTimeSchedulerLike, PrioritySchedulerLike, CallbackSchedulerLike, } from "./internal/interfaces";
export { AbstractSchedulerContinuation } from "./internal/abstractSchedulerContinuation";
export { createPriorityScheduler } from "./internal/priorityScheduler";
export { toPriorityScheduler, toPausableScheduler } from "./internal/priorityScheduler";
export { scheduleCallback } from "./internal/scheduleCallback";

@@ -5,0 +5,0 @@ export { toSchedulerWithPriority } from "./internal/schedulerWithPriority";

export { AbstractSchedulerContinuation } from "./internal/abstractSchedulerContinuation";
export { createPriorityScheduler } from "./internal/priorityScheduler";
export { toPriorityScheduler, toPausableScheduler } from "./internal/priorityScheduler";
export { scheduleCallback } from "./internal/scheduleCallback";

@@ -4,0 +4,0 @@ export { toSchedulerWithPriority } from "./internal/schedulerWithPriority";

@@ -18,2 +18,6 @@ import { DisposableLike } from "@reactive-js/disposable";

}
export interface PausableSchedulerLike extends SchedulerLike {
pause(): void;
resume(): void;
}
export interface PrioritySchedulerLike {

@@ -26,4 +30,3 @@ readonly inContinuation: boolean;

inContinuation: boolean;
readonly shouldYield: Option<() => boolean>;
scheduleCallback(callback: () => void, delay: number): DisposableLike;
scheduleCallback(callback: (shouldYield: Option<() => boolean>) => void, delay: number): DisposableLike;
}
import { DisposableLike } from "@reactive-js/disposable";
import { SchedulerLike, PrioritySchedulerLike } from "./interfaces";
export declare const createPriorityScheduler: (hostScheduler: SchedulerLike) => DisposableLike & PrioritySchedulerLike;
import { SchedulerLike, PrioritySchedulerLike, PausableSchedulerLike } from "./interfaces";
export declare const toPriorityScheduler: (hostScheduler: SchedulerLike) => DisposableLike & PrioritySchedulerLike;
export declare const toPausableScheduler: (hostScheduler: SchedulerLike) => DisposableLike & PausableSchedulerLike;

@@ -1,2 +0,2 @@

import { createPriorityQueue, } from "@reactive-js/collections";
import { createPriorityQueue } from "@reactive-js/collections";
import { AbstractSerialDisposable, } from "@reactive-js/disposable";

@@ -20,6 +20,9 @@ import { none, isSome, isNone } from "@reactive-js/option";

next.priority < current.priority;
return nextTaskIsHigherPriority || this.hostShouldYield();
return scheduler.isPaused || nextTaskIsHigherPriority || this.hostShouldYield();
};
}
produce(hostShouldYield) {
if (this.scheduler.isPaused) {
return -1;
}
this.hostShouldYield = hostShouldYield !== null && hostShouldYield !== void 0 ? hostShouldYield : alwaysFalse;

@@ -33,2 +36,3 @@ const { scheduler } = this;

if (delay > 0) {
scheduler.dueTime = dueTime;
return delay;

@@ -47,2 +51,5 @@ }

}
if (this.scheduler.isPaused) {
return -1;
}
isDisposed = this.isDisposed;

@@ -112,2 +119,3 @@ if (!isDisposed && this.hostShouldYield()) {

this.inContinuation = false;
this.isPaused = false;
this.queue = createPriorityQueue(comparator);

@@ -119,3 +127,6 @@ this.delayed = createPriorityQueue(delayedComparator);

this.dueTime = 0;
this.add(() => this.queue.clear());
this.add(() => {
this.queue.clear();
this.delayed.clear();
});
}

@@ -125,3 +136,19 @@ get now() {

}
schedule(continuation, priority, delay = 0) {
pause() {
this.isPaused = true;
this.inner.dispose();
}
resume() {
this.isPaused = false;
const head = peek(this);
if (this.inner.isDisposed && isSome(head)) {
const continuation = new PrioritySchedulerContinuation(this);
const dueTime = head.dueTime;
this.dueTime = dueTime;
this.inner = continuation;
const delay = dueTime - this.now;
this.hostScheduler.schedule(continuation, delay);
}
}
schedule(continuation, priority = Number.MAX_SAFE_INTEGER, delay = 0) {
this.add(continuation);

@@ -143,3 +170,3 @@ if (!continuation.isDisposed) {

(!this.inner.isDisposed && this.dueTime <= dueTime);
if (head === task && !continuationActive) {
if (head === task && !continuationActive && !this.isPaused) {
const continuation = new PrioritySchedulerContinuation(this);

@@ -153,3 +180,8 @@ this.dueTime = dueTime;

}
export const createPriorityScheduler = (hostScheduler) => new PrioritySchedulerImpl(hostScheduler);
export const toPriorityScheduler = (hostScheduler) => new PrioritySchedulerImpl(hostScheduler);
export const toPausableScheduler = (hostScheduler) => {
const retval = new PrioritySchedulerImpl(hostScheduler);
retval.pause();
return retval;
};
//# sourceMappingURL=priorityScheduler.js.map
function createCallback(scheduler, continuation) {
const callback = () => {
const callback = (shouldYield) => {
if (!continuation.isDisposed) {
scheduler.inContinuation = true;
const delay = continuation.run(scheduler.shouldYield);
const delay = continuation.run(shouldYield);
scheduler.inContinuation = false;

@@ -7,0 +7,0 @@ if (!continuation.isDisposed) {

@@ -1,2 +0,2 @@

import { createPriorityQueue, } from "@reactive-js/collections";
import { createPriorityQueue } from "@reactive-js/collections";
import { none, isSome } from "@reactive-js/option";

@@ -3,0 +3,0 @@ import { AbstractSchedulerContinuation } from "./abstractSchedulerContinuation";

export { SchedulerContinuationRunStatusChangedListenerLike, SchedulerContinuationLike, SchedulerLike, VirtualTimeSchedulerLike, PrioritySchedulerLike, CallbackSchedulerLike, } from "./internal/interfaces";
export { AbstractSchedulerContinuation } from "./internal/abstractSchedulerContinuation";
export { createPriorityScheduler } from "./internal/priorityScheduler";
export { toPriorityScheduler, toPausableScheduler } from "./internal/priorityScheduler";
export { scheduleCallback } from "./internal/scheduleCallback";

@@ -5,0 +5,0 @@ export { toSchedulerWithPriority } from "./internal/schedulerWithPriority";

@@ -18,2 +18,6 @@ import { DisposableLike } from "@reactive-js/disposable";

}
export interface PausableSchedulerLike extends SchedulerLike {
pause(): void;
resume(): void;
}
export interface PrioritySchedulerLike {

@@ -26,5 +30,4 @@ readonly inContinuation: boolean;

inContinuation: boolean;
readonly shouldYield: Option<() => boolean>;
scheduleCallback(callback: () => void, delay: number): DisposableLike;
scheduleCallback(callback: (shouldYield: Option<() => boolean>) => void, delay: number): DisposableLike;
}
//# sourceMappingURL=interfaces.d.ts.map
import { DisposableLike } from "@reactive-js/disposable";
import { SchedulerLike, PrioritySchedulerLike } from "./interfaces";
export declare const createPriorityScheduler: (hostScheduler: SchedulerLike) => DisposableLike & PrioritySchedulerLike;
import { SchedulerLike, PrioritySchedulerLike, PausableSchedulerLike } from "./interfaces";
export declare const toPriorityScheduler: (hostScheduler: SchedulerLike) => DisposableLike & PrioritySchedulerLike;
export declare const toPausableScheduler: (hostScheduler: SchedulerLike) => DisposableLike & PausableSchedulerLike;
//# sourceMappingURL=priorityScheduler.d.ts.map
{
"name": "@reactive-js/scheduler",
"version": "0.0.34",
"version": "0.0.35",
"main": "dist/cjs/index.js",

@@ -41,6 +41,6 @@ "module": "dist/esm5/index.js",

"dependencies": {
"@reactive-js/collections": "^0.0.34",
"@reactive-js/disposable": "^0.0.34",
"@reactive-js/option": "^0.0.34",
"@reactive-js/pipe": "^0.0.34"
"@reactive-js/collections": "^0.0.35",
"@reactive-js/disposable": "^0.0.35",
"@reactive-js/option": "^0.0.35",
"@reactive-js/pipe": "^0.0.35"
},

@@ -72,3 +72,3 @@ "devDependencies": {

},
"gitHead": "057b4a00c7069f12169d6f8a406d140769c1a349"
"gitHead": "ee275073cbce47d721480cd774149ad178ae1621"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc