Last active
December 10, 2015 18:29
-
-
Save manuelbieh/4475118 to your computer and use it in GitHub Desktop.
Make private functions public for testing
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
function foo() { | |
var _private = function() { | |
return 'myPrivateFunction'; | |
}; | |
return { | |
foobar: function() { | |
return 'foobar' + _private(); | |
}, | |
barfoo: function() { | |
return 'barfoo' + _private(); | |
} | |
/* strip-start */, _testExpose: function(test) {return eval(test);}/* strip-end */ | |
} | |
}; | |
var example = new foo(); | |
console.log(example._testExpose('_private()')); | |
// in your build script: | |
// myfile = myfile.replace(/\/\* strip-start (.*) strip-end \*\//gi, ''); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment