attempt-export
v1.0.1
Published
Attempt to export something, else export undefined.
Readme
attempt-export
Safely run a function and export its return value, or undefined if it throws.
Installation
npm install attempt-exportUsage
For example, if you want to make a file that exports Symbol if it exists, otherwise undefined:
const attemptExport = require("attempt-export")(module)
const assert = require("assert")
attemptExport(() => {
assert(Symbol.species.constructor === Symbol)
return Symbol
})