Comparing version 0.0.1 to 0.0.2
@@ -1,2 +0,2 @@ | ||
var chaotic = require('./index')(0.1); | ||
var chaotic = require('./index')(); | ||
@@ -16,7 +16,6 @@ function callback(err, res) { | ||
var fun = chaotic(callback); | ||
var funTimes = [ | ||
wrap(fun, null, "ok"), | ||
wrap(fun, null, "win") | ||
wrap(chaotic(0.9, callback), null, "probably fails"), | ||
wrap(chaotic(0.1, callback), null, "probably succeeds"), | ||
wrap(chaotic(0.5, callback), new Error("normal error"), "definitely fails, but what kind?") | ||
]; | ||
@@ -23,0 +22,0 @@ |
13
index.js
@@ -7,7 +7,12 @@ var assert = require('assert'); | ||
function toss() { | ||
return Math.random() > 1-rate; | ||
function toss(r) { | ||
assert(r < 1 && r > 0, 'rate'); | ||
return Math.random() > 1-r; | ||
} | ||
return function fuck(cb) { | ||
return function fuck(r, cb) { | ||
if (typeof r === 'function') { | ||
cb = r; | ||
r = rate; | ||
} | ||
return function () { | ||
@@ -17,3 +22,3 @@ cb.apply( | ||
[].concat( | ||
toss() ? new Error("murphy's law") : arguments[0], | ||
toss(r) ? new Error("murphy's law") : arguments[0], | ||
[].slice.call(arguments, 1) | ||
@@ -20,0 +25,0 @@ ) |
{ | ||
"name": "chaotic-cb", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "introduce chaos to callbacks (inject errors occasionally)", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -12,2 +12,5 @@ # SYNOPSIS | ||
cb(null, "testing..."); | ||
var cb = chaos(0.9, function(err, res) { console.log(err?err:res); }); | ||
cb(null, "I probably won't happen..."); | ||
``` | ||
@@ -14,0 +17,0 @@ |
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
3162
44
19