sticky-module
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -5,6 +5,7 @@ 'use strict'; | ||
* if the module might have been re-bundled in other projects. | ||
* @template T | ||
* @param {string} name the module name to save or retrieve | ||
* @param {object} value the module as value to save if not known | ||
* @param {T} value the module as value to save if not known | ||
* @param {globalThis} [global=globalThis] the reference where modules are saved where `globalThis` is the default | ||
* @returns {[object, boolean]} the passed `value` or the previous one as first entry, a boolean indicating if it was known or not | ||
* @returns {[T, boolean]} the passed `value` or the previous one as first entry, a boolean indicating if it was known or not | ||
*/ | ||
@@ -11,0 +12,0 @@ const stickyModule = (name, value, global = globalThis) => { |
/** | ||
* Allow leaking a module globally to help avoid conflicting exports | ||
* if the module might have been re-bundled in other projects. | ||
* @template T | ||
* @param {string} name the module name to save or retrieve | ||
* @param {object} value the module as value to save if not known | ||
* @param {T} value the module as value to save if not known | ||
* @param {globalThis} [global=globalThis] the reference where modules are saved where `globalThis` is the default | ||
* @returns {[object, boolean]} the passed `value` or the previous one as first entry, a boolean indicating if it was known or not | ||
* @returns {[T, boolean]} the passed `value` or the previous one as first entry, a boolean indicating if it was known or not | ||
*/ | ||
@@ -9,0 +10,0 @@ const stickyModule = (name, value, global = globalThis) => { |
/** | ||
* Allow leaking a module globally to help avoid conflicting exports | ||
* if the module might have been re-bundled in other projects. | ||
* @template T | ||
* @param {string} name the module name to save or retrieve | ||
* @param {object} value the module as value to save if not known | ||
* @param {T} value the module as value to save if not known | ||
* @param {globalThis} [global=globalThis] the reference where modules are saved where `globalThis` is the default | ||
* @returns {[object, boolean]} the passed `value` or the previous one as first entry, a boolean indicating if it was known or not | ||
* @returns {[T, boolean]} the passed `value` or the previous one as first entry, a boolean indicating if it was known or not | ||
*/ | ||
@@ -9,0 +10,0 @@ const stickyModule = (name, value, global = globalThis) => { |
{ | ||
"name": "sticky-module", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "A Symbol based leaky utility to store or retrieve a module", | ||
"main": "./cjs/index.js", | ||
"scripts": { | ||
"build": "npm run cjs && npm run rollup:es && npm run rollup:index && npm run test", | ||
"build": "npm run cjs && npm run rollup:es && npm run rollup:index && npm run ts && npm run test", | ||
"cjs": "ascjs --no-default esm cjs", | ||
"rollup:es": "rollup --config rollup/es.config.js && sed -i.bck 's/^var /self./' es.js && rm -rf es.js.bck", | ||
"rollup:index": "rollup --config rollup/index.config.js", | ||
"coveralls": "c8 report --reporter=text-lcov | coveralls", | ||
"test": "c8 node test/index.js" | ||
"test": "c8 node test/index.js", | ||
"ts": "tsc -p .", | ||
"coverage": "mkdir -p ./coverage; c8 report --reporter=text-lcov > ./coverage/lcov.info" | ||
}, | ||
@@ -23,6 +24,6 @@ "keywords": [ | ||
"@rollup/plugin-terser": "^0.4.4", | ||
"ascjs": "^6.0.2", | ||
"ascjs": "^6.0.3", | ||
"c8": "^8.0.1", | ||
"coveralls": "^3.1.1", | ||
"rollup": "^4.0.2" | ||
"rollup": "^4.3.0", | ||
"typescript": "^5.2.2" | ||
}, | ||
@@ -33,2 +34,3 @@ "module": "./esm/index.js", | ||
".": { | ||
"types": "./types/index.d.ts", | ||
"import": "./esm/index.js", | ||
@@ -35,0 +37,0 @@ "default": "./cjs/index.js" |
# sticky-module | ||
[](https://github.com/WebReflection/sticky-module/actions) [](https://coveralls.io/github/WebReflection/sticky-module?branch=main) | ||
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. | ||
@@ -20,3 +22,3 @@ | ||
a: Math.random(), | ||
b: 'let it' | ||
b: 'nope, already there' | ||
}); | ||
@@ -23,0 +25,0 @@ |
6562
9
73
28