Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

singleton-store

apache-superset6Apache-2.00.1.0TypeScript support: included

A simple key-value store that is a singleton

singleton, key-value store, storage

readme

singleton-store

Version David (path)

A simple key-value store singleton.

Sometimes you have to do horrible things, like use the global object to share a singleton or some values.

Instead of attaching values to the global object, which can lead to security concerns, this singleton-storage package provides a key-value store which is guaranteed to be a singleton, so you can use it instead of the global object. Only code that are part of the same application bundle can access this store, making it more secured.

Example

package A

import { getStore } from 'singleton-storage';
const store = getStore();
store.set('share.config.something', 123);

package B

import { getStore } from 'singleton-storage';
const store = getStore();
store.get('share.config.something'); // 123;

Installation

For this to work correctly, there must be only a single copy of singleton-storage in node_modules at all times. (Similar to how there must be only a single copy of react.)

  • For application developers, just do a regular installation. If you want to use singleton-storage directly, or have some libraries that depends on it.
npm install singleton-storage
  • For library authors, you must always list this as peerDependencies in package.json. Listing it as dependencies may cause the library consumers to have duplicates in the final application.

In library

{
  "peerDependencies": {
    "singleton-storage": "*"
  },
  "devDependencies": {
    "singleton-storage": "x.x"
  }
}

vs. in application

{
  "dependencies": {
    "singleton-storage": "x.x"
  }
}

Available functions

import { getStore } from 'singleton-storage';
const store = getStore();
store.has(key);
store.get<string>(key); // must specify value type via generic
store.getOrCreate(key, factory);
store.remove(key);
store.set(key);

Credits

Inspired by global-cache

License

Apache-2.0

changelog

0.0.0 (2020-07-14)

Bug Fixes

Features

0.4.2 (2020-07-12)

Features

0.4.1 (2020-07-12)

Features

0.4.0 (2020-07-12)

Features

  • replace vega-lite and vega imports with lean copies (#24) (6095ce6)

0.3.7 (2020-05-29)

Bug Fixes

  • correctly handle input domain for quantile and discretizing scales (#23) (82fb1b4)

0.3.6 (2020-05-29)

Features

  • support schemeparams similar to vega-lite (#21) (2ff8323)

0.3.5 (2020-04-30)

0.3.4 (2020-04-15)

Features

  • add overloading for createScaleFromScaleConfig (#20) (f2d7f06)

0.3.3 (2020-04-10)

Features

0.3.2 (2020-04-10)

Bug Fixes

  • do not nice time scale by default (#18) (0e70fb3)

0.3.1 (2020-04-10)

Features

  • export types typeguards and merge encoding utils (#17) (37d46c6)

0.3.0 (2020-04-09)

Features

  • change dependency back to lodash (#15) (b85c284)

0.2.6 (2020-02-15)

Features

  • export type LegendItemInformation (9707f5c)

0.2.5 (2020-02-15)

Features

  • export type LegendGroupInformation (06957c6)

0.2.4 (2020-02-15)

Features

0.2.3 (2020-02-15)

Features

0.2.2 (2020-02-13)

Bug Fixes

0.2.1 (2020-02-12)

Bug Fixes

0.2.0 (2020-02-06)

Bug Fixes

0.1.0 (2019-11-20)

Features

  • add functions and typeguards for checking definition types (#6) (7999086)
  • encoder can set domain of all scales from dataset at once (#7) (a9ed675)

0.0.7 (2019-11-17)

Features

  • support number output for category channel type (c79e7aa)

0.0.6 (2019-11-16)

Features

  • add overloading for encode value (#4) (f48ae69)
  • be more specific about encoding config (#3) (cfefaef)

0.0.5 (2019-11-16)

Bug Fixes

0.0.4 (2019-11-16)

Features

  • encoderFactory can create selector (#1) (99459f9)

0.0.3 (2019-11-15)

Bug Fixes

0.0.2 (2019-11-15)

0.0.1 (2019-11-15)

Bug Fixes

Features