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

tress

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tress - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

12

index.js

@@ -43,3 +43,3 @@ function Tress(worker, concurrency){ // function worker(job, done)

setTimeout(worker, delayable ? _delay : 0, job.data, function(err, ...args){
setTimeout(worker, delayable ? _delay : 0, job.data, (err, ...args) => {
if(doneCalled){

@@ -51,6 +51,2 @@ throw new Error('Too many callback calls in worker');

_queue.active = _queue.active.filter(v => v !== job);
if(_queue.active.length <= _concurrency - this.buffer && _saturated){
_saturated = false;
_onUnsaturated();
}
if(typeof err === 'boolean'){

@@ -61,6 +57,10 @@ _queue.waiting[err ? 'unshift' : 'push'](job);

_queue[err ? 'failed' : 'finished'].push(job);
if(job.callback) job.callback.call(job.data, err, ...args);
job.callback.call(job.data, err, ...args);
if(err) _onError.call(job.data, err, ...args);
if(!err) _onSuccess.call(job.data, ...args);
}
if(_queue.active.length <= _concurrency - _buffer && _saturated){
_saturated = false;
_onUnsaturated();
}
_startJob(true);

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

{
"name": "tress",
"version": "1.1.0",
"version": "1.1.1",
"description": "Easy to use asynchronous job queue. Successor of 'caolan/async.queue'.",

@@ -8,3 +8,3 @@ "main": "index.js",

"scripts": {
"test": "eslint . && ava"
"test": "eslint . && nyc ava -v"
},

@@ -21,3 +21,4 @@ "repository": {

"eslint": "^4.7.2",
"eslint-config-astur": "0.0.2"
"eslint-config-astur": "0.0.2",
"nyc": "^12.0.2"
},

@@ -24,0 +25,0 @@ "keywords": [

@@ -150,3 +150,6 @@ const test = require('ava');

q.push('*'.repeat(50).split(''));
q.concurrency = -10;
t.is(q.concurrency, -10);
q.concurrency = 10;
t.is(q.concurrency, 10);
});

@@ -175,2 +178,7 @@

t.throws(() => q.push(1, 1));
t.throws(() => q.push());
t.throws(() => q.push(() => {}));
t.throws(() => q.unshift(1, 1));
t.throws(() => q.unshift());
t.throws(() => q.unshift(() => {}));
t.throws(() => {

@@ -227,2 +235,3 @@ q.drain = 1;

t.false(q.paused);
t.is(q.status('ugly'), 'missing');
});

@@ -307,3 +316,5 @@

});
q.buffer = 0.5;
t.is(q.buffer, 1);
q.buffer = 2;
t.is(q.buffer, 2);
q.saturated = () => {

@@ -327,5 +338,2 @@ t.is(q.active.length, 4);

const q = tress((job, done) => done(null));
q.drain = () => {
t.end();
};
q.load({waiting: [1, 2, 3]});

@@ -335,17 +343,29 @@ t.throws(() => {

});
const qq = tress((job, done) => done(null));
qq.pause();
qq.load({failed: [1], finished: [2]});
t.true(qq.paused);
qq.resume();
setTimeout(() => t.end(), 20);
});
test.cb('save', t => {
const q = tress((job, done) => done(null));
q.pause();
const q = tress((job, done) => {
if(job === 'foo'){
return done(new Error());
} else if(job === 'bar'){
done(null); // eslint-disable-line
q.save(dump => {
t.deepEqual(dump, {
waiting: ['baz'],
finished: ['bar'],
failed: ['foo'],
});
t.end();
});
} else {
return done(null);
}
});
q.push(['foo', 'bar', 'baz']);
q.save(dump => {
t.deepEqual(dump, {
waiting: ['foo', 'bar', 'baz'],
finished: [],
failed: [],
});
t.end();
});
q.resume();
});

@@ -352,0 +372,0 @@

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