cached-factory 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -1
- package/package.json +3 -7
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export type Factory<Key, Value> = (key: Key) => Value;\n\nexport class CachedFactory<Key, Value> {\n\t#cache = new Map<Key, Value>();\n\t#getter: Factory<Key, Value>;\n\n\tconstructor(factory: Factory<Key, Value>) {\n\t\tthis.#getter = factory;\n\t}\n\n\tclear() {\n\t\tthis.#cache.clear();\n\t}\n\n\tget(key: Key) {\n\t\tconst existing = this.#cache.get(key);\n\t\tif (existing) {\n\t\t\treturn existing;\n\t\t}\n\n\t\tconst value = this.#getter(key);\n\t\tthis.#cache.set(key, value);\n\t\treturn value;\n\t}\n}\n"],"mappings":"AAEO,MAAM,cAA0B;AAAA,EACtC,SAAS,oBAAI,IAAgB;AAAA,EAC7B;AAAA,EAEA,YAAY,SAA8B;AACzC,SAAK,UAAU;AAAA,EAChB;AAAA,EAEA,QAAQ;AACP,SAAK,OAAO,MAAM;AAAA,EACnB;AAAA,EAEA,IAAI,KAAU;AACb,UAAM,WAAW,KAAK,OAAO,IAAI,GAAG;AACpC,QAAI,UAAU;AACb,aAAO;AAAA,IACR;AAEA,UAAM,QAAQ,KAAK,QAAQ,GAAG;AAC9B,SAAK,OAAO,IAAI,KAAK,KAAK;AAC1B,WAAO;AAAA,EACR;AACD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export type Factory<Key, Value> = (key: Key) => Value;\n\nexport class CachedFactory<Key, Value> {\n\t#cache = new Map<Key, Value>();\n\t#getter: Factory<Key, Value>;\n\n\tconstructor(factory: Factory<Key, Value>) {\n\t\tthis.#getter = factory;\n\t}\n\n\tclear() {\n\t\tthis.#cache.clear();\n\t}\n\n\tentries() {\n\t\treturn this.#cache.entries();\n\t}\n\n\tget(key: Key) {\n\t\tconst existing = this.#cache.get(key);\n\t\tif (existing) {\n\t\t\treturn existing;\n\t\t}\n\n\t\tconst value = this.#getter(key);\n\t\tthis.#cache.set(key, value);\n\t\treturn value;\n\t}\n}\n"],"mappings":"AAEO,MAAM,cAA0B;AAAA,EACtC,SAAS,oBAAI,IAAgB;AAAA,EAC7B;AAAA,EAEA,YAAY,SAA8B;AACzC,SAAK,UAAU;AAAA,EAChB;AAAA,EAEA,QAAQ;AACP,SAAK,OAAO,MAAM;AAAA,EACnB;AAAA,EAEA,UAAU;AACT,WAAO,KAAK,OAAO,QAAQ;AAAA,EAC5B;AAAA,EAEA,IAAI,KAAU;AACb,UAAM,WAAW,KAAK,OAAO,IAAI,GAAG;AACpC,QAAI,UAAU;AACb,aAAO;AAAA,IACR;AAEA,UAAM,QAAQ,KAAK,QAAQ,GAAG;AAC9B,SAAK,OAAO,IAAI,KAAK,KAAK;AAC1B,WAAO;AAAA,EACR;AACD;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cached-factory",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Creates and caches values under keys. 🏭",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"lint": "eslint . .*js --max-warnings 0 --report-unused-disable-directives",
|
|
27
27
|
"lint:knip": "knip",
|
|
28
28
|
"lint:md": "markdownlint \"**/*.md\" \".github/**/*.md\" --rules sentences-per-line",
|
|
29
|
-
"lint:package": "npmPkgJsonLint .",
|
|
29
|
+
"lint:package-json": "npmPkgJsonLint .",
|
|
30
30
|
"lint:packages": "pnpm dedupe --check",
|
|
31
31
|
"lint:spelling": "cspell \"**\" \".github/**/*\"",
|
|
32
32
|
"prepare": "husky install",
|
|
@@ -77,12 +77,8 @@
|
|
|
77
77
|
"vitest": "^0.34.3",
|
|
78
78
|
"yaml-eslint-parser": "^1.2.2"
|
|
79
79
|
},
|
|
80
|
-
"packageManager": "pnpm@
|
|
80
|
+
"packageManager": "pnpm@9.15.0",
|
|
81
81
|
"engines": {
|
|
82
82
|
"node": ">=18"
|
|
83
|
-
},
|
|
84
|
-
"publishConfig": {
|
|
85
|
-
"access": "public",
|
|
86
|
-
"provenance": true
|
|
87
83
|
}
|
|
88
84
|
}
|