Skip to content

Instantly share code, notes, and snippets.

@phiggins42
Last active September 26, 2015 23:48
Show Gist options
  • Save phiggins42/1178619 to your computer and use it in GitHub Desktop.
Save phiggins42/1178619 to your computer and use it in GitHub Desktop.
chaos monkey. If your tests pass with this in page your tests are wrong. or you are very very lucky. buy a lotto ticket.
function jerkify(obj, methods, thres){
methods.forEach(function(meth){
var orig = obj.prototype[meth];
orig && obj.prototype[meth] = function(){
return Math.random() > thres ? orig.apply(this, arguments) : orig.call(this);
}
});
}
jerkify(Array, ["push", "pop", "splice", "slice"], 0.1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment