Last active
August 29, 2015 13:55
-
-
Save SohumB/8699077 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 fs = require('fs'); | |
// then | |
hug(null, fs.writeFileSync, 'filename', 'data') | |
// should return the following function: | |
function() { | |
fs.writeFileSync('filename', 'data'); | |
} | |
// except we need to "preserve" context | |
// so if the first argument is null, then we're actually returning: | |
function() { | |
var fn = fs.writeFileSync.bind(null); | |
fn('filename', 'data'); | |
} | |
// ideally we'd want a version that doesn't need the scope argument at all | |
// but I'm pretty sure that's impossible in javascript | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment