{"_id":"uni-global","_rev":"1751539","name":"uni-global","description":"Global namespace without polluting the global scope","dist-tags":{"latest":"1.0.0"},"maintainers":[{"name":"medikoo","email":""}],"time":{"modified":"2021-11-29T01:34:53.000Z","created":"2021-10-06T08:17:04.833Z","1.0.0":"2021-10-06T08:17:04.833Z"},"users":{},"author":{"name":"Mariusz Nowak","email":"medyk@medikoo.com","url":"https://www.medikoo.com/"},"repository":{"type":"git","url":"git+https://github.com/medikoo/uni-global.git"},"versions":{"1.0.0":{"name":"uni-global","version":"1.0.0","description":"Global namespace without polluting the global scope","author":{"name":"Mariusz Nowak","email":"medyk@medikoo.com","url":"https://www.medikoo.com/"},"keywords":["global","globalThis"],"repository":{"type":"git","url":"git+https://github.com/medikoo/uni-global.git"},"dependencies":{"type":"^2.5.0"},"devDependencies":{"@commitlint/cli":"^13.2.0","chai":"^4.3.4","eslint":"^7.32.0","eslint-config-medikoo":"^4.1.0","ext":"^1.6.0","git-list-updated":"^1.2.1","github-release-from-cc-changelog":"^2.2.0","husky":"^4.3.8","lint-staged":"^11.1.2","mocha":"^9.1.2","ncjsm":"^4.2.0","nyc":"^15.1.0","prettier-elastic":"^2.2.1","standard-version":"^9.3.1"},"husky":{"hooks":{"commit-msg":"commitlint -E HUSKY_GIT_PARAMS","pre-commit":"lint-staged"}},"lint-staged":{"*.js":["eslint"],"*.{css,html,js,json,md,yaml,yml}":["prettier -c"]},"eslintConfig":{"extends":"medikoo/es3","root":true,"globals":{"Symbol":true},"overrides":[{"files":"test/**/*.js","env":{"mocha":true}}]},"prettier":{"printWidth":100,"tabWidth":4,"overrides":[{"files":["*.md","*.yml"],"options":{"tabWidth":2}}]},"nyc":{"all":true,"exclude":[".github","coverage/**","test/**","prettier.config.js"],"reporter":["lcov","html","text-summary"]},"standard-version":{"skip":{"commit":true,"tag":true},"types":[{"type":"feat","section":"Features"},{"type":"fix","section":"Bug Fixes"},{"type":"perf","section":"Performance Improvements"},{"type":"refactor","section":"Maintenance Improvements"},{"type":"chore","section":"Maintenance Improvements"}]},"scripts":{"commitlint":"commitlint -f HEAD@{15}","coverage":"nyc npm test","lint":"eslint --ignore-path=.gitignore .","lint:updated":"pipe-git-updated --ext=js -- eslint --ignore-pattern '!*'","prepare-release":"standard-version && prettier --write CHANGELOG.md","prettier-check":"prettier -c --ignore-path .gitignore \"**/*.{css,html,js,json,md,yaml,yml}\"","prettier-check:updated":"pipe-git-updated --ext=css --ext=html --ext=js --ext=json --ext=md --ext=yaml --ext=yml -- prettier -c","prettify":"prettier --write --ignore-path .gitignore \"**/*.{css,html,js,json,md,yaml,yml}\"","prettify:updated":"pipe-git-updated --ext=css --ext=html --ext=js --ext=json --ext=md --ext=yaml --ext=yml -- prettier --write","test":"mocha"},"license":"ISC","gitHead":"c3cdadd00edd6d399e0853decd0e2282cb32436a","bugs":{"url":"https://github.com/medikoo/uni-global/issues"},"homepage":"https://github.com/medikoo/uni-global#readme","_id":"uni-global@1.0.0","_nodeVersion":"14.18.0","_npmVersion":"6.14.15","dist":{"shasum":"3583c449e87a2d9dc270ea221410a649bcdad040","size":3801,"noattachment":false,"key":"/uni-global/-/uni-global-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/uni-global/download/uni-global-1.0.0.tgz"},"_npmUser":{"name":"medikoo","email":"medikoo+npm@medikoo.com"},"directories":{},"maintainers":[{"name":"medikoo","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/uni-global_1.0.0_1633508224700_0.7903668991046924"},"_hasShrinkwrap":false,"publish_time":1633508224833,"_cnpm_publish_time":1633508224833}},"readme":"[![Build status][build-image]][build-url]\n[![Tests coverage][cov-image]][cov-url]\n[![npm version][npm-image]][npm-url]\n\n# uni-global\n\n## Global namespace with no global scope pollution\n\n### Use case\n\nIn modules world, there's possiblity that two different instance of same modules (e.g. installed in different `node_modules`) are being run in same process.\n\nIf for any reason they need to operate on context instance that's same for the given application or process, then ocassionally introduced multiple installations may break the application.\n\nThis module provides interface wich can be used by those to modules to ensure that no matter how many instances of given module are loaded, in all cases they end with same context instance.\n\n### Example usage:\n\n```javascript\n// No matter how many instances of given module are loaded in the process, they will always end with same context instance\nconst globalContext = require(\"uni-global\")(\"my-scope-name\");\n\n// globalContext is a plain object, on which needed global data can be stored.\nglobalContext.someSingletonData = ...\n\n```\n\n### Adapt manually other realm\n\nIf there's a need to adapt other environment realm (e.g. coming from iframe) to share same uni-global directory.\n\nRegister it with `adaptRealm` util as below:\n\n```javascript\nconst adaptRealm = require(\"uni-global/adapt-realm\");\n\nadaptRealm(iFrameWindow); // Pass global object of the other realm\n```\n\n### Installation\n\n```bash\nnpm install uni-global\n```\n\n[build-image]: https://github.com/medikoo/uni-global/workflows/Integrate/badge.svg\n[build-url]: https://github.com/medikoo/uni-global/actions?query=workflow%3AIntegrate\n[cov-image]: https://img.shields.io/codecov/c/github/medikoo/uni-global.svg\n[cov-url]: https://codecov.io/gh/medikoo/uni-global\n[npm-image]: https://img.shields.io/npm/v/uni-global.svg\n[npm-url]: https://www.npmjs.com/package/uni-global\n","_attachments":{},"homepage":"https://github.com/medikoo/uni-global#readme","bugs":{"url":"https://github.com/medikoo/uni-global/issues"},"license":"ISC"}