Skip to content

Instantly share code, notes, and snippets.

@mbildner
Created April 3, 2014 18:52
Show Gist options
  • Save mbildner/9960529 to your computer and use it in GitHub Desktop.
Save mbildner/9960529 to your computer and use it in GitHub Desktop.
// During build, delete everything between start and end tags, keeping things safely scoped
// This exists for Grunt, and seems relatively easy to port to Gulp.
// https://github.com/philipwalton/grunt-strip-code/
(function hasPrivateFunctions (window) {
this.isPublicFunction = isPublicFunction;
function isPublicFunction () {
return 'I am a public function';
}
function isPrivateFunction () {
return 'I am a private function';
}
/* start-testing-code-section */
window.testableApiObject.isPrivateFunction = isPrivateFunction;
/* end-testing-code-section */
})(window);
window.isPublicFunction() // 'I am a public function'
window.isPrivateFunction() // TypeError, this is good
window.testableApiObject.isPrivateFunction() // 'I am a private function'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment