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.8.2 to 0.8.4

dist/src/version.d.ts

332

bundles/rx-queue.es6.umd.js

@@ -1,179 +0,181 @@

/* rx-queue version 0.8.2 */
/* rx-queue version 0.8.4 */
(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));
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';
var version = "0.8.2";
/**
* This file was auto generated from scripts/generate-version.sh
*/
const VERSION = '0.8.4';
let VERSION = version;
// default set to 500 milliseconds
const DEFAULT_PERIOD_TIME = 500;
// https://codepen.io/maindg/pen/xRwGvL
class RxQueue extends rxjs.Subject {
constructor(period = DEFAULT_PERIOD_TIME) {
super();
this.period = period;
this.itemList = [];
}
next(item) {
if (this.observers.length > 0) {
super.next(item);
}
else {
this.itemList.push(item);
}
}
subscribe(nextOrObserver, error, complete) {
let subscription; // TypeScript strict require strong typing differenciation
if (typeof nextOrObserver === 'function') {
subscription = super.subscribe(nextOrObserver, error, complete);
}
else {
subscription = super.subscribe(nextOrObserver);
}
this.itemList.forEach(item => this.next(item));
this.itemList = [];
return subscription;
}
version() {
return VERSION;
}
}
// default set to 500 milliseconds
const DEFAULT_PERIOD_TIME = 500;
// https://codepen.io/maindg/pen/xRwGvL
class RxQueue extends rxjs.Subject {
constructor(period = DEFAULT_PERIOD_TIME) {
super();
this.period = period;
this.itemList = [];
}
next(item) {
if (this.observers.length > 0) {
super.next(item);
}
else {
this.itemList.push(item);
}
}
subscribe(nextOrObserver, error, complete) {
let subscription; // TypeScript strict require strong typing differenciation
if (typeof nextOrObserver === 'function') {
subscription = super.subscribe(nextOrObserver, error, complete);
}
else {
subscription = super.subscribe(nextOrObserver);
}
this.itemList.forEach(item => this.next(item));
this.itemList = [];
return subscription;
}
version() {
return VERSION;
}
}
/**
* DelayQueue passes all the items and add delays between items.
* T: item type
*/
class DelayQueue extends RxQueue {
/**
*
* @param period milliseconds
*/
constructor(period) {
super(period);
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));
}
next(item) {
this.subject.next(item);
}
unsubscribe() {
this.subscription.unsubscribe();
super.unsubscribe();
}
}
/**
* DebounceQueue drops a item if there's another one comes in a period of time.
*
* T: item type
*/
class DebounceQueue extends RxQueue {
/**
*
* @param period milliseconds
*/
constructor(period) {
super(period);
this.subject = new rxjs.Subject();
this.subscription = this.subject.pipe(operators.debounce(() => rxjs.interval(this.period)))
.subscribe((item) => super.next(item));
}
next(item) {
this.subject.next(item);
}
unsubscribe() {
this.subscription.unsubscribe();
super.unsubscribe();
}
}
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
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); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
/**
* DelayQueueExecutor calls functions one by one with a delay time period between calls.
*/
class DelayQueueExecutor extends DelayQueue {
/**
*
* @param period milliseconds
*/
constructor(period) {
super(period);
this.delayQueueSubscription = this.subscribe(unit => {
try {
const ret = unit.fn();
return unit.resolve(ret);
}
catch (e) {
return unit.reject(e);
}
});
}
execute(fn, name) {
return __awaiter(this, void 0, void 0, function* () {
return new Promise((resolve, reject) => {
const unit = {
fn,
name: name || fn.name,
reject,
resolve,
};
this.next(unit);
});
});
}
unsubscribe() {
this.delayQueueSubscription.unsubscribe();
super.unsubscribe();
}
}
/**
* DelayQueue passes all the items and add delays between items.
* T: item type
*/
class DelayQueue extends RxQueue {
/**
*
* @param period milliseconds
*/
constructor(period) {
super(period);
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));
}
next(item) {
this.subject.next(item);
}
unsubscribe() {
this.subscription.unsubscribe();
super.unsubscribe();
}
}
/**
* DebounceQueue drops a item if there's another one comes in a period of time.
*
* T: item type
*/
class DebounceQueue extends RxQueue {
/**
*
* @param period milliseconds
*/
constructor(period) {
super(period);
this.subject = new rxjs.Subject();
this.subscription = this.subject.pipe(operators.debounce(() => rxjs.interval(this.period)))
.subscribe((item) => super.next(item));
}
next(item) {
this.subject.next(item);
}
unsubscribe() {
this.subscription.unsubscribe();
super.unsubscribe();
}
}
/**
* ThrottleQueue
*
* passes one item and then drop all the following items in a period of time.
*
* T: item type
*/
class ThrottleQueue extends RxQueue {
/**
*
* @param period milliseconds
*/
constructor(period) {
super(period);
this.subject = new rxjs.Subject();
this.subscription = this.subject.pipe(operators.throttle(_ => rxjs.interval(this.period))).subscribe((item) => super.next(item));
}
next(item) {
this.subject.next(item);
}
unsubscribe() {
this.subscription.unsubscribe();
super.unsubscribe();
}
}
/**
* ThrottleQueue
*
* passes one item and then drop all the following items in a period of time.
*
* T: item type
*/
class ThrottleQueue extends RxQueue {
/**
*
* @param period milliseconds
*/
constructor(period) {
super(period);
this.subject = new rxjs.Subject();
this.subscription = this.subject.pipe(operators.throttle(() => rxjs.interval(this.period))).subscribe((item) => super.next(item));
}
next(item) {
this.subject.next(item);
}
unsubscribe() {
this.subscription.unsubscribe();
super.unsubscribe();
}
}
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
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); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
/**
* DelayQueueExecutor calls functions one by one with a delay time period between calls.
*/
class DelayQueueExecutor extends DelayQueue {
/**
*
* @param period milliseconds
*/
constructor(period) {
super(period);
this.delayQueueSubscription = this.subscribe(unit => {
try {
const ret = unit.fn();
return unit.resolve(ret);
}
catch (e) {
return unit.reject(e);
}
});
}
execute(fn, name) {
return __awaiter(this, void 0, void 0, function* () {
return new Promise((resolve, reject) => {
const unit = {
fn,
name: name || fn.name,
reject,
resolve,
};
this.next(unit);
});
});
}
unsubscribe() {
this.delayQueueSubscription.unsubscribe();
super.unsubscribe();
}
}
exports.DebounceQueue = DebounceQueue;
exports.DelayQueue = DelayQueue;
exports.DelayQueueExector = DelayQueueExecutor;
exports.DelayQueueExecutor = DelayQueueExecutor;
exports.RxQueue = RxQueue;
exports.ThrottleQueue = ThrottleQueue;
exports.VERSION = VERSION;
exports.DebounceQueue = DebounceQueue;
exports.DelayQueue = DelayQueue;
exports.DelayQueueExector = DelayQueueExecutor;
exports.DelayQueueExecutor = DelayQueueExecutor;
exports.RxQueue = RxQueue;
exports.ThrottleQueue = ThrottleQueue;
Object.defineProperty(exports, '__esModule', { value: true });
Object.defineProperty(exports, '__esModule', { value: true });
}));
/* https://github.com/huan */
//# sourceMappingURL=rx-queue.es6.umd.js.map

@@ -41,3 +41,3 @@ var __extends = (this && this.__extends) || (function () {

};
/* rx-queue version 0.8.2 */
/* rx-queue version 0.8.4 */
(function (global, factory) {

@@ -49,4 +49,6 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('rxjs'), require('rxjs/operators')) :

'use strict';
var version = "0.8.2";
var VERSION = version;
/**
* This file was auto generated from scripts/generate-version.sh
*/
var VERSION = '0.8.4';
// default set to 500 milliseconds

@@ -91,29 +93,2 @@ var DEFAULT_PERIOD_TIME = 500;

/**
* DebounceQueue drops a item if there's another one comes in a period of time.
*
* T: item type
*/
var DebounceQueue = /** @class */ (function (_super) {
__extends(DebounceQueue, _super);
/**
*
* @param period milliseconds
*/
function DebounceQueue(period) {
var _this = _super.call(this, period) || this;
_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); });
return _this;
}
DebounceQueue.prototype.next = function (item) {
this.subject.next(item);
};
DebounceQueue.prototype.unsubscribe = function () {
this.subscription.unsubscribe();
_super.prototype.unsubscribe.call(this);
};
return DebounceQueue;
}(RxQueue));
/**
* DelayQueue passes all the items and add delays between items.

@@ -144,30 +119,2 @@ * T: item type

}(RxQueue));
/**
* ThrottleQueue
*
* passes one item and then drop all the following items in a period of time.
*
* T: item type
*/
var ThrottleQueue = /** @class */ (function (_super) {
__extends(ThrottleQueue, _super);
/**
*
* @param period milliseconds
*/
function ThrottleQueue(period) {
var _this = _super.call(this, period) || this;
_this.subject = new rxjs.Subject();
_this.subscription = _this.subject.pipe(operators.throttle(function (_) { return rxjs.interval(_this.period); })).subscribe(function (item) { return _super.prototype.next.call(_this, item); });
return _this;
}
ThrottleQueue.prototype.next = function (item) {
this.subject.next(item);
};
ThrottleQueue.prototype.unsubscribe = function () {
this.subscription.unsubscribe();
_super.prototype.unsubscribe.call(this);
};
return ThrottleQueue;
}(RxQueue));
var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -235,2 +182,57 @@ return new (P || (P = Promise))(function (resolve, reject) {

}(DelayQueue));
/**
* DebounceQueue drops a item if there's another one comes in a period of time.
*
* T: item type
*/
var DebounceQueue = /** @class */ (function (_super) {
__extends(DebounceQueue, _super);
/**
*
* @param period milliseconds
*/
function DebounceQueue(period) {
var _this = _super.call(this, period) || this;
_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); });
return _this;
}
DebounceQueue.prototype.next = function (item) {
this.subject.next(item);
};
DebounceQueue.prototype.unsubscribe = function () {
this.subscription.unsubscribe();
_super.prototype.unsubscribe.call(this);
};
return DebounceQueue;
}(RxQueue));
/**
* ThrottleQueue
*
* passes one item and then drop all the following items in a period of time.
*
* T: item type
*/
var ThrottleQueue = /** @class */ (function (_super) {
__extends(ThrottleQueue, _super);
/**
*
* @param period milliseconds
*/
function ThrottleQueue(period) {
var _this = _super.call(this, period) || this;
_this.subject = new rxjs.Subject();
_this.subscription = _this.subject.pipe(operators.throttle(function () { return rxjs.interval(_this.period); })).subscribe(function (item) { return _super.prototype.next.call(_this, item); });
return _this;
}
ThrottleQueue.prototype.next = function (item) {
this.subject.next(item);
};
ThrottleQueue.prototype.unsubscribe = function () {
this.subscription.unsubscribe();
_super.prototype.unsubscribe.call(this);
};
return ThrottleQueue;
}(RxQueue));
exports.DebounceQueue = DebounceQueue;

@@ -242,2 +244,3 @@ exports.DelayQueue = DelayQueue;

exports.ThrottleQueue = ThrottleQueue;
exports.VERSION = VERSION;
Object.defineProperty(exports, '__esModule', { value: true });

@@ -244,0 +247,0 @@ }));

{
"name": "rx-queue",
"version": "0.8.2",
"version": "0.8.4",
"description": "Easy to Use ReactiveX Queue that Supports Delay/DelayExecutor/Throttle/Debounce Features Powered by RxJS.",

@@ -12,8 +12,9 @@ "main": "bundles/rx-queue.umd.js",

"build": "tsc --module es6 && shx cp package.json dist/",
"lint": "npm run lint:ts",
"lint": "npm run lint:es && npm run lint:ts",
"rollup": "rollup -c",
"lint:ts": "tslint --project tsconfig.json && tsc --noEmit",
"lint:ts": "tsc --noEmit",
"test": "npm run lint && npm run test:unit",
"test:unit": "blue-tape -r ts-node/register \"src/**/*.spec.ts\" \"tests/**/*.spec.ts\"",
"test:pack": "bash -x scripts/npm-pack-testing.sh"
"test:pack": "bash -x scripts/npm-pack-testing.sh",
"lint:es": "eslint --ignore-pattern fixtures/ 'src/**/*.ts' 'tests/**/*.ts'"
},

@@ -45,20 +46,15 @@ "repository": {

"devDependencies": {
"@types/blue-tape": "^0.1.33",
"@types/node": "^12.0.0",
"@types/semver": "^6.0.0",
"@chatie/eslint-config": "^0.6.18",
"@chatie/git-scripts": "^0.2.5",
"@chatie/semver": "^0.4.7",
"@chatie/tsconfig": "^0.6.1",
"@types/sinon": "^7.0.0",
"blue-tape": "^1.0.0",
"brolog": "^1.2",
"git-scripts": "git+https://github.com/nkzawa/git-scripts.git",
"pkg-jq": "^0.2.4",
"rollup": "^1.0.1",
"rollup-plugin-json": "^4.0.0",
"rxjs": "^6.5.2",
"semver": "^6.0.0",
"shx": "^0.3.0",
"sinon": "^7.1.1",
"source-map-support": "^0.5.0",
"ts-node": "^8.0.3",
"tslint": "^5.11.0",
"tslint-config-standard": "^8.0.1",
"typescript": "^3.1.0-dev.20180915"
"tstest": "^0.4.2"
},

@@ -73,11 +69,12 @@ "files": [

],
"publishConfig": {
"access": "public",
"tag": "latest"
},
"dependencies": {},
"git": {
"scripts": {
"pre-push": "bash scripts/pre-push.sh"
"pre-push": "npx git-scripts-pre-push"
}
},
"publishConfig": {
"access": "public",
"tag": "latest"
}
}
}

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

export declare let VERSION: string;
export { VERSION } from './version';

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

import { version } from '../package.json';
export let VERSION = version;
export { VERSION } from './version';
//# sourceMappingURL=config.js.map

@@ -24,3 +24,3 @@ #!/usr/bin/env ts-node

t.ok(spy.notCalled, 'should not called right after first item');
yield new Promise(r => setTimeout(r, DELAY_PERIOD_TIME + 3));
yield new Promise(resolve => setTimeout(resolve, DELAY_PERIOD_TIME + 3));
t.ok(spy.calledOnce, 'should be called after the DELAY_PERIOD_TIME');

@@ -35,3 +35,3 @@ t.deepEqual(spy.firstCall.args[0], EXPECTED_ITEM1, 'should get the first item immediately');

q.next(EXPECTED_ITEM2);
yield new Promise(r => setTimeout(r, DELAY_PERIOD_TIME + 3));
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');

@@ -46,7 +46,7 @@ t.deepEqual(spy.firstCall.args[0], EXPECTED_ITEM2, 'should get the EXPECTED_ITEM2');

q.next(EXPECTED_ITEM2);
yield new Promise(r => setTimeout(r, DELAY_PERIOD_TIME + 3));
yield new Promise(resolve => setTimeout(resolve, DELAY_PERIOD_TIME + 3));
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');
yield new Promise(r => setTimeout(r, DELAY_PERIOD_TIME + 3));
yield new Promise(resolve => setTimeout(resolve, DELAY_PERIOD_TIME + 3));
t.ok(spy.calledTwice, 'should be called twice after the DELAY_PERIOD_TIME');

@@ -53,0 +53,0 @@ t.deepEqual(spy.secondCall.args[0], EXPECTED_ITEM3, 'should get EXPECTED_ITEM3');

@@ -36,9 +36,9 @@ #!/usr/bin/env ts-node

t.equal(spy.firstCall.args[0], EXPECTED_VAL1, 'should get EXPECTED_VAL1');
yield new Promise(r => setTimeout(r, DELAY_PERIOD_TIME + 3));
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');
yield new Promise(r => setTimeout(r, DELAY_PERIOD_TIME + 3));
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');
yield new Promise(r => setTimeout(r, DELAY_PERIOD_TIME + 3));
yield new Promise(resolve => setTimeout(resolve, DELAY_PERIOD_TIME + 3));
t.ok(spy.calledThrice, 'should keep third call...');

@@ -45,0 +45,0 @@ }));

@@ -34,3 +34,3 @@ #!/usr/bin/env ts-node

t.deepEqual(spy.firstCall.args[0], EXPECTED_ITEM1, 'should get the first item only');
yield new Promise(r => setTimeout(r, DELAY_PERIOD_TIME + 3));
yield new Promise(resolve => setTimeout(resolve, DELAY_PERIOD_TIME + 3));
t.ok(spy.calledTwice, 'should get the second item after period delay');

@@ -45,5 +45,5 @@ }));

q.next(EXPECTED_ITEM3);
yield new Promise(r => setTimeout(r, DELAY_PERIOD_TIME + 3));
yield new Promise(resolve => setTimeout(resolve, DELAY_PERIOD_TIME + 3));
t.ok(spy.calledTwice, 'get second item after period');
yield new Promise(r => setTimeout(r, DELAY_PERIOD_TIME + 3));
yield new Promise(resolve => setTimeout(resolve, DELAY_PERIOD_TIME + 3));
t.ok(spy.calledThrice, 'should get the third item after 2 x period');

@@ -50,0 +50,0 @@ t.deepEqual(spy.thirdCall.args[0], EXPECTED_ITEM3, 'should received EXPECTED_ITEM3 after 2 x period');

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

import { DelayQueueExecutor } from './delay-queue-executor';
export { DebounceQueue } from './debounce-queue';

@@ -5,3 +6,3 @@ export { DelayQueue } from './delay-queue';

export { ThrottleQueue } from './throttle-queue';
import { DelayQueueExecutor } from './delay-queue-executor';
export { VERSION } from './version';
export { DelayQueueExecutor, DelayQueueExecutor as DelayQueueExector, };

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

import { DelayQueueExecutor } from './delay-queue-executor';
export { DebounceQueue } from './debounce-queue';

@@ -5,3 +6,3 @@ export { DelayQueue } from './delay-queue';

export { ThrottleQueue } from './throttle-queue';
import { DelayQueueExecutor } from './delay-queue-executor';
export { VERSION } from './version';
export { DelayQueueExecutor,

@@ -8,0 +9,0 @@ // Bug compatible with ISSUE #40

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

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

@@ -22,0 +22,0 @@ next(item) {

@@ -34,3 +34,3 @@ #!/usr/bin/env ts-node

t.deepEqual(spy.firstCall.args[0], EXPECTED_ITEM1, 'should get the first item');
yield new Promise(r => setTimeout(r, THROTTLE_PERIOD_TIME + 3));
yield new Promise(resolve => setTimeout(resolve, THROTTLE_PERIOD_TIME + 3));
t.ok(spy.calledOnce, 'should drop the second call after period because of throttle');

@@ -44,3 +44,3 @@ }));

q.next(EXPECTED_ITEM2);
yield new Promise(r => setTimeout(r, THROTTLE_PERIOD_TIME + 3));
yield new Promise(resolve => setTimeout(resolve, THROTTLE_PERIOD_TIME + 3));
q.next(EXPECTED_ITEM3);

@@ -47,0 +47,0 @@ t.ok(spy.calledTwice, 'should received the third item after THROTTLE_TIME');

{
"name": "rx-queue",
"version": "0.8.2",
"version": "0.8.4",
"description": "Easy to Use ReactiveX Queue that Supports Delay/DelayExecutor/Throttle/Debounce Features Powered by RxJS.",

@@ -12,8 +12,9 @@ "main": "bundles/rx-queue.umd.js",

"build": "tsc --module es6 && shx cp package.json dist/",
"lint": "npm run lint:ts",
"lint": "npm run lint:es && npm run lint:ts",
"rollup": "rollup -c",
"lint:ts": "tslint --project tsconfig.json && tsc --noEmit",
"lint:ts": "tsc --noEmit",
"test": "npm run lint && npm run test:unit",
"test:unit": "blue-tape -r ts-node/register \"src/**/*.spec.ts\" \"tests/**/*.spec.ts\"",
"test:pack": "bash -x scripts/npm-pack-testing.sh"
"test:pack": "bash -x scripts/npm-pack-testing.sh",
"lint:es": "eslint --ignore-pattern fixtures/ 'src/**/*.ts' 'tests/**/*.ts'"
},

@@ -45,20 +46,15 @@ "repository": {

"devDependencies": {
"@types/blue-tape": "^0.1.33",
"@types/node": "^12.0.0",
"@types/semver": "^6.0.0",
"@chatie/eslint-config": "^0.6.18",
"@chatie/git-scripts": "^0.2.5",
"@chatie/semver": "^0.4.7",
"@chatie/tsconfig": "^0.6.1",
"@types/sinon": "^7.0.0",
"blue-tape": "^1.0.0",
"brolog": "^1.2",
"git-scripts": "git+https://github.com/nkzawa/git-scripts.git",
"pkg-jq": "^0.2.4",
"rollup": "^1.0.1",
"rollup-plugin-json": "^4.0.0",
"rxjs": "^6.5.2",
"semver": "^6.0.0",
"shx": "^0.3.0",
"sinon": "^7.1.1",
"source-map-support": "^0.5.0",
"ts-node": "^8.0.3",
"tslint": "^5.11.0",
"tslint-config-standard": "^8.0.1",
"typescript": "^3.1.0-dev.20180915"
"tstest": "^0.4.2"
},

@@ -73,11 +69,12 @@ "files": [

],
"publishConfig": {
"access": "public",
"tag": "latest"
},
"dependencies": {},
"git": {
"scripts": {
"pre-push": "bash scripts/pre-push.sh"
"pre-push": "npx git-scripts-pre-push"
}
},
"publishConfig": {
"access": "public",
"tag": "latest"
}
}
}

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

import { version } from '../package.json'
export let VERSION = version
export { VERSION } from './version'

@@ -24,3 +24,3 @@ #!/usr/bin/env ts-node

await new Promise(r => setTimeout(r, DELAY_PERIOD_TIME + 3))
await new Promise(resolve => setTimeout(resolve, DELAY_PERIOD_TIME + 3))
t.ok(spy.calledOnce, 'should be called after the DELAY_PERIOD_TIME')

@@ -39,3 +39,3 @@ t.deepEqual(spy.firstCall.args[0], EXPECTED_ITEM1, 'should get the first item immediately')

await new Promise(r => setTimeout(r, DELAY_PERIOD_TIME + 3))
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')

@@ -54,3 +54,3 @@ t.deepEqual(spy.firstCall.args[0], EXPECTED_ITEM2, 'should get the EXPECTED_ITEM2')

await new Promise(r => setTimeout(r, DELAY_PERIOD_TIME + 3))
await new Promise(resolve => setTimeout(resolve, DELAY_PERIOD_TIME + 3))

@@ -61,5 +61,5 @@ q.next(EXPECTED_ITEM3)

await new Promise(r => setTimeout(r, DELAY_PERIOD_TIME + 3))
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')
})

@@ -18,2 +18,3 @@ import {

export class DebounceQueue<T = any> extends RxQueue<T> {
private subscription : Subscription

@@ -35,3 +36,3 @@ private subject : Subject<T>

)
.subscribe((item: T) => super.next(item))
.subscribe((item: T) => super.next(item))
}

@@ -47,4 +48,5 @@

}
}
export default DebounceQueue

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

delay
.execute(() => spy(EXPECTED_VAL1))
.catch(() => { /* */ })
.execute(() => spy(EXPECTED_VAL1))
.catch(() => { /* */ })

@@ -43,11 +43,11 @@ t.ok(spy.calledOnce, 'should received 1 call immediately')

await new Promise(r => setTimeout(r, DELAY_PERIOD_TIME + 3))
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')
await new Promise(r => setTimeout(r, DELAY_PERIOD_TIME + 3))
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')
await new Promise(r => setTimeout(r, DELAY_PERIOD_TIME + 3))
await new Promise(resolve => setTimeout(resolve, DELAY_PERIOD_TIME + 3))
t.ok(spy.calledThrice, 'should keep third call...')

@@ -54,0 +54,0 @@ })

@@ -15,2 +15,3 @@ import { Subscription } from 'rxjs'

export class DelayQueueExecutor<T = any> extends DelayQueue<ExecutionUnit<T>> {
private readonly delayQueueSubscription: Subscription

@@ -56,4 +57,5 @@

}
}
export default DelayQueueExecutor

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

await new Promise(r => setTimeout(r, DELAY_PERIOD_TIME + 3))
await new Promise(resolve => setTimeout(resolve, DELAY_PERIOD_TIME + 3))
t.ok(spy.calledTwice, 'should get the second item after period delay')

@@ -54,8 +54,8 @@ })

await new Promise(r => setTimeout(r, DELAY_PERIOD_TIME + 3))
await new Promise(resolve => setTimeout(resolve, DELAY_PERIOD_TIME + 3))
t.ok(spy.calledTwice, 'get second item after period')
await new Promise(r => setTimeout(r, DELAY_PERIOD_TIME + 3))
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')
})

@@ -20,2 +20,3 @@ import {

export class DelayQueue<T = any> extends RxQueue<T> {
private subscription : Subscription

@@ -50,4 +51,5 @@ private subject : Subject<T>

}
}
export default DelayQueue

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

import { DelayQueueExecutor } from './delay-queue-executor'
export { DebounceQueue } from './debounce-queue'

@@ -6,3 +8,3 @@ export { DelayQueue } from './delay-queue'

import { DelayQueueExecutor } from './delay-queue-executor'
export { VERSION } from './version'

@@ -9,0 +11,0 @@ export {

@@ -16,2 +16,3 @@ import {

export class RxQueue<T = any> extends Subject<T> {
private itemList: T[] = []

@@ -57,4 +58,5 @@

}
}
export default RxQueue

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

await new Promise(r => setTimeout(r, THROTTLE_PERIOD_TIME + 3))
await new Promise(resolve => setTimeout(resolve, THROTTLE_PERIOD_TIME + 3))
t.ok(spy.calledOnce, 'should drop the second call after period because of throttle')

@@ -53,3 +53,3 @@ })

await new Promise(r => setTimeout(r, THROTTLE_PERIOD_TIME + 3))
await new Promise(resolve => setTimeout(resolve, THROTTLE_PERIOD_TIME + 3))

@@ -56,0 +56,0 @@ q.next(EXPECTED_ITEM3)

@@ -20,2 +20,3 @@ import {

export class ThrottleQueue<T = any> extends RxQueue<T> {
private subscription : Subscription

@@ -35,3 +36,3 @@ private subject : Subject<T>

this.subscription = this.subject.pipe(
throttle(_ => interval(this.period)),
throttle(() => interval(this.period)),
).subscribe((item: T) => super.next(item))

@@ -48,4 +49,5 @@ }

}
}
export default ThrottleQueue

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