@n8n/utils 1.20.0 → 1.22.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,3 @@
1
+ const require_path = require('../path.cjs');
2
+
3
+ exports.isWindowsFilePath = require_path.isWindowsFilePath;
@@ -0,0 +1,2 @@
1
+ import { t as isWindowsFilePath } from "../path.cjs";
2
+ export { isWindowsFilePath };
@@ -0,0 +1,2 @@
1
+ import { t as isWindowsFilePath } from "../path.mjs";
2
+ export { isWindowsFilePath };
@@ -0,0 +1,3 @@
1
+ import { t as isWindowsFilePath } from "../path.mjs";
2
+
3
+ export { isWindowsFilePath };
package/dist/index.cjs CHANGED
@@ -8,11 +8,13 @@ const require_sublimeSearch = require('./sublimeSearch.cjs');
8
8
  const require_sortByProperty = require('./sortByProperty.cjs');
9
9
  const require_truncate = require('./truncate.cjs');
10
10
  const require_sanitize = require('./sanitize.cjs');
11
+ const require_path = require('./path.cjs');
11
12
 
12
13
  exports.DEFAULT_KEYS = require_sublimeSearch.DEFAULT_KEYS;
13
14
  exports.assert = require_assert.assert;
14
15
  exports.createEventBus = require_event_bus.createEventBus;
15
16
  exports.createEventQueue = require_event_queue.createEventQueue;
17
+ exports.isWindowsFilePath = require_path.isWindowsFilePath;
16
18
  exports.reRankSearchResults = require_reRankSearchResults.reRankSearchResults;
17
19
  exports.retry = require_retry.retry;
18
20
  exports.sanitizeFilename = require_sanitize.sanitizeFilename;
package/dist/index.d.cts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { t as assert } from "./assert2.cjs";
2
2
  import { n as EventBus, r as createEventBus, t as CallbackFn } from "./event-bus2.cjs";
3
3
  import { t as createEventQueue } from "./event-queue2.cjs";
4
+ import { t as isWindowsFilePath } from "./path.cjs";
4
5
  import { t as sanitizeFilename } from "./sanitize.cjs";
5
6
  import { t as retry } from "./retry2.cjs";
6
7
  import { t as smartDecimal } from "./smartDecimal.cjs";
@@ -8,4 +9,4 @@ import { t as reRankSearchResults } from "./reRankSearchResults.cjs";
8
9
  import { n as sublimeSearch, t as DEFAULT_KEYS } from "./sublimeSearch.cjs";
9
10
  import { t as sortByProperty } from "./sortByProperty.cjs";
10
11
  import { n as truncateBeforeLast, t as truncate } from "./truncate.cjs";
11
- export { CallbackFn, DEFAULT_KEYS, EventBus, assert, createEventBus, createEventQueue, reRankSearchResults, retry, sanitizeFilename, smartDecimal, sortByProperty, sublimeSearch, truncate, truncateBeforeLast };
12
+ export { CallbackFn, DEFAULT_KEYS, EventBus, assert, createEventBus, createEventQueue, isWindowsFilePath, reRankSearchResults, retry, sanitizeFilename, smartDecimal, sortByProperty, sublimeSearch, truncate, truncateBeforeLast };
package/dist/index.d.mts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { t as assert } from "./assert2.mjs";
2
2
  import { n as EventBus, r as createEventBus, t as CallbackFn } from "./event-bus2.mjs";
3
3
  import { t as createEventQueue } from "./event-queue2.mjs";
4
+ import { t as isWindowsFilePath } from "./path.mjs";
4
5
  import { t as sanitizeFilename } from "./sanitize.mjs";
5
6
  import { t as retry } from "./retry2.mjs";
6
7
  import { t as smartDecimal } from "./smartDecimal.mjs";
@@ -8,4 +9,4 @@ import { t as reRankSearchResults } from "./reRankSearchResults.mjs";
8
9
  import { n as sublimeSearch, t as DEFAULT_KEYS } from "./sublimeSearch.mjs";
9
10
  import { t as sortByProperty } from "./sortByProperty.mjs";
10
11
  import { n as truncateBeforeLast, t as truncate } from "./truncate.mjs";
11
- export { CallbackFn, DEFAULT_KEYS, EventBus, assert, createEventBus, createEventQueue, reRankSearchResults, retry, sanitizeFilename, smartDecimal, sortByProperty, sublimeSearch, truncate, truncateBeforeLast };
12
+ export { CallbackFn, DEFAULT_KEYS, EventBus, assert, createEventBus, createEventQueue, isWindowsFilePath, reRankSearchResults, retry, sanitizeFilename, smartDecimal, sortByProperty, sublimeSearch, truncate, truncateBeforeLast };
package/dist/index.mjs CHANGED
@@ -8,5 +8,6 @@ import { n as sublimeSearch, t as DEFAULT_KEYS } from "./sublimeSearch.mjs";
8
8
  import { t as sortByProperty } from "./sortByProperty.mjs";
9
9
  import { n as truncateBeforeLast, t as truncate } from "./truncate.mjs";
10
10
  import { t as sanitizeFilename } from "./sanitize.mjs";
11
+ import { t as isWindowsFilePath } from "./path.mjs";
11
12
 
12
- export { DEFAULT_KEYS, assert, createEventBus, createEventQueue, reRankSearchResults, retry, sanitizeFilename, smartDecimal, sortByProperty, sublimeSearch, truncate, truncateBeforeLast };
13
+ export { DEFAULT_KEYS, assert, createEventBus, createEventQueue, isWindowsFilePath, reRankSearchResults, retry, sanitizeFilename, smartDecimal, sortByProperty, sublimeSearch, truncate, truncateBeforeLast };
package/dist/path.cjs ADDED
@@ -0,0 +1,17 @@
1
+
2
+ //#region src/files/path.ts
3
+ /**
4
+ * Fast check if file path starts with a windows drive letter, e.g. 'C:/' or 'C:\\'
5
+ */
6
+ function isWindowsFilePath(str) {
7
+ return /^[a-zA-Z]:[\\/]/.test(str);
8
+ }
9
+
10
+ //#endregion
11
+ Object.defineProperty(exports, 'isWindowsFilePath', {
12
+ enumerable: true,
13
+ get: function () {
14
+ return isWindowsFilePath;
15
+ }
16
+ });
17
+ //# sourceMappingURL=path.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path.cjs","names":[],"sources":["../src/files/path.ts"],"sourcesContent":["/**\n * Fast check if file path starts with a windows drive letter, e.g. 'C:/' or 'C:\\\\'\n */\nexport function isWindowsFilePath(str: string) {\n\treturn /^[a-zA-Z]:[\\\\/]/.test(str);\n}\n"],"mappings":";;;;;AAGA,SAAgB,kBAAkB,KAAa;AAC9C,QAAO,kBAAkB,KAAK,IAAI"}
@@ -0,0 +1,5 @@
1
+ //#region src/files/path.d.ts
2
+ declare function isWindowsFilePath(str: string): boolean;
3
+ //#endregion
4
+ export { isWindowsFilePath as t };
5
+ //# sourceMappingURL=path.d.cts.map
@@ -0,0 +1,5 @@
1
+ //#region src/files/path.d.ts
2
+ declare function isWindowsFilePath(str: string): boolean;
3
+ //#endregion
4
+ export { isWindowsFilePath as t };
5
+ //# sourceMappingURL=path.d.mts.map
package/dist/path.mjs ADDED
@@ -0,0 +1,11 @@
1
+ //#region src/files/path.ts
2
+ /**
3
+ * Fast check if file path starts with a windows drive letter, e.g. 'C:/' or 'C:\\'
4
+ */
5
+ function isWindowsFilePath(str) {
6
+ return /^[a-zA-Z]:[\\/]/.test(str);
7
+ }
8
+
9
+ //#endregion
10
+ export { isWindowsFilePath as t };
11
+ //# sourceMappingURL=path.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path.mjs","names":[],"sources":["../src/files/path.ts"],"sourcesContent":["/**\n * Fast check if file path starts with a windows drive letter, e.g. 'C:/' or 'C:\\\\'\n */\nexport function isWindowsFilePath(str: string) {\n\treturn /^[a-zA-Z]:[\\\\/]/.test(str);\n}\n"],"mappings":";;;;AAGA,SAAgB,kBAAkB,KAAa;AAC9C,QAAO,kBAAkB,KAAK,IAAI"}
package/dist/truncate.cjs CHANGED
@@ -7,7 +7,7 @@ const truncate = (text, length = 30) => text.length > length ? text.slice(0, len
7
7
  * - Remove chars just before the last word, as long as the last word is under 15 chars
8
8
  * - Otherwise preserve the last 5 chars of the name and remove chars before that
9
9
  */
10
- function truncateBeforeLast(text, maxLength) {
10
+ function truncateBeforeLast(text, maxLength, lastCharsLength = 5) {
11
11
  const chars = [];
12
12
  const segmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" });
13
13
  for (const { segment } of segmenter.segment(text)) chars.push(segment);
@@ -22,7 +22,8 @@ function truncateBeforeLast(text, maxLength) {
22
22
  const keepLength = indexBeforeLastWord - charsToRemove;
23
23
  if (keepLength > 0) return chars.slice(0, keepLength).join("") + ellipsis + chars.slice(indexBeforeLastWord).join("");
24
24
  }
25
- return chars.slice(0, maxLength - 5 - ellipsisLength).join("") + ellipsis + chars.slice(-5).join("");
25
+ if (lastCharsLength < 1) return chars.slice(0, maxLength).join("") + ellipsis;
26
+ return chars.slice(0, maxLength - lastCharsLength - ellipsisLength).join("") + ellipsis + chars.slice(-lastCharsLength).join("");
26
27
  }
27
28
 
28
29
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"truncate.cjs","names":["chars: string[]"],"sources":["../src/string/truncate.ts"],"sourcesContent":["export const truncate = (text: string, length = 30): string =>\n\ttext.length > length ? text.slice(0, length) + '...' : text;\n\n/**\n * Replace part of given text with ellipsis following the rules below:\n *\n * - Remove chars just before the last word, as long as the last word is under 15 chars\n * - Otherwise preserve the last 5 chars of the name and remove chars before that\n */\nexport function truncateBeforeLast(text: string, maxLength: number): string {\n\tconst chars: string[] = [];\n\n\tconst segmenter = new Intl.Segmenter(undefined, { granularity: 'grapheme' });\n\n\tfor (const { segment } of segmenter.segment(text)) {\n\t\tchars.push(segment);\n\t}\n\n\tif (chars.length <= maxLength) {\n\t\treturn text;\n\t}\n\n\tconst lastWhitespaceIndex = chars.findLastIndex((ch) => ch.match(/^\\s+$/));\n\tconst lastWordIndex = lastWhitespaceIndex + 1;\n\tconst lastWord = chars.slice(lastWordIndex);\n\tconst ellipsis = '…';\n\tconst ellipsisLength = ellipsis.length;\n\n\tif (lastWord.length < 15) {\n\t\tconst charsToRemove = chars.length - maxLength + ellipsisLength;\n\t\tconst indexBeforeLastWord = lastWordIndex;\n\t\tconst keepLength = indexBeforeLastWord - charsToRemove;\n\n\t\tif (keepLength > 0) {\n\t\t\treturn (\n\t\t\t\tchars.slice(0, keepLength).join('') + ellipsis + chars.slice(indexBeforeLastWord).join('')\n\t\t\t);\n\t\t}\n\t}\n\n\treturn (\n\t\tchars.slice(0, maxLength - 5 - ellipsisLength).join('') + ellipsis + chars.slice(-5).join('')\n\t);\n}\n"],"mappings":";;AAAA,MAAa,YAAY,MAAc,SAAS,OAC/C,KAAK,SAAS,SAAS,KAAK,MAAM,GAAG,OAAO,GAAG,QAAQ;;;;;;;AAQxD,SAAgB,mBAAmB,MAAc,WAA2B;CAC3E,MAAMA,QAAkB,EAAE;CAE1B,MAAM,YAAY,IAAI,KAAK,UAAU,QAAW,EAAE,aAAa,YAAY,CAAC;AAE5E,MAAK,MAAM,EAAE,aAAa,UAAU,QAAQ,KAAK,CAChD,OAAM,KAAK,QAAQ;AAGpB,KAAI,MAAM,UAAU,UACnB,QAAO;CAIR,MAAM,gBADsB,MAAM,eAAe,OAAO,GAAG,MAAM,QAAQ,CAAC,GAC9B;CAC5C,MAAM,WAAW,MAAM,MAAM,cAAc;CAC3C,MAAM,WAAW;CACjB,MAAM,iBAAiB;AAEvB,KAAI,SAAS,SAAS,IAAI;EACzB,MAAM,gBAAgB,MAAM,SAAS,YAAY;EACjD,MAAM,sBAAsB;EAC5B,MAAM,aAAa,sBAAsB;AAEzC,MAAI,aAAa,EAChB,QACC,MAAM,MAAM,GAAG,WAAW,CAAC,KAAK,GAAG,GAAG,WAAW,MAAM,MAAM,oBAAoB,CAAC,KAAK,GAAG;;AAK7F,QACC,MAAM,MAAM,GAAG,YAAY,IAAI,eAAe,CAAC,KAAK,GAAG,GAAG,WAAW,MAAM,MAAM,GAAG,CAAC,KAAK,GAAG"}
1
+ {"version":3,"file":"truncate.cjs","names":["chars: string[]"],"sources":["../src/string/truncate.ts"],"sourcesContent":["export const truncate = (text: string, length = 30): string =>\n\ttext.length > length ? text.slice(0, length) + '...' : text;\n\n/**\n * Replace part of given text with ellipsis following the rules below:\n *\n * - Remove chars just before the last word, as long as the last word is under 15 chars\n * - Otherwise preserve the last 5 chars of the name and remove chars before that\n */\nexport function truncateBeforeLast(\n\ttext: string,\n\tmaxLength: number,\n\tlastCharsLength: number = 5,\n): string {\n\tconst chars: string[] = [];\n\n\tconst segmenter = new Intl.Segmenter(undefined, { granularity: 'grapheme' });\n\n\tfor (const { segment } of segmenter.segment(text)) {\n\t\tchars.push(segment);\n\t}\n\n\tif (chars.length <= maxLength) {\n\t\treturn text;\n\t}\n\n\tconst lastWhitespaceIndex = chars.findLastIndex((ch) => ch.match(/^\\s+$/));\n\tconst lastWordIndex = lastWhitespaceIndex + 1;\n\tconst lastWord = chars.slice(lastWordIndex);\n\tconst ellipsis = '…';\n\tconst ellipsisLength = ellipsis.length;\n\n\tif (lastWord.length < 15) {\n\t\tconst charsToRemove = chars.length - maxLength + ellipsisLength;\n\t\tconst indexBeforeLastWord = lastWordIndex;\n\t\tconst keepLength = indexBeforeLastWord - charsToRemove;\n\n\t\tif (keepLength > 0) {\n\t\t\treturn (\n\t\t\t\tchars.slice(0, keepLength).join('') + ellipsis + chars.slice(indexBeforeLastWord).join('')\n\t\t\t);\n\t\t}\n\t}\n\n\tif (lastCharsLength < 1) {\n\t\treturn chars.slice(0, maxLength).join('') + ellipsis;\n\t}\n\n\treturn (\n\t\tchars.slice(0, maxLength - lastCharsLength - ellipsisLength).join('') +\n\t\tellipsis +\n\t\tchars.slice(-lastCharsLength).join('')\n\t);\n}\n"],"mappings":";;AAAA,MAAa,YAAY,MAAc,SAAS,OAC/C,KAAK,SAAS,SAAS,KAAK,MAAM,GAAG,OAAO,GAAG,QAAQ;;;;;;;AAQxD,SAAgB,mBACf,MACA,WACA,kBAA0B,GACjB;CACT,MAAMA,QAAkB,EAAE;CAE1B,MAAM,YAAY,IAAI,KAAK,UAAU,QAAW,EAAE,aAAa,YAAY,CAAC;AAE5E,MAAK,MAAM,EAAE,aAAa,UAAU,QAAQ,KAAK,CAChD,OAAM,KAAK,QAAQ;AAGpB,KAAI,MAAM,UAAU,UACnB,QAAO;CAIR,MAAM,gBADsB,MAAM,eAAe,OAAO,GAAG,MAAM,QAAQ,CAAC,GAC9B;CAC5C,MAAM,WAAW,MAAM,MAAM,cAAc;CAC3C,MAAM,WAAW;CACjB,MAAM,iBAAiB;AAEvB,KAAI,SAAS,SAAS,IAAI;EACzB,MAAM,gBAAgB,MAAM,SAAS,YAAY;EACjD,MAAM,sBAAsB;EAC5B,MAAM,aAAa,sBAAsB;AAEzC,MAAI,aAAa,EAChB,QACC,MAAM,MAAM,GAAG,WAAW,CAAC,KAAK,GAAG,GAAG,WAAW,MAAM,MAAM,oBAAoB,CAAC,KAAK,GAAG;;AAK7F,KAAI,kBAAkB,EACrB,QAAO,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,GAAG,GAAG;AAG7C,QACC,MAAM,MAAM,GAAG,YAAY,kBAAkB,eAAe,CAAC,KAAK,GAAG,GACrE,WACA,MAAM,MAAM,CAAC,gBAAgB,CAAC,KAAK,GAAG"}
@@ -1,6 +1,6 @@
1
1
  //#region src/string/truncate.d.ts
2
2
  declare const truncate: (text: string, length?: number) => string;
3
- declare function truncateBeforeLast(text: string, maxLength: number): string;
3
+ declare function truncateBeforeLast(text: string, maxLength: number, lastCharsLength?: number): string;
4
4
  //#endregion
5
5
  export { truncateBeforeLast as n, truncate as t };
6
6
  //# sourceMappingURL=truncate.d.cts.map
@@ -1,6 +1,6 @@
1
1
  //#region src/string/truncate.d.ts
2
2
  declare const truncate: (text: string, length?: number) => string;
3
- declare function truncateBeforeLast(text: string, maxLength: number): string;
3
+ declare function truncateBeforeLast(text: string, maxLength: number, lastCharsLength?: number): string;
4
4
  //#endregion
5
5
  export { truncateBeforeLast as n, truncate as t };
6
6
  //# sourceMappingURL=truncate.d.mts.map
package/dist/truncate.mjs CHANGED
@@ -6,7 +6,7 @@ const truncate = (text, length = 30) => text.length > length ? text.slice(0, len
6
6
  * - Remove chars just before the last word, as long as the last word is under 15 chars
7
7
  * - Otherwise preserve the last 5 chars of the name and remove chars before that
8
8
  */
9
- function truncateBeforeLast(text, maxLength) {
9
+ function truncateBeforeLast(text, maxLength, lastCharsLength = 5) {
10
10
  const chars = [];
11
11
  const segmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" });
12
12
  for (const { segment } of segmenter.segment(text)) chars.push(segment);
@@ -21,7 +21,8 @@ function truncateBeforeLast(text, maxLength) {
21
21
  const keepLength = indexBeforeLastWord - charsToRemove;
22
22
  if (keepLength > 0) return chars.slice(0, keepLength).join("") + ellipsis + chars.slice(indexBeforeLastWord).join("");
23
23
  }
24
- return chars.slice(0, maxLength - 5 - ellipsisLength).join("") + ellipsis + chars.slice(-5).join("");
24
+ if (lastCharsLength < 1) return chars.slice(0, maxLength).join("") + ellipsis;
25
+ return chars.slice(0, maxLength - lastCharsLength - ellipsisLength).join("") + ellipsis + chars.slice(-lastCharsLength).join("");
25
26
  }
26
27
 
27
28
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"truncate.mjs","names":["chars: string[]"],"sources":["../src/string/truncate.ts"],"sourcesContent":["export const truncate = (text: string, length = 30): string =>\n\ttext.length > length ? text.slice(0, length) + '...' : text;\n\n/**\n * Replace part of given text with ellipsis following the rules below:\n *\n * - Remove chars just before the last word, as long as the last word is under 15 chars\n * - Otherwise preserve the last 5 chars of the name and remove chars before that\n */\nexport function truncateBeforeLast(text: string, maxLength: number): string {\n\tconst chars: string[] = [];\n\n\tconst segmenter = new Intl.Segmenter(undefined, { granularity: 'grapheme' });\n\n\tfor (const { segment } of segmenter.segment(text)) {\n\t\tchars.push(segment);\n\t}\n\n\tif (chars.length <= maxLength) {\n\t\treturn text;\n\t}\n\n\tconst lastWhitespaceIndex = chars.findLastIndex((ch) => ch.match(/^\\s+$/));\n\tconst lastWordIndex = lastWhitespaceIndex + 1;\n\tconst lastWord = chars.slice(lastWordIndex);\n\tconst ellipsis = '…';\n\tconst ellipsisLength = ellipsis.length;\n\n\tif (lastWord.length < 15) {\n\t\tconst charsToRemove = chars.length - maxLength + ellipsisLength;\n\t\tconst indexBeforeLastWord = lastWordIndex;\n\t\tconst keepLength = indexBeforeLastWord - charsToRemove;\n\n\t\tif (keepLength > 0) {\n\t\t\treturn (\n\t\t\t\tchars.slice(0, keepLength).join('') + ellipsis + chars.slice(indexBeforeLastWord).join('')\n\t\t\t);\n\t\t}\n\t}\n\n\treturn (\n\t\tchars.slice(0, maxLength - 5 - ellipsisLength).join('') + ellipsis + chars.slice(-5).join('')\n\t);\n}\n"],"mappings":";AAAA,MAAa,YAAY,MAAc,SAAS,OAC/C,KAAK,SAAS,SAAS,KAAK,MAAM,GAAG,OAAO,GAAG,QAAQ;;;;;;;AAQxD,SAAgB,mBAAmB,MAAc,WAA2B;CAC3E,MAAMA,QAAkB,EAAE;CAE1B,MAAM,YAAY,IAAI,KAAK,UAAU,QAAW,EAAE,aAAa,YAAY,CAAC;AAE5E,MAAK,MAAM,EAAE,aAAa,UAAU,QAAQ,KAAK,CAChD,OAAM,KAAK,QAAQ;AAGpB,KAAI,MAAM,UAAU,UACnB,QAAO;CAIR,MAAM,gBADsB,MAAM,eAAe,OAAO,GAAG,MAAM,QAAQ,CAAC,GAC9B;CAC5C,MAAM,WAAW,MAAM,MAAM,cAAc;CAC3C,MAAM,WAAW;CACjB,MAAM,iBAAiB;AAEvB,KAAI,SAAS,SAAS,IAAI;EACzB,MAAM,gBAAgB,MAAM,SAAS,YAAY;EACjD,MAAM,sBAAsB;EAC5B,MAAM,aAAa,sBAAsB;AAEzC,MAAI,aAAa,EAChB,QACC,MAAM,MAAM,GAAG,WAAW,CAAC,KAAK,GAAG,GAAG,WAAW,MAAM,MAAM,oBAAoB,CAAC,KAAK,GAAG;;AAK7F,QACC,MAAM,MAAM,GAAG,YAAY,IAAI,eAAe,CAAC,KAAK,GAAG,GAAG,WAAW,MAAM,MAAM,GAAG,CAAC,KAAK,GAAG"}
1
+ {"version":3,"file":"truncate.mjs","names":["chars: string[]"],"sources":["../src/string/truncate.ts"],"sourcesContent":["export const truncate = (text: string, length = 30): string =>\n\ttext.length > length ? text.slice(0, length) + '...' : text;\n\n/**\n * Replace part of given text with ellipsis following the rules below:\n *\n * - Remove chars just before the last word, as long as the last word is under 15 chars\n * - Otherwise preserve the last 5 chars of the name and remove chars before that\n */\nexport function truncateBeforeLast(\n\ttext: string,\n\tmaxLength: number,\n\tlastCharsLength: number = 5,\n): string {\n\tconst chars: string[] = [];\n\n\tconst segmenter = new Intl.Segmenter(undefined, { granularity: 'grapheme' });\n\n\tfor (const { segment } of segmenter.segment(text)) {\n\t\tchars.push(segment);\n\t}\n\n\tif (chars.length <= maxLength) {\n\t\treturn text;\n\t}\n\n\tconst lastWhitespaceIndex = chars.findLastIndex((ch) => ch.match(/^\\s+$/));\n\tconst lastWordIndex = lastWhitespaceIndex + 1;\n\tconst lastWord = chars.slice(lastWordIndex);\n\tconst ellipsis = '…';\n\tconst ellipsisLength = ellipsis.length;\n\n\tif (lastWord.length < 15) {\n\t\tconst charsToRemove = chars.length - maxLength + ellipsisLength;\n\t\tconst indexBeforeLastWord = lastWordIndex;\n\t\tconst keepLength = indexBeforeLastWord - charsToRemove;\n\n\t\tif (keepLength > 0) {\n\t\t\treturn (\n\t\t\t\tchars.slice(0, keepLength).join('') + ellipsis + chars.slice(indexBeforeLastWord).join('')\n\t\t\t);\n\t\t}\n\t}\n\n\tif (lastCharsLength < 1) {\n\t\treturn chars.slice(0, maxLength).join('') + ellipsis;\n\t}\n\n\treturn (\n\t\tchars.slice(0, maxLength - lastCharsLength - ellipsisLength).join('') +\n\t\tellipsis +\n\t\tchars.slice(-lastCharsLength).join('')\n\t);\n}\n"],"mappings":";AAAA,MAAa,YAAY,MAAc,SAAS,OAC/C,KAAK,SAAS,SAAS,KAAK,MAAM,GAAG,OAAO,GAAG,QAAQ;;;;;;;AAQxD,SAAgB,mBACf,MACA,WACA,kBAA0B,GACjB;CACT,MAAMA,QAAkB,EAAE;CAE1B,MAAM,YAAY,IAAI,KAAK,UAAU,QAAW,EAAE,aAAa,YAAY,CAAC;AAE5E,MAAK,MAAM,EAAE,aAAa,UAAU,QAAQ,KAAK,CAChD,OAAM,KAAK,QAAQ;AAGpB,KAAI,MAAM,UAAU,UACnB,QAAO;CAIR,MAAM,gBADsB,MAAM,eAAe,OAAO,GAAG,MAAM,QAAQ,CAAC,GAC9B;CAC5C,MAAM,WAAW,MAAM,MAAM,cAAc;CAC3C,MAAM,WAAW;CACjB,MAAM,iBAAiB;AAEvB,KAAI,SAAS,SAAS,IAAI;EACzB,MAAM,gBAAgB,MAAM,SAAS,YAAY;EACjD,MAAM,sBAAsB;EAC5B,MAAM,aAAa,sBAAsB;AAEzC,MAAI,aAAa,EAChB,QACC,MAAM,MAAM,GAAG,WAAW,CAAC,KAAK,GAAG,GAAG,WAAW,MAAM,MAAM,oBAAoB,CAAC,KAAK,GAAG;;AAK7F,KAAI,kBAAkB,EACrB,QAAO,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,GAAG,GAAG;AAG7C,QACC,MAAM,MAAM,GAAG,YAAY,kBAAkB,eAAe,CAAC,KAAK,GAAG,GACrE,WACA,MAAM,MAAM,CAAC,gBAAgB,CAAC,KAAK,GAAG"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@n8n/utils",
3
3
  "type": "module",
4
- "version": "1.20.0",
4
+ "version": "1.22.0",
5
5
  "files": [
6
6
  "dist",
7
7
  "LICENSE.md",
@@ -34,9 +34,9 @@
34
34
  "typescript": "5.9.2",
35
35
  "vite": "npm:rolldown-vite@latest",
36
36
  "vitest": "^3.1.3",
37
+ "@n8n/vitest-config": "1.5.0",
37
38
  "@n8n/typescript-config": "1.3.0",
38
- "@n8n/eslint-config": "0.0.1",
39
- "@n8n/vitest-config": "1.5.0"
39
+ "@n8n/eslint-config": "0.0.1"
40
40
  },
41
41
  "license": "SEE LICENSE IN LICENSE.md",
42
42
  "homepage": "https://n8n.io",