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

chaotic-cb

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chaotic-cb - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

9

example.js

@@ -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 @@

@@ -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 @@

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