@ls-stack/utils 3.2.10 → 3.3.1
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/lib/{chunk-V2L472LS.js → chunk-4REIIZQY.js} +4 -2
- package/lib/safeJson.d.cts +1 -1
- package/lib/safeJson.d.ts +1 -1
- package/lib/stringUtils.cjs +5 -2
- package/lib/stringUtils.d.cts +6 -2
- package/lib/stringUtils.d.ts +6 -2
- package/lib/stringUtils.js +3 -1
- package/lib/yamlStringify.js +1 -1
- package/package.json +1 -1
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
// src/stringUtils.ts
|
|
2
|
-
function
|
|
2
|
+
function concatStrings(...args) {
|
|
3
3
|
const strings = [];
|
|
4
4
|
for (let i = 0; i < args.length; i++) {
|
|
5
5
|
const arg = args[i];
|
|
6
6
|
if (!arg) continue;
|
|
7
7
|
if (Array.isArray(arg)) {
|
|
8
|
-
strings.push(
|
|
8
|
+
strings.push(concatStrings(...arg));
|
|
9
9
|
continue;
|
|
10
10
|
}
|
|
11
11
|
strings.push(arg);
|
|
12
12
|
}
|
|
13
13
|
return strings.join("");
|
|
14
14
|
}
|
|
15
|
+
var joinStrings = concatStrings;
|
|
15
16
|
function formatNum(num) {
|
|
16
17
|
return num.toLocaleString("en-US", {
|
|
17
18
|
minimumFractionDigits: 2,
|
|
@@ -30,6 +31,7 @@ function truncateString(str, length, ellipsis = "\u2026") {
|
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
export {
|
|
34
|
+
concatStrings,
|
|
33
35
|
joinStrings,
|
|
34
36
|
formatNum,
|
|
35
37
|
isSnakeCase,
|
package/lib/safeJson.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** JSON.stringify can throw if the value is circular or contains functions, this function catches those errors and returns undefined */
|
|
2
2
|
declare function safeJsonStringify(value: unknown): string | undefined;
|
|
3
3
|
/** JSON.parse can throw if the value is not valid JSON, this function catches those errors and returns undefined */
|
|
4
|
-
declare function safeJsonParse(value: string):
|
|
4
|
+
declare function safeJsonParse(value: string): unknown;
|
|
5
5
|
|
|
6
6
|
export { safeJsonParse, safeJsonStringify };
|
package/lib/safeJson.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** JSON.stringify can throw if the value is circular or contains functions, this function catches those errors and returns undefined */
|
|
2
2
|
declare function safeJsonStringify(value: unknown): string | undefined;
|
|
3
3
|
/** JSON.parse can throw if the value is not valid JSON, this function catches those errors and returns undefined */
|
|
4
|
-
declare function safeJsonParse(value: string):
|
|
4
|
+
declare function safeJsonParse(value: string): unknown;
|
|
5
5
|
|
|
6
6
|
export { safeJsonParse, safeJsonStringify };
|
package/lib/stringUtils.cjs
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/stringUtils.ts
|
|
21
21
|
var stringUtils_exports = {};
|
|
22
22
|
__export(stringUtils_exports, {
|
|
23
|
+
concatStrings: () => concatStrings,
|
|
23
24
|
convertToSnakeCase: () => convertToSnakeCase,
|
|
24
25
|
formatNum: () => formatNum,
|
|
25
26
|
isSnakeCase: () => isSnakeCase,
|
|
@@ -27,19 +28,20 @@ __export(stringUtils_exports, {
|
|
|
27
28
|
truncateString: () => truncateString
|
|
28
29
|
});
|
|
29
30
|
module.exports = __toCommonJS(stringUtils_exports);
|
|
30
|
-
function
|
|
31
|
+
function concatStrings(...args) {
|
|
31
32
|
const strings = [];
|
|
32
33
|
for (let i = 0; i < args.length; i++) {
|
|
33
34
|
const arg = args[i];
|
|
34
35
|
if (!arg) continue;
|
|
35
36
|
if (Array.isArray(arg)) {
|
|
36
|
-
strings.push(
|
|
37
|
+
strings.push(concatStrings(...arg));
|
|
37
38
|
continue;
|
|
38
39
|
}
|
|
39
40
|
strings.push(arg);
|
|
40
41
|
}
|
|
41
42
|
return strings.join("");
|
|
42
43
|
}
|
|
44
|
+
var joinStrings = concatStrings;
|
|
43
45
|
function formatNum(num) {
|
|
44
46
|
return num.toLocaleString("en-US", {
|
|
45
47
|
minimumFractionDigits: 2,
|
|
@@ -58,6 +60,7 @@ function truncateString(str, length, ellipsis = "\u2026") {
|
|
|
58
60
|
}
|
|
59
61
|
// Annotate the CommonJS export names for ESM import in node:
|
|
60
62
|
0 && (module.exports = {
|
|
63
|
+
concatStrings,
|
|
61
64
|
convertToSnakeCase,
|
|
62
65
|
formatNum,
|
|
63
66
|
isSnakeCase,
|
package/lib/stringUtils.d.cts
CHANGED
|
@@ -7,10 +7,14 @@ type Arg = string | false | undefined | null;
|
|
|
7
7
|
* joinStrings('a', false, 'c') // 'ac'
|
|
8
8
|
* joinStrings('a', addBString ? 'b' : null, 'c') // 'ac' if addBString is false, 'abc' if addBString is true
|
|
9
9
|
*/
|
|
10
|
-
declare function
|
|
10
|
+
declare function concatStrings(...args: (Arg | Arg[])[]): string;
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Use {@link concatStrings} instead
|
|
13
|
+
*/
|
|
14
|
+
declare const joinStrings: typeof concatStrings;
|
|
11
15
|
declare function formatNum(num: number): string;
|
|
12
16
|
declare function isSnakeCase(str: string): boolean;
|
|
13
17
|
declare function convertToSnakeCase(str: string): string;
|
|
14
18
|
declare function truncateString(str: string, length: number, ellipsis?: string): string;
|
|
15
19
|
|
|
16
|
-
export { convertToSnakeCase, formatNum, isSnakeCase, joinStrings, truncateString };
|
|
20
|
+
export { concatStrings, convertToSnakeCase, formatNum, isSnakeCase, joinStrings, truncateString };
|
package/lib/stringUtils.d.ts
CHANGED
|
@@ -7,10 +7,14 @@ type Arg = string | false | undefined | null;
|
|
|
7
7
|
* joinStrings('a', false, 'c') // 'ac'
|
|
8
8
|
* joinStrings('a', addBString ? 'b' : null, 'c') // 'ac' if addBString is false, 'abc' if addBString is true
|
|
9
9
|
*/
|
|
10
|
-
declare function
|
|
10
|
+
declare function concatStrings(...args: (Arg | Arg[])[]): string;
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Use {@link concatStrings} instead
|
|
13
|
+
*/
|
|
14
|
+
declare const joinStrings: typeof concatStrings;
|
|
11
15
|
declare function formatNum(num: number): string;
|
|
12
16
|
declare function isSnakeCase(str: string): boolean;
|
|
13
17
|
declare function convertToSnakeCase(str: string): string;
|
|
14
18
|
declare function truncateString(str: string, length: number, ellipsis?: string): string;
|
|
15
19
|
|
|
16
|
-
export { convertToSnakeCase, formatNum, isSnakeCase, joinStrings, truncateString };
|
|
20
|
+
export { concatStrings, convertToSnakeCase, formatNum, isSnakeCase, joinStrings, truncateString };
|
package/lib/stringUtils.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
+
concatStrings,
|
|
2
3
|
convertToSnakeCase,
|
|
3
4
|
formatNum,
|
|
4
5
|
isSnakeCase,
|
|
5
6
|
joinStrings,
|
|
6
7
|
truncateString
|
|
7
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-4REIIZQY.js";
|
|
8
9
|
export {
|
|
10
|
+
concatStrings,
|
|
9
11
|
convertToSnakeCase,
|
|
10
12
|
formatNum,
|
|
11
13
|
isSnakeCase,
|
package/lib/yamlStringify.js
CHANGED