# immutable-global

> Immutable Global is designed to provide global data stores for use by modules.

Latest version **0.2.3** (published 2018-11-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install immutable-global
pnpm add immutable-global
yarn add immutable-global
bun add immutable-global
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.3 |
| Published | 2018-11-18 |
| First published | 2017-09-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=7.6.0 |
| Dependencies | 3 |
| Unpacked size | 10.2 KB |
| Known vulnerabilities | 0 (+7 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Ersun Warncke |
| Maintainers | ersun.warncke |

## Links

- npm: https://www.npmjs.com/package/immutable-global
- Repository: https://github.com/warncke/immutable-global
- Homepage: https://github.com/warncke/immutable-global#readme
- Issues: https://github.com/warncke/immutable-global/issues
- npm.io page: https://npm.io/package/immutable-global

## Dependencies (3)

- [lodash](https://npm.io/package/lodash.md) 4.17.11
- [if-defined](https://npm.io/package/if-defined.md) 1.0.18
- [immutable-error](https://npm.io/package/immutable-error.md) 0.1.5

## Recent versions

- 0.2.3 (latest) — 2018-11-18
- 0.2.2 — 2018-01-15
- 0.2.1 — 2018-01-15
- 0.2.0 — 2017-10-27
- 0.1.3 — 2017-10-06
- 0.1.2 — 2017-10-04
- 0.1.1 — 2017-10-01
- 0.1.0 — 2017-09-27

## README

# immutable-global

Immutable Global is designed to provide global data stores for use by modules.

Storing data globally, as opposed to in private variables inside a module file,
is necessary when you truly need a singleton object because different versions
of the same module may be loaded from different files.

Immutable Global stores global data according to a consistent naming scheme
and provides a reset mechanism which is needed for unit tests.

## Creating a new global instance

    var global = new ImmutableGlobal('MyModule', {foo: true})

This will create a new global data object stored at:

    global.__immutable_global__.MyModule

This object will be initialized with the default values `foo: true` and
whenever it is reset it will be reset to its default state.

## Get global instance for module

    var global = ImmutableGlobal.global('MyModule')

`global.data` will have the global data for the module. Will throw error if
module does not have global instance registered.

## Check if module has global instance

    ImmutableGlobal.hasGlobal('MyModule') 

## Get global data

    var data = global.data

The `data` property of the ImmutableGlobal instance references the global data
for the module.

## Reset global data

    global.reset()

The `reset` method on an ImmutableGlobal instance will reset the data for that
particular instance to its default values

## Reset all global data

    ImmutableGlobal.reset()

The `reset` method on the ImmutableGlobal class will reset the global data for
all instances.

---
_Source: https://npm.io/package/immutable-global · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
