@n8n/utils 1.48.0 → 1.49.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/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/package.json +4 -4
|
@@ -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"}
|
|
@@ -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"}
|
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.49.0",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
7
7
|
"LICENSE_EE.md",
|
|
@@ -27,19 +27,19 @@
|
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@n8n/constants": "0.
|
|
30
|
+
"@n8n/constants": "0.40.0",
|
|
31
31
|
"nanoid": "3.3.18"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@n8n/eslint-config": "0.0.1",
|
|
35
35
|
"@n8n/typescript-config": "1.12.0",
|
|
36
|
-
"@n8n/vitest-config": "1.
|
|
36
|
+
"@n8n/vitest-config": "1.23.0",
|
|
37
37
|
"@testing-library/jest-dom": "^6.6.3",
|
|
38
38
|
"fast-check": "^3.23.2",
|
|
39
39
|
"tsdown": "^0.22.8",
|
|
40
40
|
"typescript": "7.0.2",
|
|
41
41
|
"vite": "^8.0.2",
|
|
42
|
-
"vitest": "
|
|
42
|
+
"vitest": "5.0.1"
|
|
43
43
|
},
|
|
44
44
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
45
45
|
"homepage": "https://n8n.io",
|