Skip to content

Instantly share code, notes, and snippets.

@evinism
Created October 17, 2021 23:03
Show Gist options
  • Save evinism/2ad57ce2690387950085f3e9430f6de3 to your computer and use it in GitHub Desktop.
Save evinism/2ad57ce2690387950085f3e9430f6de3 to your computer and use it in GitHub Desktop.
cjsp4
function uncomment(fn){
const body = fn.toString().replace(/\/\//, '');
return new Function(`return (${body})(...arguments)`);
}
function fn(a){
// return a + 1;
return a
}
fn(1) // returns 1
uncomment(fn)(1) // returns 2!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment