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

kgo

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kgo - npm Package Compare versions

Comparing version 2.0.2 to 2.0.4

22

kgo.js
var run = require('./run'),
EventEmitter = require('events').EventEmitter,
fnRegex = /^function.*?\((.*?)\)/;
EventEmitter = require('events').EventEmitter;

@@ -11,3 +10,2 @@ var defer = typeof setImmediate === 'function' ? setImmediate : setTimeout;

results = {},
errorHandlers = {},
inFlight,

@@ -17,4 +15,8 @@ defaultsDefined;

function kgoFn(){
if(!arguments.length){
throw new Error('kgo must must be called with a task or defaults');
}
if(inFlight){
throw 'No tasks or defaults may be set after kgo is in flight';
throw new Error('No tasks or defaults may be set after kgo is in flight');
}

@@ -35,3 +37,3 @@

}
if(typeof arguments[argIndex] === 'object' && !Array.isArray(arguments[argIndex])){

@@ -41,3 +43,3 @@ var defaults = arguments[argIndex];

if(defaultsDefined){
throw 'Defaults may be defined only once per kgo';
throw new Error('Defaults may be defined only once per kgo');
}

@@ -47,3 +49,3 @@

if(key in tasks){
throw 'A task is already defined for ' + key;
throw new Error('A task is already defined for ' + key);
}

@@ -71,3 +73,3 @@ results[key] = defaults[key];

if(names[i] in results){
throw 'A default with the same name as this task (' + names[i] + ') has already been set';
throw new Error('A default with the same name as this task (' + names[i] + ') has already been set');
}

@@ -82,3 +84,3 @@ }

if(typeof dependency !== 'string'){
throw 'dependency was not a string: ' + dependency + ' in task: ' + names;
throw new Error('dependency was not a string: ' + dependency + ' in task: ' + names);
}

@@ -89,3 +91,3 @@ });

if(name in tasks){
throw 'A task with the same name (' + name + ') is aready defined';
throw new Error('A task with the same name (' + name + ') is aready defined');
}

@@ -92,0 +94,0 @@

{
"name": "kgo",
"version": "2.0.2",
"version": "2.0.4",
"description": "Flow control the super easy way",

@@ -23,3 +23,2 @@ "main": "kgo.js",

"devDependencies": {
"grape": "^1.0.1",
"tape": "^4.0.0"

@@ -26,0 +25,0 @@ },

var ignoreDependency = /^\!.+/;
function rotate90(array){
// transpose from http://www.codesuck.com/2012/02/transpose-javascript-array-in-one-line.html
return Object.keys(array[0]).map(function (c) { return array.map(function (r) { return r[c]; }); });
}
function Step(task, args, done){

@@ -37,3 +32,2 @@ this._task = task;

dependants = task.args,
taskFunction = task.fn,
args = [];

@@ -119,15 +113,14 @@

function checkDependencyIsDefined(dependencyName){
dependencyName = dependencyName.split('!').pop();
if(!(dependencyName in tasks) && !(dependencyName in results)){
throw new Error('No task or result has been defined for dependency: ' + dependencyName);
}
}
for(var key in tasks){
todo[key] = tasks[key];
emitter._taskCount ++;
}
// check for missing dependencies
for(var key in tasks){
tasks[key].args.map(function(dependencyName){
dependencyName = dependencyName.split('!').pop();
if(!(dependencyName in tasks) && !(dependencyName in results)){
throw 'No task or result has been defined for dependency: ' + dependencyName;
}
});
tasks[key].args.map(checkDependencyIsDefined);
}

@@ -134,0 +127,0 @@

@@ -81,3 +81,3 @@ var test = require('tape'),

})
.on('error', function(error, names){
.on('error', function(){
t.pass();

@@ -274,5 +274,38 @@ })

(['foo', ['bar']], function(){});
},
},
/dependency was not a string: bar in task: 0__returnless/
);
});
test('task with missing dependency', function(t){
t.plan(2);
var d = require('domain').create();
d.on('error', function(error){
t.ok(error instanceof Error, 'error is instance of Error');
t.equal(error.message, 'No task or result has been defined for dependency: foo');
});
d.run(function(){
kgo
(['foo'], function(){});
});
});
test('must have argmuents', function(t){
t.plan(2);
t.throws(
function(){
kgo();
},
/kgo must must be called with a task or defaults/
);
t.throws(
function(){
kgo({})();
},
/kgo must must be called with a task or defaults/
);
});
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