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

qjobs

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

qjobs - npm Package Compare versions

Comparing version

to
1.1.2

tests/pause.js

2

package.json
{
"name": "qjobs",
"version": "1.1.1",
"version": "1.1.2",
"description": "qjobs is a simple and stupid queue job manager for nodejs",

@@ -5,0 +5,0 @@ "main": "qjobs.js",

@@ -181,10 +181,12 @@ var util = require('util');

clearInterval(this.pausedId);
self.emit('unpause');
this.run();
}
if (this.paused && !this.pausedId) {
this.lastPause = Date.now();
self.lastPause = Date.now();
this.pausedId = setInterval(function() {
var since = Date.now() - lastPause;
self.emit('inPause',since);
var since = Date.now() - self.lastPause;
self.emit('pause',since);
},1000);
return;
}

@@ -191,0 +193,0 @@ }

@@ -36,3 +36,5 @@ [![Build Status](https://secure.travis-ci.org/franck34/qjobs.png)](http://travis-ci.org/franck34/qjobs)

```
// My non blocking main job
var qjobs = new require('./qjobs');
// My non blocking main job
var myjob = function(args,next) {

@@ -45,34 +47,31 @@ setTimeout(function() {

// qjobs stuff
var q = new qjobs({maxConcurrency:10});
var myQueueJobs = new require('qjobs');
// Let's add 30 job to the queue
for (var i = 0; i<30; i++) {
myQueueJobs.add(myjob,[i,'test '+i]);
q.add(myjob,[i,'test '+i]);
}
// Initialize all events
myQueueJobs.on('start',function() {
q.on('start',function() {
console.log('Starting ...');
});
myQueueJobs.on('end',function() {
q.on('end',function() {
console.log('... All jobs done');
});
myQueueJobs.on('jobStart',function(args) {
q.on('jobStart',function(args) {
console.log('jobStart',args);
});
myQueueJobs.on('jobEnd',function(args) {
q.on('jobEnd',function(args) {
console.log('jobend',args);
// If i'm jobId 10, then make a pause of 5 sec
if (args._jobId == 10) {
myQueueJobs.pause(true);
q.pause(true);
setTimeout(function() {
myQueueJobs.pause(false);
q.pause(false);
},5000);

@@ -82,11 +81,12 @@ }

// I want to know if queue is in pause every sec
myQueueJobs.on('inPause',function(since) {
q.on('pause',function(since) {
console.log('in pause since '+since+' milliseconds');
});
q.on('unpause',function() {
console.log('pause end, continu ..');
});
// JOBS !! leeeeeeeeeet's staaaaaaaart !
myQueueJobs.run();
q.run();
```