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

riverjs-event-sequence

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

riverjs-event-sequence - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

.travis.yml

31

lib/parallel.js

@@ -5,13 +5,15 @@ function parallel(){

}
parallel.prototype.push = Array.prototype.push;
parallel.prototype.shift = Array.prototype.shift;
parallel.prototype.forEach = Array.prototype.forEach;
parallel.prototype.update = update;
parallel.prototype.exec = exec;
parallel.prototype.on = on;
parallel.prototype.emmit = emmit;
parallel.prototype.push = Array.prototype.push;
parallel.prototype.shift = Array.prototype.shift;
parallel.prototype.forEach = Array.prototype.forEach;
parallel.prototype.update = update;
parallel.prototype.exec = exec;
parallel.prototype.on = on;
parallel.prototype.emmit = emmit;
function exec(){
var args = arguments;
var me = this;
this.forEach(function(task,index){
task();
task.apply(me,args);
});

@@ -21,8 +23,8 @@ }

function update(){
var scope = this;
var me = this;
var caller = arguments.callee.caller;
scope.completeTasks.push(caller);
scope.emmit('process',scope.completeTasks);
if(scope.completeTasks.length === scope.length){
scope.emmit('end',scope.completeTasks);
me.completeTasks.push(caller);
me.emmit('process',me.completeTasks);
if(me.completeTasks.length === me.length){
me.emmit('end',me.completeTasks);
}

@@ -41,5 +43,6 @@ }

var args =Array.prototype.slice.call(arguments,1);
var me = this;
if(is('Array',this.listeners[id])){
this.listeners[id].forEach(function(listener,index){
listeners.apply({},args);
listeners.apply(me,args);
});

@@ -46,0 +49,0 @@ }

@@ -13,3 +13,3 @@ function serial () {

if(task){
task.apply({},arguments);
task.apply(this,arguments);
}

@@ -16,0 +16,0 @@ }

{
"name": "riverjs-event-sequence",
"version": "0.0.3",
"version": "0.0.4",
"description": "a tool for handling serial and parallel asynchronous event quene.",

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

riverjs-event-sequence
======================
[![Build Status](https://travis-ci.org/zhang-ning/riverjs-event-sequence.png?branch=master)](https://travis-ci.org/zhang-ning/riverjs-event-sequence)

@@ -24,2 +25,3 @@ a tool for handling serial and parallel asynchronous event quene.

```
var serial = require('riverjs-event-sequence').serial;
var task1=function(){

@@ -51,2 +53,3 @@ setTimeout(function(){

```
var parallel = require('riverjs-event-sequence').parallel;
var task1 = function (){

@@ -53,0 +56,0 @@ setTimeout(function () {

@@ -5,5 +5,6 @@ var parallel = require('../').parallel;

describe('parallel case',function(){
var task1,task2,task3,data=[],beginTime=Date.now();
var task1,task2,task3,data=[],beginTime=Date.now(),q;
before(function(done){
task1 = function (){
var queue = this;
setTimeout(function () {

@@ -16,2 +17,3 @@ data.push({name:'task1',time:Date.now() - beginTime});

var args = arguments;
var queue = this;
setTimeout(function () {

@@ -24,2 +26,3 @@ data.push({name:'task2',time:Date.now() - beginTime});

var args = arguments;
var queue = this;
setTimeout(function () {

@@ -31,7 +34,7 @@ data.push({name:'task3',time:Date.now() - beginTime});

};
var queue = new parallel();
queue.push(task1);
queue.push(task2);
queue.push(task3);
queue.exec();
q = new parallel();
q.push(task1);
q.push(task2);
q.push(task3);
q.exec();
});

@@ -42,10 +45,15 @@

});
it('#on end event',function(){
q.on('end',function(){
assert(3 === data.length);
});
});
it('#task1 execute time more then 50ms',function(){
assert(data[0].time >= 50);
});
it('#task1 execute time more then 50ms,less then 100ms',function(){
it('#task2 execute time more then 50ms,less then 100ms',function(){
assert(data[1].time >= 50);
assert(data[1].time <= 100);
});
it('#task1 execute time more then 100ms,less then 200ms',function(){
it('#task3 execute time more then 100ms,less then 200ms',function(){
assert(data[2].time >= 100);

@@ -52,0 +60,0 @@ assert(data[2].time <= 200);

@@ -8,2 +8,3 @@ var serial = require('../').serial;

task1 = function (){
var queue=this;
setTimeout(function () {

@@ -16,2 +17,3 @@ data.push({num:'task1'});

var args = arguments;
var queue=this;
setTimeout(function () {

@@ -24,2 +26,3 @@ data.push({num:'task2',args:args});

var args = arguments;
var queue=this;
setTimeout(function () {

@@ -31,7 +34,7 @@ data.push({num:'task3',args:args});

var queue = new serial();
queue.push(task1);
queue.push(task2);
queue.push(task3);
queue.exec();
var q = new serial();
q.push(task1);
q.push(task2);
q.push(task3);
q.exec();
});

@@ -38,0 +41,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