@n8n/utils 1.48.1 → 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.
- package/dist/errors/ensure-error.cjs +1 -1
- package/dist/errors/ensure-error.cjs.map +1 -1
- package/dist/errors/ensure-error.mjs +1 -1
- package/dist/errors/ensure-error.mjs.map +1 -1
- package/dist/invert.cjs +11 -0
- package/dist/invert.cjs.map +1 -0
- package/dist/invert.d.cts +5 -0
- package/dist/invert.d.mts +5 -0
- package/dist/invert.mjs +10 -0
- package/dist/invert.mjs.map +1 -0
- package/dist/lru-cache.cjs +38 -0
- package/dist/lru-cache.cjs.map +1 -0
- package/dist/lru-cache.d.cts +14 -0
- package/dist/lru-cache.d.mts +14 -0
- package/dist/lru-cache.mjs +37 -0
- package/dist/lru-cache.mjs.map +1 -0
- package/dist/run-serially.cjs +16 -0
- package/dist/run-serially.cjs.map +1 -0
- package/dist/run-serially.d.cts +5 -0
- package/dist/run-serially.d.mts +5 -0
- package/dist/run-serially.mjs +15 -0
- package/dist/run-serially.mjs.map +1 -0
- package/dist/sort/partition-last.cjs +14 -0
- package/dist/sort/partition-last.cjs.map +1 -0
- package/dist/sort/partition-last.d.cts +5 -0
- package/dist/sort/partition-last.d.mts +5 -0
- package/dist/sort/partition-last.mjs +13 -0
- package/dist/sort/partition-last.mjs.map +1 -0
- package/package.json +9 -7
|
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
//#region src/errors/ensure-error.ts
|
|
3
3
|
/** Ensures `error` is an `Error */
|
|
4
4
|
function ensureError(error) {
|
|
5
|
-
return error instanceof Error ? error : new Error("Error that was not an instance of Error was thrown", { cause: error });
|
|
5
|
+
return error instanceof Error ? error : new Error("Error that was not an instance of Error was thrown", { cause: new Error(String(error)) });
|
|
6
6
|
}
|
|
7
7
|
//#endregion
|
|
8
8
|
exports.ensureError = ensureError;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensure-error.cjs","names":[],"sources":["../../src/errors/ensure-error.ts"],"sourcesContent":["/** Ensures `error` is an `Error */\nexport function ensureError(error: unknown): Error {\n\treturn error instanceof Error\n\t\t? error\n\t\t: new Error('Error that was not an instance of Error was thrown', {\n\t\t\t\t// We should never throw anything except something that derives from Error\n\t\t\t\tcause: error,\n\t\t\t});\n}\n"],"mappings":";;;AACA,SAAgB,YAAY,OAAuB;CAClD,OAAO,iBAAiB,QACrB,QACA,IAAI,MAAM,sDAAsD,
|
|
1
|
+
{"version":3,"file":"ensure-error.cjs","names":[],"sources":["../../src/errors/ensure-error.ts"],"sourcesContent":["/** Ensures `error` is an `Error */\nexport function ensureError(error: unknown): Error {\n\treturn error instanceof Error\n\t\t? error\n\t\t: new Error('Error that was not an instance of Error was thrown', {\n\t\t\t\t// We should never throw anything except something that derives from Error\n\t\t\t\t// Wrap this into an error, so error-reporter can report it\n\t\t\t\tcause: new Error(String(error)),\n\t\t\t});\n}\n"],"mappings":";;;AACA,SAAgB,YAAY,OAAuB;CAClD,OAAO,iBAAiB,QACrB,QACA,IAAI,MAAM,sDAAsD,EAGhE,OAAO,IAAI,MAAM,OAAO,KAAK,CAAC,EAC/B,CAAC;AACJ"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//#region src/errors/ensure-error.ts
|
|
2
2
|
/** Ensures `error` is an `Error */
|
|
3
3
|
function ensureError(error) {
|
|
4
|
-
return error instanceof Error ? error : new Error("Error that was not an instance of Error was thrown", { cause: error });
|
|
4
|
+
return error instanceof Error ? error : new Error("Error that was not an instance of Error was thrown", { cause: new Error(String(error)) });
|
|
5
5
|
}
|
|
6
6
|
//#endregion
|
|
7
7
|
export { ensureError };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensure-error.mjs","names":[],"sources":["../../src/errors/ensure-error.ts"],"sourcesContent":["/** Ensures `error` is an `Error */\nexport function ensureError(error: unknown): Error {\n\treturn error instanceof Error\n\t\t? error\n\t\t: new Error('Error that was not an instance of Error was thrown', {\n\t\t\t\t// We should never throw anything except something that derives from Error\n\t\t\t\tcause: error,\n\t\t\t});\n}\n"],"mappings":";;AACA,SAAgB,YAAY,OAAuB;CAClD,OAAO,iBAAiB,QACrB,QACA,IAAI,MAAM,sDAAsD,
|
|
1
|
+
{"version":3,"file":"ensure-error.mjs","names":[],"sources":["../../src/errors/ensure-error.ts"],"sourcesContent":["/** Ensures `error` is an `Error */\nexport function ensureError(error: unknown): Error {\n\treturn error instanceof Error\n\t\t? error\n\t\t: new Error('Error that was not an instance of Error was thrown', {\n\t\t\t\t// We should never throw anything except something that derives from Error\n\t\t\t\t// Wrap this into an error, so error-reporter can report it\n\t\t\t\tcause: new Error(String(error)),\n\t\t\t});\n}\n"],"mappings":";;AACA,SAAgB,YAAY,OAAuB;CAClD,OAAO,iBAAiB,QACrB,QACA,IAAI,MAAM,sDAAsD,EAGhE,OAAO,IAAI,MAAM,OAAO,KAAK,CAAC,EAC/B,CAAC;AACJ"}
|
package/dist/invert.cjs
ADDED
|
@@ -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"}
|
package/dist/invert.mjs
ADDED
|
@@ -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,16 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/run-serially.ts
|
|
3
|
+
/** Serialize work per key. A failed operation does not block later work. */
|
|
4
|
+
async function runSerially(pending, key, work) {
|
|
5
|
+
const run = (pending.get(key) ?? Promise.resolve()).catch(() => {}).then(work);
|
|
6
|
+
pending.set(key, run);
|
|
7
|
+
try {
|
|
8
|
+
return await run;
|
|
9
|
+
} finally {
|
|
10
|
+
if (pending.get(key) === run) pending.delete(key);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
exports.runSerially = runSerially;
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=run-serially.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-serially.cjs","names":[],"sources":["../src/run-serially.ts"],"sourcesContent":["/** Serialize work per key. A failed operation does not block later work. */\nexport async function runSerially<T>(\n\tpending: Map<string, Promise<unknown>>,\n\tkey: string,\n\twork: () => Promise<T>,\n): Promise<T> {\n\tconst previous = pending.get(key) ?? Promise.resolve();\n\tconst run = previous.catch(() => {}).then(work);\n\tpending.set(key, run);\n\ttry {\n\t\treturn await run;\n\t} finally {\n\t\tif (pending.get(key) === run) pending.delete(key);\n\t}\n}\n"],"mappings":";;;AACA,eAAsB,YACrB,SACA,KACA,MACa;CAEb,MAAM,OADW,QAAQ,IAAI,GAAG,KAAK,QAAQ,QAAQ,EAAA,CAChC,YAAY,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI;CAC9C,QAAQ,IAAI,KAAK,GAAG;CACpB,IAAI;EACH,OAAO,MAAM;CACd,UAAU;EACT,IAAI,QAAQ,IAAI,GAAG,MAAM,KAAK,QAAQ,OAAO,GAAG;CACjD;AACD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/run-serially.ts
|
|
2
|
+
/** Serialize work per key. A failed operation does not block later work. */
|
|
3
|
+
async function runSerially(pending, key, work) {
|
|
4
|
+
const run = (pending.get(key) ?? Promise.resolve()).catch(() => {}).then(work);
|
|
5
|
+
pending.set(key, run);
|
|
6
|
+
try {
|
|
7
|
+
return await run;
|
|
8
|
+
} finally {
|
|
9
|
+
if (pending.get(key) === run) pending.delete(key);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { runSerially };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=run-serially.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-serially.mjs","names":[],"sources":["../src/run-serially.ts"],"sourcesContent":["/** Serialize work per key. A failed operation does not block later work. */\nexport async function runSerially<T>(\n\tpending: Map<string, Promise<unknown>>,\n\tkey: string,\n\twork: () => Promise<T>,\n): Promise<T> {\n\tconst previous = pending.get(key) ?? Promise.resolve();\n\tconst run = previous.catch(() => {}).then(work);\n\tpending.set(key, run);\n\ttry {\n\t\treturn await run;\n\t} finally {\n\t\tif (pending.get(key) === run) pending.delete(key);\n\t}\n}\n"],"mappings":";;AACA,eAAsB,YACrB,SACA,KACA,MACa;CAEb,MAAM,OADW,QAAQ,IAAI,GAAG,KAAK,QAAQ,QAAQ,EAAA,CAChC,YAAY,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI;CAC9C,QAAQ,IAAI,KAAK,GAAG;CACpB,IAAI;EACH,OAAO,MAAM;CACd,UAAU;EACT,IAAI,QAAQ,IAAI,GAAG,MAAM,KAAK,QAAQ,OAAO,GAAG;CACjD;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,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,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@n8n/utils",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.50.0",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
7
7
|
"LICENSE.md",
|
|
@@ -27,19 +27,21 @@
|
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@n8n/constants": "0.
|
|
30
|
+
"@n8n/constants": "0.41.0",
|
|
31
31
|
"nanoid": "3.3.18"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@n8n/
|
|
34
|
+
"@n8n/oxlint-config": "0.0.1",
|
|
35
35
|
"@n8n/typescript-config": "1.12.0",
|
|
36
|
-
"@n8n/vitest-config": "1.
|
|
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",
|
|
42
|
-
"vitest": "
|
|
44
|
+
"vitest": "5.0.1"
|
|
43
45
|
},
|
|
44
46
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
45
47
|
"homepage": "https://n8n.io",
|
|
@@ -61,8 +63,8 @@
|
|
|
61
63
|
"test": "vitest run",
|
|
62
64
|
"test:unit": "vitest run",
|
|
63
65
|
"test:dev": "vitest --silent=false",
|
|
64
|
-
"lint": "
|
|
65
|
-
"lint: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
|
}
|