Skip to content

Instantly share code, notes, and snippets.

@IhostVlad
Created April 3, 2018 15:31
Show Gist options
  • Save IhostVlad/4e6ac3e60097fb8a44b4612211ea8d61 to your computer and use it in GitHub Desktop.
Save IhostVlad/4e6ac3e60097fb8a44b4612211ea8d61 to your computer and use it in GitHub Desktop.
SafeInvokeFs
const safeInvokeFs = (funcName, ...args) =>
new Function(
'context',
`try {
return require('fs')[context.funcName].apply(null, context.args)
} catch(err) {}`
)({ funcName, args })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment