cached-factory 0.0.2 → 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 CHANGED
@@ -3,6 +3,7 @@ declare class CachedFactory<Key, Value> {
3
3
  #private;
4
4
  constructor(factory: Factory<Key, Value>);
5
5
  clear(): void;
6
+ entries(): IterableIterator<[Key, Value]>;
6
7
  get(key: Key): Value;
7
8
  }
8
9
 
package/lib/index.js CHANGED
@@ -7,6 +7,9 @@ class CachedFactory {
7
7
  clear() {
8
8
  this.#cache.clear();
9
9
  }
10
+ entries() {
11
+ return this.#cache.entries();
12
+ }
10
13
  get(key) {
11
14
  const existing = this.#cache.get(key);
12
15
  if (existing) {
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.2",
3
+ "version": "0.1.0",
4
4
  "description": "Creates and caches values under keys. 🏭",
5
5
  "repository": {
6
6
  "type": "git",
@@ -77,12 +77,8 @@
77
77
  "vitest": "^0.34.3",
78
78
  "yaml-eslint-parser": "^1.2.2"
79
79
  },
80
- "packageManager": "pnpm@8.5.0",
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
  }