https://github.com/statewalker/statewalker-ns
https://github.com/statewalker/statewalker-ns
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/statewalker/statewalker-ns
- Owner: statewalker
- License: mit
- Created: 2022-05-15T11:13:26.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-11-17T21:40:11.000Z (over 3 years ago)
- Last Synced: 2025-01-16T02:21:51.179Z (over 1 year ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# statewalker-ns
This package contains common namespace for StateWalker libraries.
This namespace allows to share code loaded independently by various applications.
Logically this module gets the global context (the `g` variable
in the example below) and verifies that there is an object
associated with the `statewalker` key:
```js
let g;
g = g || (typeof window !== 'undefined' ? window : undefined);
g = g || (typeof global !== 'undefined' ? global : undefined);
g = g || {};
const ns = g.statewalker = g.statewalker || {};
export default ns;
```
This global namespace is used to share code and data between applications loaded independently:
```js
import { default as ns } from "@setatewalker/ns";
import newServices from ...
const services = ns.services = ns.services || newServices();
...
```