{"id":20442654,"url":"https://github.com/tgorka/node-window-polyfill","last_synced_at":"2025-04-12T23:43:44.414Z","repository":{"id":40798687,"uuid":"130678797","full_name":"tgorka/node-window-polyfill","owner":"tgorka","description":"Polyfill for the problem 'window is not defined' in node.js","archived":false,"fork":false,"pushed_at":"2025-01-06T04:27:38.000Z","size":843,"stargazers_count":9,"open_issues_count":10,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T23:43:38.644Z","etag":null,"topics":["es6","javascript","nodejs","polyfill","typescript","websocket","window","yarn"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tgorka.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-04-23T10:18:01.000Z","updated_at":"2025-02-04T20:11:40.000Z","dependencies_parsed_at":"2025-01-18T06:31:53.452Z","dependency_job_id":"12292561-33c7-4627-8e7a-ab7794bd7cf5","html_url":"https://github.com/tgorka/node-window-polyfill","commit_stats":{"total_commits":29,"total_committers":4,"mean_commits":7.25,"dds":"0.24137931034482762","last_synced_commit":"ed60a3d02171cf5649264d180d9e947e882583bc"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tgorka%2Fnode-window-polyfill","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tgorka%2Fnode-window-polyfill/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tgorka%2Fnode-window-polyfill/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tgorka%2Fnode-window-polyfill/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tgorka","download_url":"https://codeload.github.com/tgorka/node-window-polyfill/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248647256,"owners_count":21139081,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["es6","javascript","nodejs","polyfill","typescript","websocket","window","yarn"],"created_at":"2024-11-15T09:42:22.577Z","updated_at":"2025-04-12T23:43:44.382Z","avatar_url":"https://github.com/tgorka.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# node-window-polyfill\n\n[![Version npm](https://img.shields.io/npm/v/node-window-polyfill.svg)](https://www.npmjs.com/package/node-window-polyfill)\n\nPolyfill for the problem `window is not defined` in node.js.\nIt's inserting window object on globals \nand inputing all needed sub-elements \nwith requiring web sockets dependency.\n\n## Installation\n\nYarn\n```\nyarn add node-window-polyfill\n```\n\nNpm\n```\nnpm install node-window-polyfill\n```\n\n### Requirements \nMinimum ES5.\n\nTo use it in different environment it's required to clone and build it with the proper flag.\n\n## Usage\n\nImport it in global file, or in every file \nwhere the source code requires the `window` object.\n\n```typescript\nimport nodeWindowPolyfill from \"node-window-polyfill\";\n\nnodeWindowPolyfill.register();\n```\n\nFor shorter import that will call register directrly\n```typescript\nimport \"node-window-polyfill/register\";\n```\n\nIf you don't want to import 'ws' module and just create empty objects:\n```typescript\nimport nodeWindowPolyfill from \"node-window-polyfill\";\n\nnodeWindowPolyfill.register(false);\n```\n\nAnd the version previous ES versions:\n```javascript\nrequire('node-window-polyfill').register();\n```\n\n## What is polyfilled?\n\n- usage of `window` in the code or libraries\n- `window.setTimeout` - default `setTimeout` node function\n- `window.clearTimeout` - default `clearTimeout` node function\n- `window.WebSocket` - version from global object \n- `window.ArrayBuffer` - version from global object only\n- `window.addEventListener` - empty void function\n- `window.navigator` - `{ onLine: true }`\n- `window.isNodeJS` - to check if polyfills were aplied\n- `window.localStorage` - in memory storage\n- `window.Date` - version from global object\n- `global.WebSocket` - using [ws](https://www.npmjs.com/package/ws) if the right flag is not set\n- if the above functions/properties are already set in the `global` object then they will be taken into the account\n\n## Configure\n\nTo configure development environment and run the tests, \nfirst clone the repository:\n\n```\ngit clone https://github.com/tgorka/node-window-polyfill.git\n```\n\nthen (once you have `yarn` and node installed) install dependencies\n\n```\nyarn\n```\n\n## Build\n\nTo build the distribution and types\n\n```\nyarn build\n```\n\nThe distribution is in the `dist` folder and types in the `types` folder.\n\nTo change defauld ES standard use `--target` flag. Ex.:\n```\nyarn build -target es3\n```\n\n## Test\n\nAfter configuring we can run tests.\n\n```\nyarn test\n```\n\nWe can use debug information logging with setting up env variable\n\n```\nDEBUG=nodeWindowPolyfill-* yarn test\n```\n\n## Author\nTomasz Górka \u003chttp://tomasz.gorka.org.pl\u003e\n\n## License\n\u0026copy; 2018 Tomasz Górka\n\nMIT licensed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftgorka%2Fnode-window-polyfill","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftgorka%2Fnode-window-polyfill","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftgorka%2Fnode-window-polyfill/lists"}