@n8n/utils 1.49.0 → 1.50.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.
@@ -0,0 +1,11 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/invert.ts
3
+ function invert(obj) {
4
+ const result = {};
5
+ for (const key in obj) result[obj[key]] = key;
6
+ return result;
7
+ }
8
+ //#endregion
9
+ exports.invert = invert;
10
+
11
+ //# sourceMappingURL=invert.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invert.cjs","names":[],"sources":["../src/invert.ts"],"sourcesContent":["export function invert<T extends Record<PropertyKey, PropertyKey>>(obj: T) {\n\tconst result = {} as Record<T[keyof T], keyof T>;\n\tfor (const key in obj) {\n\t\tresult[obj[key]] = key;\n\t}\n\treturn result;\n}\n"],"mappings":";;AAAA,SAAgB,OAAmD,KAAQ;CAC1E,MAAM,SAAS,CAAC;CAChB,KAAK,MAAM,OAAO,KACjB,OAAO,IAAI,QAAQ;CAEpB,OAAO;AACR"}
@@ -0,0 +1,5 @@
1
+ //#region src/invert.d.ts
2
+ declare function invert<T extends Record<PropertyKey, PropertyKey>>(obj: T): Record<T[keyof T], keyof T>;
3
+ //#endregion
4
+ export { invert };
5
+ //# sourceMappingURL=invert.d.cts.map
@@ -0,0 +1,5 @@
1
+ //#region src/invert.d.ts
2
+ declare function invert<T extends Record<PropertyKey, PropertyKey>>(obj: T): Record<T[keyof T], keyof T>;
3
+ //#endregion
4
+ export { invert };
5
+ //# sourceMappingURL=invert.d.mts.map
@@ -0,0 +1,10 @@
1
+ //#region src/invert.ts
2
+ function invert(obj) {
3
+ const result = {};
4
+ for (const key in obj) result[obj[key]] = key;
5
+ return result;
6
+ }
7
+ //#endregion
8
+ export { invert };
9
+
10
+ //# sourceMappingURL=invert.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invert.mjs","names":[],"sources":["../src/invert.ts"],"sourcesContent":["export function invert<T extends Record<PropertyKey, PropertyKey>>(obj: T) {\n\tconst result = {} as Record<T[keyof T], keyof T>;\n\tfor (const key in obj) {\n\t\tresult[obj[key]] = key;\n\t}\n\treturn result;\n}\n"],"mappings":";AAAA,SAAgB,OAAmD,KAAQ;CAC1E,MAAM,SAAS,CAAC;CAChB,KAAK,MAAM,OAAO,KACjB,OAAO,IAAI,QAAQ;CAEpB,OAAO;AACR"}
@@ -0,0 +1,38 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/lru-cache.ts
3
+ var LruCache = class {
4
+ capacity;
5
+ onEvict;
6
+ map = /* @__PURE__ */ new Map();
7
+ constructor(capacity, onEvict) {
8
+ this.capacity = capacity;
9
+ this.onEvict = onEvict;
10
+ if (capacity < 1) throw new Error("LruCache capacity must be at least 1");
11
+ }
12
+ get(key) {
13
+ const value = this.map.get(key);
14
+ if (value === void 0) return void 0;
15
+ this.map.delete(key);
16
+ this.map.set(key, value);
17
+ return value;
18
+ }
19
+ set(key, value) {
20
+ this.map.delete(key);
21
+ this.map.set(key, value);
22
+ if (this.map.size > this.capacity) {
23
+ const [oldestKey, oldestValue] = this.map.entries().next().value;
24
+ this.map.delete(oldestKey);
25
+ this.onEvict?.(oldestKey, oldestValue);
26
+ }
27
+ }
28
+ get size() {
29
+ return this.map.size;
30
+ }
31
+ clear() {
32
+ this.map.clear();
33
+ }
34
+ };
35
+ //#endregion
36
+ exports.LruCache = LruCache;
37
+
38
+ //# sourceMappingURL=lru-cache.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lru-cache.cjs","names":[],"sources":["../src/lru-cache.ts"],"sourcesContent":["export class LruCache<K, V> {\n\tprivate map = new Map<K, V>();\n\n\tconstructor(\n\t\tprivate readonly capacity: number,\n\t\tprivate readonly onEvict?: (key: K, value: V) => void,\n\t) {\n\t\tif (capacity < 1) {\n\t\t\tthrow new Error('LruCache capacity must be at least 1');\n\t\t}\n\t}\n\n\tget(key: K): V | undefined {\n\t\tconst value = this.map.get(key);\n\t\tif (value === undefined) return undefined;\n\t\tthis.map.delete(key);\n\t\tthis.map.set(key, value);\n\t\treturn value;\n\t}\n\n\tset(key: K, value: V): void {\n\t\tthis.map.delete(key);\n\t\tthis.map.set(key, value);\n\t\tif (this.map.size > this.capacity) {\n\t\t\tconst [oldestKey, oldestValue] = this.map.entries().next().value!;\n\t\t\tthis.map.delete(oldestKey);\n\t\t\tthis.onEvict?.(oldestKey, oldestValue);\n\t\t}\n\t}\n\n\tget size(): number {\n\t\treturn this.map.size;\n\t}\n\n\tclear(): void {\n\t\tthis.map.clear();\n\t}\n}\n"],"mappings":";;AAAA,IAAa,WAAb,MAA4B;CAIT;CACA;CAJlB,sBAAc,IAAI,IAAU;CAE5B,YACC,UACA,SACC;EAFgB,KAAA,WAAA;EACA,KAAA,UAAA;EAEjB,IAAI,WAAW,GACd,MAAM,IAAI,MAAM,sCAAsC;CAExD;CAEA,IAAI,KAAuB;EAC1B,MAAM,QAAQ,KAAK,IAAI,IAAI,GAAG;EAC9B,IAAI,UAAU,KAAA,GAAW,OAAO,KAAA;EAChC,KAAK,IAAI,OAAO,GAAG;EACnB,KAAK,IAAI,IAAI,KAAK,KAAK;EACvB,OAAO;CACR;CAEA,IAAI,KAAQ,OAAgB;EAC3B,KAAK,IAAI,OAAO,GAAG;EACnB,KAAK,IAAI,IAAI,KAAK,KAAK;EACvB,IAAI,KAAK,IAAI,OAAO,KAAK,UAAU;GAClC,MAAM,CAAC,WAAW,eAAe,KAAK,IAAI,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC;GAC3D,KAAK,IAAI,OAAO,SAAS;GACzB,KAAK,UAAU,WAAW,WAAW;EACtC;CACD;CAEA,IAAI,OAAe;EAClB,OAAO,KAAK,IAAI;CACjB;CAEA,QAAc;EACb,KAAK,IAAI,MAAM;CAChB;AACD"}
@@ -0,0 +1,14 @@
1
+ //#region src/lru-cache.d.ts
2
+ declare class LruCache<K, V> {
3
+ private readonly capacity;
4
+ private readonly onEvict?;
5
+ private map;
6
+ constructor(capacity: number, onEvict?: ((key: K, value: V) => void) | undefined);
7
+ get(key: K): V | undefined;
8
+ set(key: K, value: V): void;
9
+ get size(): number;
10
+ clear(): void;
11
+ }
12
+ //#endregion
13
+ export { LruCache };
14
+ //# sourceMappingURL=lru-cache.d.cts.map
@@ -0,0 +1,14 @@
1
+ //#region src/lru-cache.d.ts
2
+ declare class LruCache<K, V> {
3
+ private readonly capacity;
4
+ private readonly onEvict?;
5
+ private map;
6
+ constructor(capacity: number, onEvict?: ((key: K, value: V) => void) | undefined);
7
+ get(key: K): V | undefined;
8
+ set(key: K, value: V): void;
9
+ get size(): number;
10
+ clear(): void;
11
+ }
12
+ //#endregion
13
+ export { LruCache };
14
+ //# sourceMappingURL=lru-cache.d.mts.map
@@ -0,0 +1,37 @@
1
+ //#region src/lru-cache.ts
2
+ var LruCache = class {
3
+ capacity;
4
+ onEvict;
5
+ map = /* @__PURE__ */ new Map();
6
+ constructor(capacity, onEvict) {
7
+ this.capacity = capacity;
8
+ this.onEvict = onEvict;
9
+ if (capacity < 1) throw new Error("LruCache capacity must be at least 1");
10
+ }
11
+ get(key) {
12
+ const value = this.map.get(key);
13
+ if (value === void 0) return void 0;
14
+ this.map.delete(key);
15
+ this.map.set(key, value);
16
+ return value;
17
+ }
18
+ set(key, value) {
19
+ this.map.delete(key);
20
+ this.map.set(key, value);
21
+ if (this.map.size > this.capacity) {
22
+ const [oldestKey, oldestValue] = this.map.entries().next().value;
23
+ this.map.delete(oldestKey);
24
+ this.onEvict?.(oldestKey, oldestValue);
25
+ }
26
+ }
27
+ get size() {
28
+ return this.map.size;
29
+ }
30
+ clear() {
31
+ this.map.clear();
32
+ }
33
+ };
34
+ //#endregion
35
+ export { LruCache };
36
+
37
+ //# sourceMappingURL=lru-cache.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lru-cache.mjs","names":[],"sources":["../src/lru-cache.ts"],"sourcesContent":["export class LruCache<K, V> {\n\tprivate map = new Map<K, V>();\n\n\tconstructor(\n\t\tprivate readonly capacity: number,\n\t\tprivate readonly onEvict?: (key: K, value: V) => void,\n\t) {\n\t\tif (capacity < 1) {\n\t\t\tthrow new Error('LruCache capacity must be at least 1');\n\t\t}\n\t}\n\n\tget(key: K): V | undefined {\n\t\tconst value = this.map.get(key);\n\t\tif (value === undefined) return undefined;\n\t\tthis.map.delete(key);\n\t\tthis.map.set(key, value);\n\t\treturn value;\n\t}\n\n\tset(key: K, value: V): void {\n\t\tthis.map.delete(key);\n\t\tthis.map.set(key, value);\n\t\tif (this.map.size > this.capacity) {\n\t\t\tconst [oldestKey, oldestValue] = this.map.entries().next().value!;\n\t\t\tthis.map.delete(oldestKey);\n\t\t\tthis.onEvict?.(oldestKey, oldestValue);\n\t\t}\n\t}\n\n\tget size(): number {\n\t\treturn this.map.size;\n\t}\n\n\tclear(): void {\n\t\tthis.map.clear();\n\t}\n}\n"],"mappings":";AAAA,IAAa,WAAb,MAA4B;CAIT;CACA;CAJlB,sBAAc,IAAI,IAAU;CAE5B,YACC,UACA,SACC;EAFgB,KAAA,WAAA;EACA,KAAA,UAAA;EAEjB,IAAI,WAAW,GACd,MAAM,IAAI,MAAM,sCAAsC;CAExD;CAEA,IAAI,KAAuB;EAC1B,MAAM,QAAQ,KAAK,IAAI,IAAI,GAAG;EAC9B,IAAI,UAAU,KAAA,GAAW,OAAO,KAAA;EAChC,KAAK,IAAI,OAAO,GAAG;EACnB,KAAK,IAAI,IAAI,KAAK,KAAK;EACvB,OAAO;CACR;CAEA,IAAI,KAAQ,OAAgB;EAC3B,KAAK,IAAI,OAAO,GAAG;EACnB,KAAK,IAAI,IAAI,KAAK,KAAK;EACvB,IAAI,KAAK,IAAI,OAAO,KAAK,UAAU;GAClC,MAAM,CAAC,WAAW,eAAe,KAAK,IAAI,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC;GAC3D,KAAK,IAAI,OAAO,SAAS;GACzB,KAAK,UAAU,WAAW,WAAW;EACtC;CACD;CAEA,IAAI,OAAe;EAClB,OAAO,KAAK,IAAI;CACjB;CAEA,QAAc;EACb,KAAK,IAAI,MAAM;CAChB;AACD"}
@@ -0,0 +1,14 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/sort/partition-last.ts
3
+ /** Stable: moves matches to the end. Returns `items` itself when nothing matches. */
4
+ function partitionLast(items, predicate) {
5
+ const rest = [];
6
+ const last = [];
7
+ for (const item of items) (predicate(item) ? last : rest).push(item);
8
+ if (last.length === 0) return items;
9
+ return [...rest, ...last];
10
+ }
11
+ //#endregion
12
+ exports.partitionLast = partitionLast;
13
+
14
+ //# sourceMappingURL=partition-last.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"partition-last.cjs","names":[],"sources":["../../src/sort/partition-last.ts"],"sourcesContent":["/** Stable: moves matches to the end. Returns `items` itself when nothing matches. */\nexport function partitionLast<T>(items: T[], predicate: (item: T) => boolean): T[] {\n\tconst rest: T[] = [];\n\tconst last: T[] = [];\n\tfor (const item of items) {\n\t\t(predicate(item) ? last : rest).push(item);\n\t}\n\tif (last.length === 0) return items;\n\n\treturn [...rest, ...last];\n}\n"],"mappings":";;;AACA,SAAgB,cAAiB,OAAY,WAAsC;CAClF,MAAM,OAAY,CAAC;CACnB,MAAM,OAAY,CAAC;CACnB,KAAK,MAAM,QAAQ,OAClB,CAAC,UAAU,IAAI,IAAI,OAAO,KAAA,CAAM,KAAK,IAAI;CAE1C,IAAI,KAAK,WAAW,GAAG,OAAO;CAE9B,OAAO,CAAC,GAAG,MAAM,GAAG,IAAI;AACzB"}
@@ -0,0 +1,5 @@
1
+ //#region src/sort/partition-last.d.ts
2
+ declare function partitionLast<T>(items: T[], predicate: (item: T) => boolean): T[];
3
+ //#endregion
4
+ export { partitionLast };
5
+ //# sourceMappingURL=partition-last.d.cts.map
@@ -0,0 +1,5 @@
1
+ //#region src/sort/partition-last.d.ts
2
+ declare function partitionLast<T>(items: T[], predicate: (item: T) => boolean): T[];
3
+ //#endregion
4
+ export { partitionLast };
5
+ //# sourceMappingURL=partition-last.d.mts.map
@@ -0,0 +1,13 @@
1
+ //#region src/sort/partition-last.ts
2
+ /** Stable: moves matches to the end. Returns `items` itself when nothing matches. */
3
+ function partitionLast(items, predicate) {
4
+ const rest = [];
5
+ const last = [];
6
+ for (const item of items) (predicate(item) ? last : rest).push(item);
7
+ if (last.length === 0) return items;
8
+ return [...rest, ...last];
9
+ }
10
+ //#endregion
11
+ export { partitionLast };
12
+
13
+ //# sourceMappingURL=partition-last.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"partition-last.mjs","names":[],"sources":["../../src/sort/partition-last.ts"],"sourcesContent":["/** Stable: moves matches to the end. Returns `items` itself when nothing matches. */\nexport function partitionLast<T>(items: T[], predicate: (item: T) => boolean): T[] {\n\tconst rest: T[] = [];\n\tconst last: T[] = [];\n\tfor (const item of items) {\n\t\t(predicate(item) ? last : rest).push(item);\n\t}\n\tif (last.length === 0) return items;\n\n\treturn [...rest, ...last];\n}\n"],"mappings":";;AACA,SAAgB,cAAiB,OAAY,WAAsC;CAClF,MAAM,OAAY,CAAC;CACnB,MAAM,OAAY,CAAC;CACnB,KAAK,MAAM,QAAQ,OAClB,CAAC,UAAU,IAAI,IAAI,OAAO,KAAA,CAAM,KAAK,IAAI;CAE1C,IAAI,KAAK,WAAW,GAAG,OAAO;CAE9B,OAAO,CAAC,GAAG,MAAM,GAAG,IAAI;AACzB"}
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@n8n/utils",
3
3
  "type": "module",
4
- "version": "1.49.0",
4
+ "version": "1.50.0",
5
5
  "files": [
6
6
  "dist",
7
- "LICENSE_EE.md",
8
- "LICENSE.md"
7
+ "LICENSE.md",
8
+ "LICENSE_EE.md"
9
9
  ],
10
10
  "exports": {
11
11
  "./dist/*": {
@@ -27,15 +27,17 @@
27
27
  }
28
28
  },
29
29
  "dependencies": {
30
- "@n8n/constants": "0.40.0",
30
+ "@n8n/constants": "0.41.0",
31
31
  "nanoid": "3.3.18"
32
32
  },
33
33
  "devDependencies": {
34
- "@n8n/eslint-config": "0.0.1",
34
+ "@n8n/oxlint-config": "0.0.1",
35
35
  "@n8n/typescript-config": "1.12.0",
36
- "@n8n/vitest-config": "1.23.0",
36
+ "@n8n/vitest-config": "1.24.0",
37
37
  "@testing-library/jest-dom": "^6.6.3",
38
38
  "fast-check": "^3.23.2",
39
+ "oxlint": "1.78.0",
40
+ "oxlint-tsgolint": "^0.21.1",
39
41
  "tsdown": "^0.22.8",
40
42
  "typescript": "7.0.2",
41
43
  "vite": "^8.0.2",
@@ -61,8 +63,8 @@
61
63
  "test": "vitest run",
62
64
  "test:unit": "vitest run",
63
65
  "test:dev": "vitest --silent=false",
64
- "lint": "eslint src --quiet",
65
- "lint:fix": "eslint src --fix",
66
+ "lint": "oxlint src --quiet",
67
+ "lint:fix": "oxlint src --fix",
66
68
  "format": "biome format --write . && prettier --write . --ignore-path ../../../.prettierignore",
67
69
  "format:check": "biome ci . && prettier --check . --ignore-path ../../../.prettierignore"
68
70
  }