Last active
December 28, 2015 19:29
-
-
Save predic8/7550619 to your computer and use it in GitHub Desktop.
Sample for underscore.js's wrap function node wrap-demo.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var _ = require('underscore'); | |
var niceAlert = _.wrap( console.log, function() { | |
var args = _.toArray(arguments); | |
var fn = _.first(args); | |
var rest = _.rest(args); | |
rest = _.map(rest, function(s) { | |
if (s === 'f*ck') s = 'Well'; | |
return s; | |
}); | |
fn.apply(this, rest); | |
} ); | |
niceAlert('f*ck'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment