Comparing version 0.0.1 to 0.0.2
14
kgo.js
var run = require('./run'), | ||
fnRegex = /^function\s+?([_\$a-zA-Z][_\$a-zA-Z0-9]*?)\s*\((.*?)\)/; | ||
fnRegex = /^function.*?\((.*?)\)/; | ||
@@ -9,11 +9,15 @@ function newKgo(){ | ||
function kgoFn(fn){ | ||
function kgoFn(name, fn){ | ||
if(typeof name === 'function'){ | ||
fn = name; | ||
name = ''; | ||
} | ||
var details = fnRegex.exec(fn.toString()); | ||
if(!details){ | ||
throw "Functions must have a name"; | ||
throw "Functions must have named arguments"; | ||
} | ||
var name = details[1], | ||
args = details[2].split(','); | ||
var args = details[1].split(','); | ||
@@ -20,0 +24,0 @@ // We don't care about the callback |
{ | ||
"name": "kgo", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Flow control the super easy way", | ||
@@ -5,0 +5,0 @@ "main": "kgo.js", |
@@ -26,3 +26,3 @@ kgo | ||
kgo(function things(cb){ | ||
kgo('things', function(cb){ | ||
@@ -34,3 +34,3 @@ //Something async | ||
})(function stuff(cb){ | ||
})('stuff', function(cb){ | ||
@@ -42,3 +42,3 @@ //Something async | ||
})(function whatsits(things, stuff, cb){ | ||
})('whatsits', function(things, stuff, cb){ | ||
@@ -50,3 +50,3 @@ //Something async | ||
})(function dooby(things, cb){ | ||
})('dooby', function(things, cb){ | ||
@@ -58,3 +58,3 @@ //Something async | ||
})(function majigger(whatsits, dooby, cb){ | ||
})(function(whatsits, dooby, cb){ | ||
@@ -70,3 +70,3 @@ //Done | ||
kgo toStrings the functions, figures out their names, and parameters, stirs over high heat, adds eye of newt and then profit. | ||
kgo toStrings the functions, figures out their parameters, stirs over high heat, adds eye of newt and then profit. | ||
@@ -77,7 +77,7 @@ USE WITH CAUTION! | ||
Yeah them anoying things. | ||
Yeah them annoying things. | ||
You can assign error handlers to your functions by name, if you want to. | ||
kgo(function things(cb){ | ||
kgo('things', function(cb){ | ||
@@ -89,3 +89,3 @@ //Something async | ||
})(function stuff(cb){ | ||
})('stuff', function(cb){ | ||
@@ -97,3 +97,3 @@ //Something async | ||
})(function whatsits(things, stuff, cb){ | ||
})(function(things, stuff, cb){ | ||
@@ -107,5 +107,5 @@ //Something async | ||
}).errors({ | ||
"stuff":function(error){ | ||
'stuff':function(error){ | ||
// will recieve the Whoops error. | ||
} | ||
}); |
10
test.js
var kgo = require('./kgo'); | ||
kgo(function things(cb){ | ||
kgo('things', function(cb){ | ||
setTimeout(function(){ | ||
cb(null, 1); | ||
}, 100); | ||
})(function stuff(cb){ | ||
})('stuff', function(cb){ | ||
setTimeout(function(){ | ||
cb(null, 2); | ||
}, 100); | ||
})(function whatsits(things, stuff, cb){ | ||
})('whatsits', function(things, stuff, cb){ | ||
setTimeout(function(){ | ||
cb(null, things + stuff); | ||
}, 100); | ||
})(function dooby(things, cb){ | ||
})('dooby', function(things, cb){ | ||
setTimeout(function(){ | ||
cb(null, things/2); | ||
}, 100); | ||
})(function majigger(whatsits, dooby, cb){ | ||
})(function(whatsits, dooby, cb){ | ||
console.log(whatsits, dooby); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7000
174