New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

rx-queue

Package Overview
Dependencies
Maintainers
1
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rx-queue - npm Package Compare versions

Comparing version 0.9.3 to 0.12.2

24

bundles/rx-queue.es6.umd.js

@@ -1,7 +0,7 @@

/* rx-queue version 0.9.3 */
/* rx-queue version 0.12.2 */
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('rxjs'), require('rxjs/operators')) :
typeof define === 'function' && define.amd ? define(['exports', 'rxjs', 'rxjs/operators'], factory) :
(global = global || self, factory(global.window = {}, global.rxjs, global.operators));
}(this, function (exports, rxjs, operators) { 'use strict';
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.window = {}, global.rxjs, global.operators));
}(this, (function (exports, rxjs, operators) { 'use strict';

@@ -11,3 +11,3 @@ /**

*/
const VERSION = '0.9.3';
const VERSION = '0.12.2';

@@ -60,4 +60,8 @@ // default set to 500 milliseconds

this.subject = new rxjs.Subject();
this.subscription = this.subject.pipe(operators.concatMap(args => rxjs.concat(rxjs.of(args), // emit first item right away
rxjs.EMPTY.pipe(operators.delay(this.period))))).subscribe((item) => super.next(item));
this.subscription = this.subject.pipe(operators.concatMap(x => rxjs.concat(rxjs.of(x), // emit first item right away
/**
* Issue #71 - DelayQueue failed: behavior breaking change after RxJS from v6 to v7
* https://github.com/huan/rx-queue/issues/71
*/
rxjs.timer(this.period).pipe(operators.skip(1))))).subscribe((item) => super.next(item));
}

@@ -74,6 +78,7 @@ next(item) {

var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -134,4 +139,3 @@ });

this.subject = new rxjs.Subject();
this.subscription = this.subject.pipe(operators.debounce(() => rxjs.interval(this.period)))
.subscribe((item) => super.next(item));
this.subscription = this.subject.pipe(operators.debounce(() => rxjs.interval(this.period))).subscribe((item) => super.next(item));
}

@@ -183,4 +187,4 @@ next(item) {

}));
})));
/* https://github.com/huan */
//# sourceMappingURL=rx-queue.es6.umd.js.map

@@ -5,6 +5,8 @@ var __extends = (this && this.__extends) || (function () {

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);

@@ -42,8 +44,8 @@ function __() { this.constructor = d; }

};
/* rx-queue version 0.9.3 */
/* rx-queue version 0.12.2 */
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('rxjs'), require('rxjs/operators')) :
typeof define === 'function' && define.amd ? define(['exports', 'rxjs', 'rxjs/operators'], factory) :
(global = global || self, factory(global.window = {}, global.rxjs, global.operators));
}(this, function (exports, rxjs, operators) {
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.window = {}, global.rxjs, global.operators));
}(this, (function (exports, rxjs, operators) {
'use strict';

@@ -53,3 +55,3 @@ /**

*/
var VERSION = '0.9.3';
var VERSION = '0.12.2';
// default set to 500 milliseconds

@@ -106,4 +108,8 @@ var DEFAULT_PERIOD_TIME = 500;

_this.subject = new rxjs.Subject();
_this.subscription = _this.subject.pipe(operators.concatMap(function (args) { return rxjs.concat(rxjs.of(args), // emit first item right away
rxjs.EMPTY.pipe(operators.delay(_this.period))); })).subscribe(function (item) { return _super.prototype.next.call(_this, item); });
_this.subscription = _this.subject.pipe(operators.concatMap(function (x) { return rxjs.concat(rxjs.of(x), // emit first item right away
/**
* Issue #71 - DelayQueue failed: behavior breaking change after RxJS from v6 to v7
* https://github.com/huan/rx-queue/issues/71
*/
rxjs.timer(_this.period).pipe(operators.skip(1))); })).subscribe(function (item) { return _super.prototype.next.call(_this, item); });
return _this;

@@ -121,2 +127,3 @@ }

var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {

@@ -135,3 +142,3 @@ function fulfilled(value) { try {

} }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -198,4 +205,3 @@ });

_this.subject = new rxjs.Subject();
_this.subscription = _this.subject.pipe(operators.debounce(function () { return rxjs.interval(_this.period); }))
.subscribe(function (item) { return _super.prototype.next.call(_this, item); });
_this.subscription = _this.subject.pipe(operators.debounce(function () { return rxjs.interval(_this.period); })).subscribe(function (item) { return _super.prototype.next.call(_this, item); });
return _this;

@@ -248,4 +254,4 @@ }

Object.defineProperty(exports, '__esModule', { value: true });
}));
})));
/* https://github.com/huan */
//# sourceMappingURL=rx-queue.es6.umd.js.map
{
"name": "rx-queue",
"version": "0.9.3",
"version": "0.12.2",
"description": "Easy to Use ReactiveX Queue that Supports Delay/DelayExecutor/Throttle/Debounce Features Powered by RxJS.",

@@ -41,19 +41,20 @@ "main": "bundles/rx-queue.umd.js",

"peerDependencies": {
"brolog": "^1.4.9",
"rxjs": "^6.1.0"
"brolog": "^1.8.3",
"rxjs": "^7.1.0"
},
"devDependencies": {
"@chatie/eslint-config": "^0.8.1",
"@chatie/git-scripts": "^0.2.5",
"@chatie/eslint-config": "^0.12.3",
"@chatie/git-scripts": "^0.6.2",
"@chatie/semver": "^0.4.7",
"@chatie/tsconfig": "^0.6.1",
"@types/sinon": "^7.0.0",
"brolog": "^1.2",
"pkg-jq": "^0.2.4",
"rollup": "^1.0.1",
"@chatie/tsconfig": "^0.16.1",
"@types/sinon": "^10.0.1",
"brolog": "^1.12",
"pkg-jq": "^0.2.11",
"rollup": "^2.50.4",
"rollup-plugin-json": "^4.0.0",
"rxjs": "^6.5.2",
"shx": "^0.3.0",
"source-map-support": "^0.5.0",
"tstest": "^0.4.2"
"rxjs": "^7.1.0",
"shx": "^0.3.3",
"source-map-support": "^0.5.19",
"tstest": "^0.4.10",
"typescript": "^4.3.2"
},

@@ -70,5 +71,4 @@ "files": [

"access": "public",
"tag": "next"
"tag": "latest"
},
"dependencies": {},
"git": {

@@ -75,0 +75,0 @@ "scripts": {

@@ -7,3 +7,3 @@ import RxQueue from './rx-queue';

*/
export declare class DebounceQueue<T = any> extends RxQueue<T> {
export declare class DebounceQueue<T = unknown> extends RxQueue<T> {
private subscription;

@@ -10,0 +10,0 @@ private subject;

@@ -17,4 +17,3 @@ import { interval, Subject, } from 'rxjs';

this.subject = new Subject();
this.subscription = this.subject.pipe(debounce(() => interval(this.period)))
.subscribe((item) => super.next(item));
this.subscription = this.subject.pipe(debounce(() => interval(this.period))).subscribe((item) => super.next(item));
}

@@ -21,0 +20,0 @@ next(item) {

#!/usr/bin/env ts-node
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -18,3 +19,3 @@ });

const DELAY_PERIOD_TIME = 10; // milliseconds
test('DebounceQueue 1 item', (t) => __awaiter(this, void 0, void 0, function* () {
test('DebounceQueue 1 item', (t) => __awaiter(void 0, void 0, void 0, function* () {
const q = new DebounceQueue(DELAY_PERIOD_TIME);

@@ -29,3 +30,3 @@ const spy = sinon.spy();

}));
test('DebounceQueue 2 item', (t) => __awaiter(this, void 0, void 0, function* () {
test('DebounceQueue 2 item', (t) => __awaiter(void 0, void 0, void 0, function* () {
const q = new DebounceQueue(DELAY_PERIOD_TIME);

@@ -37,6 +38,6 @@ const spy = sinon.spy();

yield new Promise(resolve => setTimeout(resolve, DELAY_PERIOD_TIME + 3));
t.ok(spy.calledOnce, 'should be called only once after DELAY_PERIOD_TIME because its debounced');
t.deepEqual(spy.firstCall.args[0], EXPECTED_ITEM2, 'should get the EXPECTED_ITEM2');
t.equal(spy.callCount, 1, 'should be called only once after DELAY_PERIOD_TIME because its debounced');
t.deepEqual(spy.lastCall.args[0], EXPECTED_ITEM2, 'should get the EXPECTED_ITEM2');
}));
test('DebounceQueue 3 items', (t) => __awaiter(this, void 0, void 0, function* () {
test('DebounceQueue 3 items', (t) => __awaiter(void 0, void 0, void 0, function* () {
const q = new DebounceQueue(DELAY_PERIOD_TIME);

@@ -49,8 +50,8 @@ const spy = sinon.spy();

q.next(EXPECTED_ITEM3);
t.ok(spy.calledOnce, 'should called once right after next(EXPECTED_ITEM3)');
t.deepEqual(spy.firstCall.args[0], EXPECTED_ITEM2, 'the first call should receive EXPECTED_ITEM2');
t.equal(spy.callCount, 1, 'should called once right after next(EXPECTED_ITEM3)');
t.deepEqual(spy.lastCall.args[0], EXPECTED_ITEM2, 'the first call should receive EXPECTED_ITEM2');
yield new Promise(resolve => setTimeout(resolve, DELAY_PERIOD_TIME + 3));
t.ok(spy.calledTwice, 'should be called twice after the DELAY_PERIOD_TIME');
t.deepEqual(spy.secondCall.args[0], EXPECTED_ITEM3, 'should get EXPECTED_ITEM3');
t.equal(spy.callCount, 2, 'should be called twice after the DELAY_PERIOD_TIME');
t.deepEqual(spy.lastCall.args[0], EXPECTED_ITEM3, 'should get EXPECTED_ITEM3');
}));
//# sourceMappingURL=debounce-queue.spec.js.map
import DelayQueue from './delay-queue';
export interface ExecutionUnit<T = any> {
export interface ExecutionUnit<T = unknown> {
fn: () => T;

@@ -11,3 +11,3 @@ name: string;

*/
export declare class DelayQueueExecutor<T = any> extends DelayQueue<ExecutionUnit<T>> {
export declare class DelayQueueExecutor<T = unknown> extends DelayQueue<ExecutionUnit<T>> {
private readonly delayQueueSubscription;

@@ -14,0 +14,0 @@ /**

var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -7,0 +8,0 @@ });

#!/usr/bin/env ts-node
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -19,3 +20,3 @@ });

const MEANING_OF_LIFE = 42;
test('DelayQueueExecutor execute once', (t) => __awaiter(this, void 0, void 0, function* () {
test('DelayQueueExecutor execute once', (t) => __awaiter(void 0, void 0, void 0, function* () {
const spy = sinon.spy();

@@ -29,3 +30,3 @@ const delay = new DelayExecutor(DELAY_PERIOD_TIME);

}));
test('DelayQueueExecutor execute thrice', (t) => __awaiter(this, void 0, void 0, function* () {
test('DelayQueueExecutor execute thrice', (t) => __awaiter(void 0, void 0, void 0, function* () {
const spy = sinon.spy();

@@ -36,14 +37,14 @@ const delay = new DelayExecutor(DELAY_PERIOD_TIME);

delay.execute(() => spy(EXPECTED_VAL3)).catch(() => { });
t.ok(spy.calledOnce, 'should call once immediately');
t.equal(spy.firstCall.args[0], EXPECTED_VAL1, 'should get EXPECTED_VAL1');
t.equal(spy.callCount, 1, 'should call once immediately');
t.equal(spy.lastCall.args[0], EXPECTED_VAL1, 'should get EXPECTED_VAL1');
yield new Promise(resolve => setTimeout(resolve, DELAY_PERIOD_TIME + 3));
t.ok(spy.calledTwice, 'should call twice after DELAY_PERIOD_TIME');
t.equal(spy.secondCall.args[0], EXPECTED_VAL2, 'should get EXPECTED_VAL2');
t.equal(spy.callCount, 2, 'should call twice after DELAY_PERIOD_TIME');
t.equal(spy.lastCall.args[0], EXPECTED_VAL2, 'should get EXPECTED_VAL2');
yield new Promise(resolve => setTimeout(resolve, DELAY_PERIOD_TIME + 3));
t.ok(spy.calledThrice, 'should call thrice after 2 x DELAY_PERIOD_TIME');
t.equal(spy.thirdCall.args[0], EXPECTED_VAL3, 'should get EXPECTED_VAL3');
t.equal(spy.callCount, 3, 'should call thrice after 2 x DELAY_PERIOD_TIME');
t.equal(spy.lastCall.args[0], EXPECTED_VAL3, 'should get EXPECTED_VAL3');
yield new Promise(resolve => setTimeout(resolve, DELAY_PERIOD_TIME + 3));
t.ok(spy.calledThrice, 'should keep third call...');
t.equal(spy.callCount, 3, 'should keep third call...');
}));
test('DelayQueueExecutor return Promise', (t) => __awaiter(this, void 0, void 0, function* () {
test('DelayQueueExecutor return Promise', (t) => __awaiter(void 0, void 0, void 0, function* () {
const delay = new DelayExecutor(0);

@@ -50,0 +51,0 @@ const mol = yield delay.execute(() => MEANING_OF_LIFE);

@@ -6,3 +6,3 @@ import RxQueue from './rx-queue';

*/
export declare class DelayQueue<T = any> extends RxQueue<T> {
export declare class DelayQueue<T = unknown> extends RxQueue<T> {
private subscription;

@@ -9,0 +9,0 @@ private subject;

@@ -1,3 +0,3 @@

import { concat, EMPTY, of, Subject, } from 'rxjs';
import { concatMap, delay, } from 'rxjs/operators';
import { concat, of, Subject, timer, } from 'rxjs';
import { concatMap, skip, } from 'rxjs/operators';
import RxQueue from './rx-queue';

@@ -16,4 +16,8 @@ /**

this.subject = new Subject();
this.subscription = this.subject.pipe(concatMap(args => concat(of(args), // emit first item right away
EMPTY.pipe(delay(this.period))))).subscribe((item) => super.next(item));
this.subscription = this.subject.pipe(concatMap(x => concat(of(x), // emit first item right away
/**
* Issue #71 - DelayQueue failed: behavior breaking change after RxJS from v6 to v7
* https://github.com/huan/rx-queue/issues/71
*/
timer(this.period).pipe(skip(1))))).subscribe((item) => super.next(item));
}

@@ -20,0 +24,0 @@ next(item) {

#!/usr/bin/env ts-node
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -18,3 +19,3 @@ });

const DELAY_PERIOD_TIME = 10; // milliseconds
test('DelayQueue 1 item', (t) => __awaiter(this, void 0, void 0, function* () {
test('DelayQueue 1 item', (t) => __awaiter(void 0, void 0, void 0, function* () {
const q = new DelayQueue(DELAY_PERIOD_TIME);

@@ -24,6 +25,6 @@ const spy = sinon.spy();

q.next(EXPECTED_ITEM1);
t.ok(spy.calledOnce, 'should called right after first item');
t.deepEqual(spy.firstCall.args[0], EXPECTED_ITEM1, 'should get the first item immediately');
t.equal(spy.callCount, 1, 'should called right after first item');
t.deepEqual(spy.lastCall.args[0], EXPECTED_ITEM1, 'should get the first item immediately');
}));
test('DelayQueue 2 item', (t) => __awaiter(this, void 0, void 0, function* () {
test('DelayQueue 2 item', (t) => __awaiter(void 0, void 0, void 0, function* () {
const q = new DelayQueue(DELAY_PERIOD_TIME);

@@ -34,8 +35,9 @@ const spy = sinon.spy();

q.next(EXPECTED_ITEM2);
t.ok(spy.calledOnce, 'should get one item after next two item');
t.deepEqual(spy.firstCall.args[0], EXPECTED_ITEM1, 'should get the first item only');
t.equal(spy.callCount, 1, 'should get one item after next two item');
t.deepEqual(spy.lastCall.args[0], EXPECTED_ITEM1, 'should get the first item only');
yield new Promise(resolve => setTimeout(resolve, DELAY_PERIOD_TIME + 3));
t.ok(spy.calledTwice, 'should get the second item after period delay');
t.equal(spy.callCount, 2, 'should get the second item after period delay');
t.deepEqual(spy.lastCall.args[0], EXPECTED_ITEM2, 'should get the second item for last call');
}));
test('DelayQueue 3 items', (t) => __awaiter(this, void 0, void 0, function* () {
test('DelayQueue 3 items', (t) => __awaiter(void 0, void 0, void 0, function* () {
const q = new DelayQueue(DELAY_PERIOD_TIME);

@@ -47,8 +49,11 @@ const spy = sinon.spy();

q.next(EXPECTED_ITEM3);
t.equal(spy.callCount, 1, 'get first item immediatelly');
t.deepEqual(spy.lastCall.args[0], EXPECTED_ITEM1, 'should received EXPECTED_ITEM1 immediatelly');
yield new Promise(resolve => setTimeout(resolve, DELAY_PERIOD_TIME + 3));
t.ok(spy.calledTwice, 'get second item after period');
t.equal(spy.callCount, 2, 'get second item after period');
t.deepEqual(spy.lastCall.args[0], EXPECTED_ITEM2, 'should received EXPECTED_ITEM2 after 1 x period');
yield new Promise(resolve => setTimeout(resolve, DELAY_PERIOD_TIME + 3));
t.ok(spy.calledThrice, 'should get the third item after 2 x period');
t.deepEqual(spy.thirdCall.args[0], EXPECTED_ITEM3, 'should received EXPECTED_ITEM3 after 2 x period');
t.equal(spy.callCount, 3, 'should get the third item after 2 x period');
t.deepEqual(spy.lastCall.args[0], EXPECTED_ITEM3, 'should received EXPECTED_ITEM3 after 2 x period');
}));
//# sourceMappingURL=delay-queue.spec.js.map
import { PartialObserver, Subject, Subscription } from 'rxjs';
export declare class RxQueue<T = any> extends Subject<T> {
export declare class RxQueue<T = unknown> extends Subject<T> {
period: number;

@@ -4,0 +4,0 @@ private itemList;

#!/usr/bin/env ts-node
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -14,3 +15,3 @@ });

import RxQueue from './rx-queue';
test('RxQueue subscribe & next', (t) => __awaiter(this, void 0, void 0, function* () {
test('RxQueue subscribe & next', (t) => __awaiter(void 0, void 0, void 0, function* () {
const EXPECTED_ITEM = { test: 'testing123' };

@@ -24,3 +25,3 @@ const spy = sinon.spy();

}));
test('RxQueue version()', (t) => __awaiter(this, void 0, void 0, function* () {
test('RxQueue version()', (t) => __awaiter(void 0, void 0, void 0, function* () {
const q = new RxQueue();

@@ -27,0 +28,0 @@ t.ok(/^\d+\.\d+\.\d+$/.test(q.version()), 'get version');

@@ -9,3 +9,3 @@ import RxQueue from './rx-queue';

*/
export declare class ThrottleQueue<T = any> extends RxQueue<T> {
export declare class ThrottleQueue<T = unknown> extends RxQueue<T> {
private subscription;

@@ -12,0 +12,0 @@ private subject;

#!/usr/bin/env ts-node
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -18,3 +19,3 @@ });

const THROTTLE_PERIOD_TIME = 10; // milliseconds
test('ThrottleQueue 1 item', (t) => __awaiter(this, void 0, void 0, function* () {
test('ThrottleQueue 1 item', (t) => __awaiter(void 0, void 0, void 0, function* () {
const q = new ThrottleQueue(THROTTLE_PERIOD_TIME);

@@ -27,3 +28,3 @@ const spy = sinon.spy();

}));
test('ThrottleQueue 2 item', (t) => __awaiter(this, void 0, void 0, function* () {
test('ThrottleQueue 2 item', (t) => __awaiter(void 0, void 0, void 0, function* () {
const q = new ThrottleQueue(THROTTLE_PERIOD_TIME);

@@ -39,3 +40,3 @@ const spy = sinon.spy();

}));
test('ThrottleQueue 3 items', (t) => __awaiter(this, void 0, void 0, function* () {
test('ThrottleQueue 3 items', (t) => __awaiter(void 0, void 0, void 0, function* () {
const q = new ThrottleQueue(THROTTLE_PERIOD_TIME);

@@ -42,0 +43,0 @@ const spy = sinon.spy();

/**
* This file was auto generated from scripts/generate-version.sh
*/
export const VERSION = '0.9.3';
export const VERSION = '0.12.2';
//# sourceMappingURL=version.js.map
#!/usr/bin/env ts-node
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -13,5 +14,5 @@ });

import { VERSION } from './version';
test('Make sure the VERSION is fresh in source code', (t) => __awaiter(this, void 0, void 0, function* () {
test('Make sure the VERSION is fresh in source code', (t) => __awaiter(void 0, void 0, void 0, function* () {
t.equal(VERSION, '0.0.0', 'version should be 0.0.0 in source code, only updated before publish to NPM');
}));
//# sourceMappingURL=version.spec.js.map
{
"name": "rx-queue",
"version": "0.9.3",
"version": "0.12.2",
"description": "Easy to Use ReactiveX Queue that Supports Delay/DelayExecutor/Throttle/Debounce Features Powered by RxJS.",

@@ -41,19 +41,20 @@ "main": "bundles/rx-queue.umd.js",

"peerDependencies": {
"brolog": "^1.4.9",
"rxjs": "^6.1.0"
"brolog": "^1.8.3",
"rxjs": "^7.1.0"
},
"devDependencies": {
"@chatie/eslint-config": "^0.8.1",
"@chatie/git-scripts": "^0.2.5",
"@chatie/eslint-config": "^0.12.3",
"@chatie/git-scripts": "^0.6.2",
"@chatie/semver": "^0.4.7",
"@chatie/tsconfig": "^0.6.1",
"@types/sinon": "^7.0.0",
"brolog": "^1.2",
"pkg-jq": "^0.2.4",
"rollup": "^1.0.1",
"@chatie/tsconfig": "^0.16.1",
"@types/sinon": "^10.0.1",
"brolog": "^1.12",
"pkg-jq": "^0.2.11",
"rollup": "^2.50.4",
"rollup-plugin-json": "^4.0.0",
"rxjs": "^6.5.2",
"shx": "^0.3.0",
"source-map-support": "^0.5.0",
"tstest": "^0.4.2"
"rxjs": "^7.1.0",
"shx": "^0.3.3",
"source-map-support": "^0.5.19",
"tstest": "^0.4.10",
"typescript": "^4.3.2"
},

@@ -70,5 +71,4 @@ "files": [

"access": "public",
"tag": "next"
"tag": "latest"
},
"dependencies": {},
"git": {

@@ -75,0 +75,0 @@ "scripts": {

# RX-QUEUE
[![Greenkeeper badge](https://badges.greenkeeper.io/huan/rx-queue.svg)](https://greenkeeper.io/)
[![Build Status](https://travis-ci.com/huan/rx-queue.svg?branch=master)](https://travis-ci.com/huan/rx-queue) [![Windows Build status](https://img.shields.io/appveyor/ci/zixia/rx-queue/master.svg?label=Windows)](https://ci.appveyor.com/project/zixia/rx-queue) [![NPM Version](https://badge.fury.io/js/rx-queue.svg)](https://badge.fury.io/js/rx-queue) [![Downloads](http://img.shields.io/npm/dm/rx-queue.svg?style=flat-square)](https://npmjs.org/package/rx-queue) [![Powered by TypeScript](https://img.shields.io/badge/Powered%20By-TypeScript-blue.svg)](https://www.typescriptlang.org/)
[![NPM](https://github.com/huan/rx-queue/actions/workflows/npm.yml/badge.svg)](https://github.com/huan/rx-queue/actions/workflows/npm.yml)
[![Windows Build status](https://img.shields.io/appveyor/ci/zixia/rx-queue/master.svg?label=Windows)](https://ci.appveyor.com/project/zixia/rx-queue)
[![NPM Version](https://badge.fury.io/js/rx-queue.svg)](https://badge.fury.io/js/rx-queue)
[![Downloads](http://img.shields.io/npm/dm/rx-queue.svg?style=flat-square)](https://npmjs.org/package/rx-queue)
[![Powered by TypeScript](https://img.shields.io/badge/Powered%20By-TypeScript-blue.svg)](https://www.typescriptlang.org/)

@@ -79,2 +82,3 @@ Easy to Use ReactiveX Queue that Supports Delay/DelayExecutor/Throttle/Debounce Features Powered by RxJS.

Practical examples of `ThrottleQueue`:
1. User is typing text in a textarea. We want to call auto-save function when user is typing, and want it only run at most once every five minutes.

@@ -109,2 +113,3 @@

Practical examples of `DebounceQueue`:
1. User is typing text in a search box. We want to make an auto-complete function call only after the user stop typing for 500 milliseconds.

@@ -132,2 +137,4 @@

> If you want this feature but do not want rxjs dependencies, you can have a look on a zero dependencies alternative: [BottleNeck](https://github.com/SGrondin/bottleneck)
![DelayQueueExecutor](https://huan.github.io/rx-queue/images/delay.png)

@@ -164,5 +171,11 @@ > Picture Credit: [ReactiveX Single Operator Delay](http://reactivex.io/documentation/single.html)

### v0.12 - May 2021
1. Upgrade RxJS to v7.1
1. Upgrade TypeScript to v4.3
1. Fix RxJS breaking changes [#71](https://github.com/huan/rx-queue/issues/71)
### v0.8 - Mar 2019
1. Fix typo of ISSUE #40: rename `DelayQueueExector` to `DelayQueueExecutor`
1. Fix typo: issue [#40](https://github.com/huan/rx-queue/issues/40) - rename `DelayQueueExector` to `DelayQueueExecutor`

@@ -191,4 +204,4 @@ ### v0.6 - Sep 2018

* Code & Docs © 2017-2018 Huan LI \<zixia@zixia.net\>
* Code & Docs © 2017-now Huan LI \<zixia@zixia.net\>
* Code released under the Apache-2.0 License
* Docs released under Creative Commons

@@ -39,4 +39,4 @@ #!/usr/bin/env ts-node

await new Promise(resolve => setTimeout(resolve, DELAY_PERIOD_TIME + 3))
t.ok(spy.calledOnce, 'should be called only once after DELAY_PERIOD_TIME because its debounced')
t.deepEqual(spy.firstCall.args[0], EXPECTED_ITEM2, 'should get the EXPECTED_ITEM2')
t.equal(spy.callCount, 1, 'should be called only once after DELAY_PERIOD_TIME because its debounced')
t.deepEqual(spy.lastCall.args[0], EXPECTED_ITEM2, 'should get the EXPECTED_ITEM2')
})

@@ -56,8 +56,8 @@

q.next(EXPECTED_ITEM3)
t.ok(spy.calledOnce, 'should called once right after next(EXPECTED_ITEM3)')
t.deepEqual(spy.firstCall.args[0], EXPECTED_ITEM2, 'the first call should receive EXPECTED_ITEM2')
t.equal(spy.callCount, 1, 'should called once right after next(EXPECTED_ITEM3)')
t.deepEqual(spy.lastCall.args[0], EXPECTED_ITEM2, 'the first call should receive EXPECTED_ITEM2')
await new Promise(resolve => setTimeout(resolve, DELAY_PERIOD_TIME + 3))
t.ok(spy.calledTwice, 'should be called twice after the DELAY_PERIOD_TIME')
t.deepEqual(spy.secondCall.args[0], EXPECTED_ITEM3, 'should get EXPECTED_ITEM3')
t.equal(spy.callCount, 2, 'should be called twice after the DELAY_PERIOD_TIME')
t.deepEqual(spy.lastCall.args[0], EXPECTED_ITEM3, 'should get EXPECTED_ITEM3')
})

@@ -17,3 +17,3 @@ import {

*/
export class DebounceQueue<T = any> extends RxQueue<T> {
export class DebounceQueue<T = unknown> extends RxQueue<T> {

@@ -35,4 +35,3 @@ private subscription : Subscription

debounce(() => interval(this.period)),
)
.subscribe((item: T) => super.next(item))
).subscribe((item: T) => super.next(item))
}

@@ -39,0 +38,0 @@

@@ -39,15 +39,15 @@ #!/usr/bin/env ts-node

t.ok(spy.calledOnce, 'should call once immediately')
t.equal(spy.firstCall.args[0], EXPECTED_VAL1, 'should get EXPECTED_VAL1')
t.equal(spy.callCount, 1, 'should call once immediately')
t.equal(spy.lastCall.args[0], EXPECTED_VAL1, 'should get EXPECTED_VAL1')
await new Promise(resolve => setTimeout(resolve, DELAY_PERIOD_TIME + 3))
t.ok(spy.calledTwice, 'should call twice after DELAY_PERIOD_TIME')
t.equal(spy.secondCall.args[0], EXPECTED_VAL2, 'should get EXPECTED_VAL2')
t.equal(spy.callCount, 2, 'should call twice after DELAY_PERIOD_TIME')
t.equal(spy.lastCall.args[0], EXPECTED_VAL2, 'should get EXPECTED_VAL2')
await new Promise(resolve => setTimeout(resolve, DELAY_PERIOD_TIME + 3))
t.ok(spy.calledThrice, 'should call thrice after 2 x DELAY_PERIOD_TIME')
t.equal(spy.thirdCall.args[0], EXPECTED_VAL3, 'should get EXPECTED_VAL3')
t.equal(spy.callCount, 3, 'should call thrice after 2 x DELAY_PERIOD_TIME')
t.equal(spy.lastCall.args[0], EXPECTED_VAL3, 'should get EXPECTED_VAL3')
await new Promise(resolve => setTimeout(resolve, DELAY_PERIOD_TIME + 3))
t.ok(spy.calledThrice, 'should keep third call...')
t.equal(spy.callCount, 3, 'should keep third call...')
})

@@ -54,0 +54,0 @@

import { Subscription } from 'rxjs'
import DelayQueue from './delay-queue'
export interface ExecutionUnit<T = any> {
export interface ExecutionUnit<T = unknown> {
fn : () => T,

@@ -14,3 +15,3 @@ name : string,

*/
export class DelayQueueExecutor<T = any> extends DelayQueue<ExecutionUnit<T>> {
export class DelayQueueExecutor<T = unknown> extends DelayQueue<ExecutionUnit<T>> {

@@ -17,0 +18,0 @@ private readonly delayQueueSubscription: Subscription

@@ -23,4 +23,4 @@ #!/usr/bin/env ts-node

t.ok(spy.calledOnce, 'should called right after first item')
t.deepEqual(spy.firstCall.args[0], EXPECTED_ITEM1, 'should get the first item immediately')
t.equal(spy.callCount, 1, 'should called right after first item')
t.deepEqual(spy.lastCall.args[0], EXPECTED_ITEM1, 'should get the first item immediately')
})

@@ -37,7 +37,8 @@

t.ok(spy.calledOnce, 'should get one item after next two item')
t.deepEqual(spy.firstCall.args[0], EXPECTED_ITEM1, 'should get the first item only')
t.equal(spy.callCount, 1, 'should get one item after next two item')
t.deepEqual(spy.lastCall.args[0], EXPECTED_ITEM1, 'should get the first item only')
await new Promise(resolve => setTimeout(resolve, DELAY_PERIOD_TIME + 3))
t.ok(spy.calledTwice, 'should get the second item after period delay')
t.equal(spy.callCount, 2, 'should get the second item after period delay')
t.deepEqual(spy.lastCall.args[0], EXPECTED_ITEM2, 'should get the second item for last call')
})

@@ -55,8 +56,12 @@

t.equal(spy.callCount, 1, 'get first item immediatelly')
t.deepEqual(spy.lastCall.args[0], EXPECTED_ITEM1, 'should received EXPECTED_ITEM1 immediatelly')
await new Promise(resolve => setTimeout(resolve, DELAY_PERIOD_TIME + 3))
t.ok(spy.calledTwice, 'get second item after period')
t.equal(spy.callCount, 2, 'get second item after period')
t.deepEqual(spy.lastCall.args[0], EXPECTED_ITEM2, 'should received EXPECTED_ITEM2 after 1 x period')
await new Promise(resolve => setTimeout(resolve, DELAY_PERIOD_TIME + 3))
t.ok(spy.calledThrice, 'should get the third item after 2 x period')
t.deepEqual(spy.thirdCall.args[0], EXPECTED_ITEM3, 'should received EXPECTED_ITEM3 after 2 x period')
t.equal(spy.callCount, 3, 'should get the third item after 2 x period')
t.deepEqual(spy.lastCall.args[0], EXPECTED_ITEM3, 'should received EXPECTED_ITEM3 after 2 x period')
})
import {
concat,
EMPTY,
of,
Subject,
Subscription,
timer,
} from 'rxjs'
import {
concatMap,
delay,
skip,
} from 'rxjs/operators'

@@ -19,3 +19,3 @@

*/
export class DelayQueue<T = any> extends RxQueue<T> {
export class DelayQueue<T = unknown> extends RxQueue<T> {

@@ -36,5 +36,9 @@ private subscription : Subscription

this.subscription = this.subject.pipe(
concatMap(args => concat(
of(args), // emit first item right away
EMPTY.pipe(delay(this.period)), // delay next item
concatMap(x => concat(
of(x), // emit first item right away
/**
* Issue #71 - DelayQueue failed: behavior breaking change after RxJS from v6 to v7
* https://github.com/huan/rx-queue/issues/71
*/
timer(this.period).pipe(skip(1)),
)),

@@ -41,0 +45,0 @@ ).subscribe((item: T) => super.next(item))

@@ -15,3 +15,3 @@ import {

// https://codepen.io/maindg/pen/xRwGvL
export class RxQueue<T = any> extends Subject<T> {
export class RxQueue<T = unknown> extends Subject<T> {

@@ -18,0 +18,0 @@ private itemList: T[] = []

@@ -19,3 +19,3 @@ import {

*/
export class ThrottleQueue<T = any> extends RxQueue<T> {
export class ThrottleQueue<T = unknown> extends RxQueue<T> {

@@ -22,0 +22,0 @@ private subscription : Subscription

/**
* This file was auto generated from scripts/generate-version.sh
*/
export const VERSION: string = '0.9.3'
export const VERSION: string = '0.12.2'

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