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 1.1.3 to 1.2.0

test/index.html

28

kgo.js

@@ -11,5 +11,26 @@ var run = require('./run'),

results = {},
errorHandlers = {};
errorHandlers = {},
inFlight,
defaultsDefined;
function kgoFn(name, dependencies, fn){
if(inFlight){
throw "No tasks or defaults may be set after kgo is in flight";
}
if(arguments.length === 1 && name !== null && typeof name === 'object'){
if(defaultsDefined){
throw "Defaults may be defined only once per kgo";
}
for(var key in name){
if(key in tasks){
throw "A task is already defined for " + key;
}
results[key] = name[key];
}
defaultsDefined = true;
return kgoFn;
}
if(typeof name !== 'string'){

@@ -30,2 +51,6 @@ fn = dependencies;

if(name in results){
throw "A default with the same name as this task (" + name + ") has already been set";
}
tasks[name] = {

@@ -47,2 +72,3 @@ name: name,

defer(function(){
inFlight = true;
run(tasks, results, kgoFn);

@@ -49,0 +75,0 @@ });

{
"name": "kgo",
"version": "1.1.3",
"version": "1.2.0",
"description": "Flow control the super easy way",

@@ -26,4 +26,14 @@ "main": "kgo.js",

"testling": {
"files": "./test/index.js"
"files": "./test/index.js",
"browsers": [
"ie/6..latest",
"chrome/22..latest",
"firefox/16..latest",
"safari/latest",
"opera/11.0..latest",
"iphone/6",
"ipad/6",
"android-browser/latest"
]
}
}

@@ -118,2 +118,32 @@ kgo

## Defaults
You can define default data for use in later tasks by passing an object into kgo, where the keys in the objects will map to dependency names:
kgo
({
foo: 1
})
('bar', function(done){
done(null, 2);
});
('baz', ['foo', 'bar'], function(foo, bar, done){
})
This is especially useful when you want to use named functions that need additional parameters to run:
var fs = require('fs');
kgo
({
'sourcePath': '/foo/bar'
})
('files', ['sourcePath'], fs.readdir)
### Note: You may only define defaults once in a kgo block. Extra calls will result in an error.
## Errors

@@ -120,0 +150,0 @@

@@ -115,2 +115,69 @@ var test = require('grape'),

})
});
test('defaults', function(t){
t.plan(2);
kgo
({
things: 1,
stuff: 2
})
(['things', 'stuff'], function(things, stuff, done){
t.equal(things, 1);
t.equal(stuff, 2);
});
});
test('defaults with same taskname', function(t){
t.plan(1);
t.throws(function(){
kgo
({
things: 1,
stuff: 2
})
('stuff', function(done){
doAsync(done, null, 2);
})
(['things', 'stuff'], function(things, stuff, done){
t.fail('task ran but should not have');
});
}, 'cannot define a task with the same name as that of a default');
});
test('defaults with same taskname, after task', function(t){
t.plan(1);
t.throws(function(){
kgo
('stuff', function(done){
doAsync(done, null, 2);
})
({
things: 1,
stuff: 2
})
(['things', 'stuff'], function(things, stuff, done){
t.fail('task ran but should not have');
});
}, 'set defaults containing a key that conflicts with a task name');
});
test('double defaults', function(t){
t.plan(1);
t.throws(function(){
kgo
({
things: 1
})
({
stuff: 2
})
(['things', 'stuff'], function(things, stuff, done){
t.fail('task ran but should not have');
});
}, 'cannot define defaults twice');
});

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