revertable-globals
v4.0.0
Published
Sets globals that can be easily reverted to restore the original environment; useful for testing code that relies on the presence of certain globals.
Downloads
68
Maintainers
Readme
revertable-globals
Sets globals in a JavaScript environment that can be easily reverted to restore the original environment; useful for testing code that relies on the presence of certain globals.
Installation
For Node.js, to install revertable-globals
with npm, run:
npm install revertable-globals --save-dev
For Deno, an example import map:
{
"imports": {
"revertable-globals": "https://unpkg.com/[email protected]/revertableGlobals.mjs"
}
}
Then, import and use the function revertableGlobals
.
Requirements
Supported runtime environments:
Non Deno projects must configure TypeScript to use types from the ECMAScript modules that have a // @ts-check
comment:
compilerOptions.allowJs
should betrue
.compilerOptions.maxNodeModuleJsDepth
should be reasonably large, e.g.10
.compilerOptions.module
should be"node16"
or"nodenext"
.
Exports
The npm package revertable-globals
features optimal JavaScript module design. These ECMAScript modules are exported via the package.json
field exports
: