Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
node-window-polyfill
Advanced tools
Polyfill for the problem window is not defined
in node.js.
It's inserting window object on globals
and inputing all needed sub-elements
with requiring web sockets dependency.
Yarn
yarn add node-window-polyfill
Npm
npm install node-window-polyfill
Minimum ES5.
To use it in different environment it's required to clone and build it with the proper flag.
Import it in global file, or in every file
where the source code requires the window
object.
import nodeWindowPolyfill from "node-window-polyfill";
nodeWindowPolyfill.register();
For shorter import that will call register directrly
import "node-window-polyfill/register";
If you don't want to import 'ws' module and just create empty objects:
import nodeWindowPolyfill from "node-window-polyfill";
nodeWindowPolyfill.register(false);
And the version previous ES versions:
require('node-window-polyfill').register();
window
in the code or librarieswindow.setTimeout
- default setTimeout
node functionwindow.clearTimeout
- default clearTimeout
node functionwindow.WebSocket
- version from global objectwindow.ArrayBuffer
- version from global object onlywindow.addEventListener
- empty void functionwindow.navigator
- { onLine: true }
window.isNodeJS
- to check if polyfills were apliedwindow.localStorage
- in memory storagewindow.Date
- version from global objectglobal.WebSocket
- using ws if the right flag is not setglobal
object then they will be taken into the accountTo configure development environment and run the tests, first clone the repository:
git clone https://github.com/tgorka/node-window-polyfill.git
then (once you have yarn
and node installed) install dependencies
yarn
To build the distribution and types
yarn build
The distribution is in the dist
folder and types in the types
folder.
To change defauld ES standard use --target
flag. Ex.:
yarn build -target es3
After configuring we can run tests.
yarn test
We can use debug information logging with setting up env variable
DEBUG=nodeWindowPolyfill-* yarn test
Tomasz Górka http://tomasz.gorka.org.pl
© 2018 Tomasz Górka
MIT licensed.
FAQs
Polyfill for the problem `window is not defined` in node.js
The npm package node-window-polyfill receives a total of 1,015 weekly downloads. As such, node-window-polyfill popularity was classified as popular.
We found that node-window-polyfill demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.