Skip to content

Instantly share code, notes, and snippets.

@predic8
Last active December 28, 2015 19:29
Show Gist options
  • Save predic8/7550619 to your computer and use it in GitHub Desktop.
Save predic8/7550619 to your computer and use it in GitHub Desktop.
Sample for underscore.js's wrap function node wrap-demo.js
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