Created
April 3, 2018 15:31
-
-
Save IhostVlad/4e6ac3e60097fb8a44b4612211ea8d61 to your computer and use it in GitHub Desktop.
SafeInvokeFs
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
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