cached-factory 0.1.0 โ 0.3.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/README.md +48 -26
- package/lib/CachedFactory.d.ts +12 -0
- package/lib/CachedFactory.d.ts.map +1 -0
- package/lib/CachedFactory.js +25 -0
- package/lib/CachedFactory.js.map +1 -0
- package/lib/WeakCachedFactory.d.ts +12 -0
- package/lib/WeakCachedFactory.d.ts.map +1 -0
- package/lib/WeakCachedFactory.js +22 -0
- package/lib/WeakCachedFactory.js.map +1 -0
- package/lib/index.d.ts +3 -10
- package/lib/index.js +3 -26
- package/package.json +43 -53
- package/lib/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,34 +1,33 @@
|
|
|
1
1
|
<h1 align="center">cached-factory</h1>
|
|
2
2
|
|
|
3
|
-
<p align="center">
|
|
3
|
+
<p align="center">
|
|
4
|
+
Creates and caches values under keys.
|
|
5
|
+
๐ญ
|
|
6
|
+
</p>
|
|
4
7
|
|
|
5
8
|
<p align="center">
|
|
6
|
-
|
|
7
|
-
<!--
|
|
8
|
-
|
|
9
|
-
<img alt="All Contributors: 1" src="https://img.shields.io/badge/all_contributors-1-21bb42.svg" />
|
|
9
|
+
<!-- prettier-ignore-start -->
|
|
10
|
+
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
|
11
|
+
<a href="#contributors" target="_blank"><img alt="๐ช All Contributors: 2" src="https://img.shields.io/badge/%F0%9F%91%AA_all_contributors-2-21bb42.svg" /></a>
|
|
10
12
|
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
|
11
|
-
<!-- prettier-ignore-end -->
|
|
12
|
-
|
|
13
|
-
<a href="https://codecov.io/gh/JoshuaKGoldberg/cached-factory" target="_blank">
|
|
14
|
-
<img alt="
|
|
15
|
-
|
|
16
|
-
<
|
|
17
|
-
<img alt="Contributor Covenant" src="https://img.shields.io/badge/code_of_conduct-enforced-21bb42" />
|
|
18
|
-
</a>
|
|
19
|
-
<a href="https://github.com/JoshuaKGoldberg/cached-factory/blob/main/LICENSE.md" target="_blank">
|
|
20
|
-
<img alt="License: MIT" src="https://img.shields.io/github/license/JoshuaKGoldberg/cached-factory?color=21bb42">
|
|
21
|
-
</a>
|
|
22
|
-
<img alt="Style: Prettier" src="https://img.shields.io/badge/style-prettier-21bb42.svg" />
|
|
23
|
-
<img alt="TypeScript: Strict" src="https://img.shields.io/badge/typescript-strict-21bb42.svg" />
|
|
13
|
+
<!-- prettier-ignore-end -->
|
|
14
|
+
<a href="https://github.com/JoshuaKGoldberg/cached-factory/blob/main/.github/CODE_OF_CONDUCT.md" target="_blank"><img alt="๐ค Code of Conduct: Kept" src="https://img.shields.io/badge/%F0%9F%A4%9D_code_of_conduct-kept-21bb42" /></a>
|
|
15
|
+
<a href="https://codecov.io/gh/JoshuaKGoldberg/cached-factory" target="_blank"><img alt="๐งช Coverage" src="https://img.shields.io/codecov/c/github/JoshuaKGoldberg/cached-factory?label=%F0%9F%A7%AA%20coverage" /></a>
|
|
16
|
+
<a href="https://github.com/JoshuaKGoldberg/cached-factory/blob/main/LICENSE.md" target="_blank"><img alt="๐ License: MIT" src="https://img.shields.io/badge/%F0%9F%93%9D_license-MIT-21bb42.svg" /></a>
|
|
17
|
+
<a href="http://npmjs.com/package/cached-factory" target="_blank"><img alt="๐ฆ npm version" src="https://img.shields.io/npm/v/cached-factory?color=21bb42&label=%F0%9F%93%A6%20npm" /></a>
|
|
18
|
+
<img alt="๐ช TypeScript: Strict" src="https://img.shields.io/badge/%F0%9F%92%AA_typescript-strict-21bb42.svg" />
|
|
24
19
|
</p>
|
|
25
20
|
|
|
26
21
|
## Usage
|
|
27
22
|
|
|
23
|
+
### `CachedFactory`
|
|
24
|
+
|
|
28
25
|
`cached-factory` exports a `CachedFactory` class that takes in "factory" function in its constructor.
|
|
29
26
|
Each time a factory's `.get(key)` is called with any `key` for the first time, that factory is used to create a value under the `key`.
|
|
30
27
|
|
|
31
28
|
```ts
|
|
29
|
+
import { CachedFactory } from "cached-factory";
|
|
30
|
+
|
|
32
31
|
const cache = new CachedFactory((key) => `Cached: ${key}!`);
|
|
33
32
|
|
|
34
33
|
// "Cached: apple!"
|
|
@@ -38,16 +37,36 @@ cache.get("apple");
|
|
|
38
37
|
Values are cached so that subsequent `.get(key)` calls with the same `key` instantly return the same value.
|
|
39
38
|
|
|
40
39
|
```ts
|
|
40
|
+
import { CachedFactory } from "cached-factory";
|
|
41
|
+
|
|
41
42
|
const cache = new CachedFactory((key) => ({ key }));
|
|
42
43
|
|
|
43
44
|
// { key: "banana" }
|
|
44
45
|
cache.get("banana");
|
|
45
46
|
|
|
46
47
|
// true
|
|
47
|
-
cache.get("banana") ===
|
|
48
|
+
cache.get("banana") === cache.get("banana");
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### `WeakCachedFactory`
|
|
52
|
+
|
|
53
|
+
The package also exports a `WeakCachedFactory` class that provides the same behavior as `CachedFactory` but uses a `WeakMap` as its underlying data structure.
|
|
54
|
+
As such, only objects can be used for keys (no primitives), and there is no `entries()` function.
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
import { WeakCachedFactory } from "cached-factory";
|
|
58
|
+
|
|
59
|
+
const cache = new WeakCachedFactory((key: Context) =>
|
|
60
|
+
createSomeResultObject(key),
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
const result = cache.get(someContext);
|
|
64
|
+
|
|
65
|
+
// true
|
|
66
|
+
result === cache.get(someContext);
|
|
48
67
|
```
|
|
49
68
|
|
|
50
|
-
|
|
69
|
+
## Asynchronous Factories
|
|
51
70
|
|
|
52
71
|
`CachedFactory` does not itself handle `Promise` logic, but it doesn't have to!
|
|
53
72
|
Provided factory functions can themselves be `async` / return `Promise` values.
|
|
@@ -76,7 +95,8 @@ cache.clear();
|
|
|
76
95
|
|
|
77
96
|
### TypeScript
|
|
78
97
|
|
|
79
|
-
`
|
|
98
|
+
`cached-factory` is written in TypeScript and ships with strong typing.
|
|
99
|
+
๐ช
|
|
80
100
|
|
|
81
101
|
> ๐ Tip: if you're working with [`noImplicitAny`](https://aka.ms/tsconfig#noImplicitAny) enabled _(which is generally a good idea)_, an inline function provided as an argument to `CachedFactory` may need an explicit type annotation for its key.
|
|
82
102
|
>
|
|
@@ -84,26 +104,28 @@ cache.clear();
|
|
|
84
104
|
> new CachedFactory((key: string) => `Cached: ${key}!`);
|
|
85
105
|
> ```
|
|
86
106
|
|
|
107
|
+
## Development
|
|
108
|
+
|
|
109
|
+
See [`.github/CONTRIBUTING.md`](./.github/CONTRIBUTING.md), then [`.github/DEVELOPMENT.md`](./.github/DEVELOPMENT.md).
|
|
110
|
+
Thanks! ๐ญ
|
|
111
|
+
|
|
87
112
|
## Contributors
|
|
88
113
|
|
|
89
114
|
<!-- spellchecker: disable -->
|
|
90
115
|
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
91
116
|
<!-- prettier-ignore-start -->
|
|
92
|
-
<!-- markdownlint-disable -->
|
|
93
117
|
<table>
|
|
94
118
|
<tbody>
|
|
95
119
|
<tr>
|
|
120
|
+
<td align="center" valign="top" width="14.28%"><a href="http://lishaduck.github.io"><img src="https://avatars.githubusercontent.com/u/88557639?v=4?s=100" width="100px;" alt="Eli"/><br /><sub><b>Eli</b></sub></a><br /><a href="https://github.com/JoshuaKGoldberg/cached-factory/issues?q=author%3Alishaduck" title="Bug reports">๐</a></td>
|
|
96
121
|
<td align="center" valign="top" width="14.28%"><a href="http://www.joshuakgoldberg.com/"><img src="https://avatars.githubusercontent.com/u/3335181?v=4?s=100" width="100px;" alt="Josh Goldberg โจ"/><br /><sub><b>Josh Goldberg โจ</b></sub></a><br /><a href="https://github.com/JoshuaKGoldberg/cached-factory/commits?author=JoshuaKGoldberg" title="Code">๐ป</a> <a href="#content-JoshuaKGoldberg" title="Content">๐</a> <a href="https://github.com/JoshuaKGoldberg/cached-factory/commits?author=JoshuaKGoldberg" title="Documentation">๐</a> <a href="#ideas-JoshuaKGoldberg" title="Ideas, Planning, & Feedback">๐ค</a> <a href="#infra-JoshuaKGoldberg" title="Infrastructure (Hosting, Build-Tools, etc)">๐</a> <a href="#maintenance-JoshuaKGoldberg" title="Maintenance">๐ง</a> <a href="#projectManagement-JoshuaKGoldberg" title="Project Management">๐</a> <a href="#tool-JoshuaKGoldberg" title="Tools">๐ง</a></td>
|
|
97
122
|
</tr>
|
|
98
123
|
</tbody>
|
|
99
124
|
</table>
|
|
100
125
|
|
|
101
|
-
<!-- markdownlint-restore -->
|
|
102
126
|
<!-- prettier-ignore-end -->
|
|
103
127
|
|
|
104
128
|
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
105
129
|
<!-- spellchecker: enable -->
|
|
106
130
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
> ๐ This package is based on [@JoshuaKGoldberg](https://github.com/JoshuaKGoldberg)'s [template-typescript-node-package](https://github.com/JoshuaKGoldberg/template-typescript-node-package).
|
|
131
|
+
> ๐ This package was templated with [`create-typescript-app`](https://github.com/JoshuaKGoldberg/create-typescript-app) using the [Bingo framework](https://create.bingo).
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/CachedFactory.d.ts
|
|
2
|
+
type Factory<Key, Value> = (key: Key) => Value;
|
|
3
|
+
declare class CachedFactory<Key, Value> {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(factory: Factory<Key, Value>);
|
|
6
|
+
clear(): void;
|
|
7
|
+
entries(): MapIterator<[Key, Value]>;
|
|
8
|
+
get(key: Key): Value;
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { CachedFactory, Factory };
|
|
12
|
+
//# sourceMappingURL=CachedFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CachedFactory.d.ts","names":[],"sources":["../src/CachedFactory.ts"],"mappings":";KAAY,OAAA,gBAAuB,GAAA,EAAK,GAAA,KAAQ,KAAK;AAAA,cAExC,aAAA;EAAA;cAIA,OAAA,EAAS,OAAA,CAAQ,GAAA,EAAK,KAAA;EAIlC,KAAA;EAIA,OAAA,IAAO,WAAA,EAAA,GAAA,EAAA,KAAA;EAIP,GAAA,CAAI,GAAA,EAAK,GAAA,GAAG,KAAA;AAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//#region src/CachedFactory.ts
|
|
2
|
+
var CachedFactory = class {
|
|
3
|
+
#cache = /* @__PURE__ */ new Map();
|
|
4
|
+
#getter;
|
|
5
|
+
constructor(factory) {
|
|
6
|
+
this.#getter = factory;
|
|
7
|
+
}
|
|
8
|
+
clear() {
|
|
9
|
+
this.#cache.clear();
|
|
10
|
+
}
|
|
11
|
+
entries() {
|
|
12
|
+
return this.#cache.entries();
|
|
13
|
+
}
|
|
14
|
+
get(key) {
|
|
15
|
+
const existing = this.#cache.get(key);
|
|
16
|
+
if (existing) return existing;
|
|
17
|
+
const value = this.#getter(key);
|
|
18
|
+
this.#cache.set(key, value);
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
export { CachedFactory };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=CachedFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CachedFactory.js","names":["#getter","#cache"],"sources":["../src/CachedFactory.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":";AAEA,IAAa,gBAAb,MAAuC;CACtC,yBAAS,IAAI,IAAgB;CAC7B;CAEA,YAAY,SAA8B;EACzC,KAAKA,UAAU;CAChB;CAEA,QAAQ;EACP,KAAKC,OAAO,MAAM;CACnB;CAEA,UAAU;EACT,OAAO,KAAKA,OAAO,QAAQ;CAC5B;CAEA,IAAI,KAAU;EACb,MAAM,WAAW,KAAKA,OAAO,IAAI,GAAG;EACpC,IAAI,UACH,OAAO;EAGR,MAAM,QAAQ,KAAKD,QAAQ,GAAG;EAC9B,KAAKC,OAAO,IAAI,KAAK,KAAK;EAC1B,OAAO;CACR;AACD"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Factory } from "./CachedFactory.js";
|
|
2
|
+
|
|
3
|
+
//#region src/WeakCachedFactory.d.ts
|
|
4
|
+
declare class WeakCachedFactory<Key extends WeakKey, Value> {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(factory: Factory<Key, Value>);
|
|
7
|
+
clear(): void;
|
|
8
|
+
get(key: Key): Value;
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { WeakCachedFactory };
|
|
12
|
+
//# sourceMappingURL=WeakCachedFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WeakCachedFactory.d.ts","names":[],"sources":["../src/WeakCachedFactory.ts"],"mappings":";;;cAEa,iBAAA,aAA8B,OAAA;EAAA;cAI9B,OAAA,EAAS,OAAA,CAAQ,GAAA,EAAK,KAAA;EAIlC,KAAA;EAIA,GAAA,CAAI,GAAA,EAAK,GAAA,GAAG,KAAA;AAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/WeakCachedFactory.ts
|
|
2
|
+
var WeakCachedFactory = class {
|
|
3
|
+
#cache = /* @__PURE__ */ new WeakMap();
|
|
4
|
+
#getter;
|
|
5
|
+
constructor(factory) {
|
|
6
|
+
this.#getter = factory;
|
|
7
|
+
}
|
|
8
|
+
clear() {
|
|
9
|
+
this.#cache = /* @__PURE__ */ new WeakMap();
|
|
10
|
+
}
|
|
11
|
+
get(key) {
|
|
12
|
+
const existing = this.#cache.get(key);
|
|
13
|
+
if (existing) return existing;
|
|
14
|
+
const value = this.#getter(key);
|
|
15
|
+
this.#cache.set(key, value);
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { WeakCachedFactory };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=WeakCachedFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WeakCachedFactory.js","names":["#getter","#cache"],"sources":["../src/WeakCachedFactory.ts"],"sourcesContent":["import { Factory } from \"./CachedFactory.ts\";\n\nexport class WeakCachedFactory<Key extends WeakKey, Value> {\n\t#cache = new WeakMap<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 = new WeakMap<Key, Value>();\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":";AAEA,IAAa,oBAAb,MAA2D;CAC1D,yBAAS,IAAI,QAAoB;CACjC;CAEA,YAAY,SAA8B;EACzC,KAAKA,UAAU;CAChB;CAEA,QAAQ;EACP,KAAKC,yBAAS,IAAI,QAAoB;CACvC;CAEA,IAAI,KAAU;EACb,MAAM,WAAW,KAAKA,OAAO,IAAI,GAAG;EACpC,IAAI,UACH,OAAO;EAGR,MAAM,QAAQ,KAAKD,QAAQ,GAAG;EAC9B,KAAKC,OAAO,IAAI,KAAK,KAAK;EAC1B,OAAO;CACR;AACD"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
constructor(factory: Factory<Key, Value>);
|
|
5
|
-
clear(): void;
|
|
6
|
-
entries(): IterableIterator<[Key, Value]>;
|
|
7
|
-
get(key: Key): Value;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export { CachedFactory, Factory };
|
|
1
|
+
import { CachedFactory, Factory } from "./CachedFactory.js";
|
|
2
|
+
import { WeakCachedFactory } from "./WeakCachedFactory.js";
|
|
3
|
+
export { CachedFactory, type Factory, WeakCachedFactory };
|
package/lib/index.js
CHANGED
|
@@ -1,26 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
constructor(factory) {
|
|
5
|
-
this.#getter = factory;
|
|
6
|
-
}
|
|
7
|
-
clear() {
|
|
8
|
-
this.#cache.clear();
|
|
9
|
-
}
|
|
10
|
-
entries() {
|
|
11
|
-
return this.#cache.entries();
|
|
12
|
-
}
|
|
13
|
-
get(key) {
|
|
14
|
-
const existing = this.#cache.get(key);
|
|
15
|
-
if (existing) {
|
|
16
|
-
return existing;
|
|
17
|
-
}
|
|
18
|
-
const value = this.#getter(key);
|
|
19
|
-
this.#cache.set(key, value);
|
|
20
|
-
return value;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
export {
|
|
24
|
-
CachedFactory
|
|
25
|
-
};
|
|
26
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import { CachedFactory } from "./CachedFactory.js";
|
|
2
|
+
import { WeakCachedFactory } from "./WeakCachedFactory.js";
|
|
3
|
+
export { CachedFactory, WeakCachedFactory };
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cached-factory",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Creates and caches values under keys. ๐ญ",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "https://github.com/JoshuaKGoldberg/cached-factory"
|
|
7
|
+
"url": "git+https://github.com/JoshuaKGoldberg/cached-factory.git"
|
|
8
8
|
},
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"author": {
|
|
@@ -12,25 +12,19 @@
|
|
|
12
12
|
"email": "npm@joshuakgoldberg.com"
|
|
13
13
|
},
|
|
14
14
|
"type": "module",
|
|
15
|
-
"main": "
|
|
15
|
+
"main": "lib/index.js",
|
|
16
16
|
"files": [
|
|
17
|
-
"lib/"
|
|
18
|
-
"package.json",
|
|
19
|
-
"LICENSE.md",
|
|
20
|
-
"README.md"
|
|
17
|
+
"lib/"
|
|
21
18
|
],
|
|
22
19
|
"scripts": {
|
|
23
|
-
"build": "
|
|
24
|
-
"format": "prettier
|
|
20
|
+
"build": "tsdown",
|
|
21
|
+
"format": "prettier .",
|
|
25
22
|
"format:write": "pnpm format --write",
|
|
26
|
-
"lint": "eslint .
|
|
23
|
+
"lint": "eslint . --max-warnings 0",
|
|
27
24
|
"lint:knip": "knip",
|
|
28
|
-
"lint:md": "markdownlint \"**/*.md\" \".github/**/*.md\" --rules sentences-per-line",
|
|
29
|
-
"lint:package-json": "npmPkgJsonLint .",
|
|
30
25
|
"lint:packages": "pnpm dedupe --check",
|
|
31
26
|
"lint:spelling": "cspell \"**\" \".github/**/*\"",
|
|
32
|
-
"prepare": "husky
|
|
33
|
-
"should-semantic-release": "should-semantic-release --verbose",
|
|
27
|
+
"prepare": "husky",
|
|
34
28
|
"test": "vitest",
|
|
35
29
|
"tsc": "tsc"
|
|
36
30
|
},
|
|
@@ -38,47 +32,43 @@
|
|
|
38
32
|
"*": "prettier --ignore-unknown --write"
|
|
39
33
|
},
|
|
40
34
|
"devDependencies": {
|
|
41
|
-
"@
|
|
42
|
-
"@
|
|
43
|
-
"@
|
|
44
|
-
"@
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"eslint": "
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"eslint
|
|
52
|
-
"eslint-plugin-jsdoc": "
|
|
53
|
-
"eslint-plugin-jsonc": "
|
|
54
|
-
"eslint-plugin-
|
|
55
|
-
"eslint-plugin-
|
|
56
|
-
"eslint-plugin-
|
|
57
|
-
"eslint-plugin-
|
|
58
|
-
"eslint-plugin-
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"release-it": "^16.1.5",
|
|
73
|
-
"sentences-per-line": "^0.2.1",
|
|
74
|
-
"should-semantic-release": "^0.1.1",
|
|
75
|
-
"tsup": "^7.2.0",
|
|
76
|
-
"typescript": "^5.1.6",
|
|
77
|
-
"vitest": "^0.34.3",
|
|
78
|
-
"yaml-eslint-parser": "^1.2.2"
|
|
35
|
+
"@eslint-community/eslint-plugin-eslint-comments": "4.7.1",
|
|
36
|
+
"@eslint/js": "10.0.1",
|
|
37
|
+
"@eslint/markdown": "8.0.1",
|
|
38
|
+
"@release-it/conventional-changelog": "11.0.0",
|
|
39
|
+
"@types/node": "25.9.0",
|
|
40
|
+
"@vitest/coverage-v8": "4.1.5",
|
|
41
|
+
"@vitest/eslint-plugin": "1.6.16",
|
|
42
|
+
"console-fail-test": "0.6.1",
|
|
43
|
+
"create-typescript-app": "2.60.1",
|
|
44
|
+
"cspell": "10.0.0",
|
|
45
|
+
"eslint": "10.4.0",
|
|
46
|
+
"eslint-plugin-jsdoc": "63.0.0",
|
|
47
|
+
"eslint-plugin-jsonc": "3.2.0",
|
|
48
|
+
"eslint-plugin-n": "18.1.0",
|
|
49
|
+
"eslint-plugin-package-json": "1.3.0",
|
|
50
|
+
"eslint-plugin-perfectionist": "5.9.0",
|
|
51
|
+
"eslint-plugin-regexp": "3.1.0",
|
|
52
|
+
"eslint-plugin-yml": "3.4.0",
|
|
53
|
+
"husky": "9.1.7",
|
|
54
|
+
"knip": "6.16.0",
|
|
55
|
+
"lint-staged": "17.0.2",
|
|
56
|
+
"prettier": "3.8.3",
|
|
57
|
+
"prettier-plugin-curly": "0.4.1",
|
|
58
|
+
"prettier-plugin-packagejson": "3.0.2",
|
|
59
|
+
"prettier-plugin-sentences-per-line": "0.2.3",
|
|
60
|
+
"prettier-plugin-sh": "0.18.1",
|
|
61
|
+
"release-it": "20.2.0",
|
|
62
|
+
"tsdown": "0.22.0",
|
|
63
|
+
"typescript": "6.0.3",
|
|
64
|
+
"typescript-eslint": "8.61.0",
|
|
65
|
+
"vitest": "4.1.5"
|
|
79
66
|
},
|
|
80
|
-
"packageManager": "pnpm@
|
|
67
|
+
"packageManager": "pnpm@11.5.0",
|
|
81
68
|
"engines": {
|
|
82
69
|
"node": ">=18"
|
|
70
|
+
},
|
|
71
|
+
"publishConfig": {
|
|
72
|
+
"provenance": true
|
|
83
73
|
}
|
|
84
74
|
}
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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":[]}
|