sticky-module

0.1.1 • Public • Published

sticky-module

build status Coverage Status

A Symbol based leaky utility to store or retrieve a module, so that libraries can actually be sure if these are re-bundled elsewhere they still work as expected or do not bootstrap twice.

import stickyModule from 'sticky-module';

let [{a, b}, known] = stickyModule('@custom/name', {
  a: Math.random(),
  b: 'let it'
});

known;    // `false`
({a, b}); // the random value and the string "let it"

// on a further attempt it will return exact same object
// hence exact same random value `a` had before
[{a, b}, known] = stickyModule('@custom/name', {
  a: Math.random(),
  b: 'nope, already there'
});

known;    // this time it's `true`
({a, b}); // the same previous random value and the same string "let it"

Readme

Keywords

Package Sidebar

Install

npm i sticky-module

Weekly Downloads

3,297

Version

0.1.1

License

ISC

Unpacked Size

6.56 kB

Total Files

9

Last publish

Collaborators

  • webreflection