utilium 2.8.7 → 2.8.8

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/dist/fs.d.ts CHANGED
@@ -9,6 +9,8 @@ export declare abstract class FileMap<V> implements Map<string, V> {
9
9
  abstract get(key: string): V;
10
10
  abstract has(key: string): boolean;
11
11
  abstract set(key: string, value: V): this;
12
+ getOrInsert(key: string, defaultValue: V): V;
13
+ getOrInsertComputed(key: string, callback: (key: string) => V): V;
12
14
  get size(): number;
13
15
  get [Symbol.iterator](): () => MapIterator<[string, V]>;
14
16
  get keys(): typeof this._map.keys;
package/dist/fs.js CHANGED
@@ -13,6 +13,18 @@ export class FileMap {
13
13
  throw new ReferenceError('No path specified');
14
14
  }
15
15
  }
16
+ getOrInsert(key, defaultValue) {
17
+ if (this.has(key)) {
18
+ return this.get(key);
19
+ }
20
+ return this.set(key, defaultValue).get(key);
21
+ }
22
+ getOrInsertComputed(key, callback) {
23
+ if (this.has(key)) {
24
+ return this.get(key);
25
+ }
26
+ return this.set(key, callback(key)).get(key);
27
+ }
16
28
  get size() {
17
29
  return this._map.size;
18
30
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "utilium",
3
- "version": "2.8.7",
3
+ "version": "2.8.8",
4
4
  "description": "Typescript utilities",
5
5
  "funding": {
6
6
  "type": "individual",
@@ -39,15 +39,15 @@
39
39
  },
40
40
  "homepage": "https://github.com/james-pre/utilium#readme",
41
41
  "devDependencies": {
42
- "@eslint/js": "^9.12.0",
42
+ "@eslint/js": "^10.0.1",
43
43
  "@types/node": "^24.7.0",
44
- "eslint": "^9.12.0",
44
+ "eslint": "^10.1.0",
45
45
  "globals": "^15.10.0",
46
46
  "prettier": "^3.2.5",
47
47
  "tsx": "^4.19.1",
48
- "typedoc": "^0.28.13",
49
- "typescript": "^5.7.2",
50
- "typescript-eslint": "^8.8.0"
48
+ "typedoc": "^0.28.18",
49
+ "typescript": "^6.0.0",
50
+ "typescript-eslint": "^8.58.0"
51
51
  },
52
52
  "dependencies": {
53
53
  "eventemitter3": "^5.0.1"