{"_id":"window-or-global","_rev":"2795661","name":"window-or-global","description":"Use either the window object in the browser or the global object in node.","dist-tags":{"latest":"1.0.1"},"maintainers":[{"name":"oroce","email":"robert@oroszi.net"},{"name":"ruffle1986","email":"ftamas.mail@gmail.com"}],"time":{"modified":"2022-07-12T09:43:50.000Z","created":"2015-09-16T13:17:33.133Z","1.0.1":"2015-09-16T16:05:07.663Z","1.0.0":"2015-09-16T13:17:33.133Z"},"users":{},"author":{"name":"ruffle1986","email":"tf@purposeindustries.co"},"repository":{"type":"git","url":"git+https://github.com/purposeindustries/window-or-global.git"},"versions":{"1.0.1":{"name":"window-or-global","version":"1.0.1","description":"Use either the window object in the browser or the global object in node.","license":"MIT","repository":{"type":"git","url":"git+https://github.com/purposeindustries/window-or-global.git"},"author":{"name":"ruffle1986","email":"tf@purposeindustries.co"},"main":"./lib/index.js","scripts":{"test":"xo","posttest":"ava examples/**/*.spec.js"},"xo":{"envs":["node","browser"],"space":true,"semicolon":false},"files":["lib"],"keywords":["window","global","isomorphic","universal"],"devDependencies":{"ava":"^0.2.0","browserify":"^11.1.0","component-emitter":"^1.2.0","jsdom":"^6.5.0","proxyquire":"^1.7.2","react":"^0.13.3","xo":"*"},"dependencies":{},"gitHead":"3a2f8bd7a3553b359b0c34c2e622249e0902633b","bugs":{"url":"https://github.com/purposeindustries/window-or-global/issues"},"homepage":"https://github.com/purposeindustries/window-or-global#readme","_id":"window-or-global@1.0.1","_shasum":"dbe45ba2a291aabc56d62cf66c45b7fa322946de","_from":".","_npmVersion":"2.13.3","_nodeVersion":"3.2.0","_npmUser":{"name":"ruffle1986","email":"ftamas.mail@gmail.com"},"maintainers":[{"name":"oroce","email":"robert@oroszi.net"},{"name":"ruffle1986","email":"ftamas.mail@gmail.com"}],"dist":{"shasum":"dbe45ba2a291aabc56d62cf66c45b7fa322946de","size":1986,"noattachment":false,"key":"/window-or-global/-/window-or-global-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/window-or-global/download/window-or-global-1.0.1.tgz"},"directories":{},"publish_time":1442419507663,"_hasShrinkwrap":false,"_cnpm_publish_time":1442419507663,"_cnpmcore_publish_time":"2021-12-14T15:45:05.646Z"},"1.0.0":{"name":"window-or-global","version":"1.0.0","description":"Use either the window object in the browser or the global object in node.","license":"MIT","repository":{"type":"git","url":"git+https://github.com/purposeindustries/window-or-global.git"},"author":{"name":"ruffle1986","email":"tf@purposeindustries.co"},"main":"./lib/index.js","scripts":{"test":"xo","posttest":"ava examples/**/*.spec.js"},"xo":{"envs":["node","browser"],"space":true,"semicolon":false},"files":["lib"],"keywords":["window","global","isomorphic","universal"],"devDependencies":{"ava":"^0.2.0","browserify":"^11.1.0","component-emitter":"^1.2.0","jsdom":"^6.5.0","proxyquire":"^1.7.2","react":"^0.13.3","xo":"*"},"dependencies":{},"gitHead":"e9053ccb57a62a8dab4615fd21bcfd64492d32b2","bugs":{"url":"https://github.com/purposeindustries/window-or-global/issues"},"homepage":"https://github.com/purposeindustries/window-or-global#readme","_id":"window-or-global@1.0.0","_shasum":"73a31dd18304243f6b85ce3767a6de7113f76772","_from":".","_npmVersion":"2.13.3","_nodeVersion":"3.2.0","_npmUser":{"name":"ruffle1986","email":"ftamas.mail@gmail.com"},"maintainers":[{"name":"oroce","email":"robert@oroszi.net"},{"name":"ruffle1986","email":"ftamas.mail@gmail.com"}],"dist":{"shasum":"73a31dd18304243f6b85ce3767a6de7113f76772","size":1974,"noattachment":false,"key":"/window-or-global/-/window-or-global-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/window-or-global/download/window-or-global-1.0.0.tgz"},"directories":{},"publish_time":1442409453133,"_hasShrinkwrap":false,"_cnpm_publish_time":1442409453133,"_cnpmcore_publish_time":"2021-12-14T15:45:05.829Z"}},"readme":"window-or-global\n================\n\nUse this module to get the global object both on server and client side.\nNo more `window is not defined` errors just peace and flowers.\n\nAdvantages:\n\n- You can easily mock it by [mockery](https://www.npmjs.com/package/mockery) or [proxyquire](https://www.npmjs.com/package/proxyquire) in your tests\n- It's really useful in case of universal (or isomorphic) code, for example, when you'd like to render a [React](http://facebook.github.io/react/) component both on client and server side\n\n## Install\n\n```sh\n$ npm i window-or-global\n```\n\n## Usage\n\n```js\nimport root from 'window-or-global'\n```\n\n## React example\n\n`components/my-component.jsx:`\n\n```js\nimport React, { Component } from 'react'\n// in node, you'll get the global object instead of crashing by an error\nimport root from 'window-or-global'\n\nclass MyComponent extends Component {\n\n  // this method is only invoked in the browser environment\n  componentDidMount() {\n    root.addEventListener(/*...*/)\n  }\n\n  componentWillUnmount() {\n    root.addEventListener(/*...*/)\n  }\n\n  render() {}\n\n}\n\n// Voilà. Enjoy your universal react component! ;)\n// No more 'window is not defined' errors when you render your component\n// on server side.\n\n```\n\n## Unit-testing example\n\nYou can find a complete test example [here](examples/react). The test passes of course, just type\n\n```sh\n$ npm test\n```\n\nin your terminal.\n\n## License\n\n[MIT](LICENSE) &copy; Purpose Industries\n","_attachments":{},"homepage":"https://github.com/purposeindustries/window-or-global#readme","bugs":{"url":"https://github.com/purposeindustries/window-or-global/issues"},"license":"MIT"}