@settlemint/sdk-utils 2.3.2-prfd3a56ad → 2.3.3
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/README.md +121 -77
- package/dist/environment.cjs +17708 -384
- package/dist/environment.cjs.map +1 -1
- package/dist/environment.d.cts +263 -98
- package/dist/environment.d.ts +263 -98
- package/dist/environment.js +17746 -0
- package/dist/environment.js.map +1 -0
- package/dist/filesystem.cjs +6746 -113
- package/dist/filesystem.cjs.map +1 -1
- package/dist/filesystem.d.cts +22 -1
- package/dist/filesystem.d.ts +22 -1
- package/dist/filesystem.js +6766 -0
- package/dist/filesystem.js.map +1 -0
- package/dist/http.cjs +214 -94
- package/dist/http.cjs.map +1 -1
- package/dist/http.d.cts +9 -1
- package/dist/http.d.ts +9 -1
- package/dist/http.js +226 -0
- package/dist/http.js.map +1 -0
- package/dist/index.cjs +295 -104
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -1
- package/dist/index.d.ts +26 -1
- package/dist/index.js +306 -0
- package/dist/index.js.map +1 -0
- package/dist/json.cjs +83 -0
- package/dist/json.cjs.map +1 -0
- package/dist/json.d.cts +56 -0
- package/dist/json.d.ts +56 -0
- package/dist/json.js +80 -0
- package/dist/json.js.map +1 -0
- package/dist/logging.cjs +209 -137
- package/dist/logging.cjs.map +1 -1
- package/dist/logging.d.cts +23 -14
- package/dist/logging.d.ts +23 -14
- package/dist/logging.js +221 -0
- package/dist/logging.js.map +1 -0
- package/dist/package-manager.cjs +7353 -173
- package/dist/package-manager.cjs.map +1 -1
- package/dist/package-manager.d.cts +26 -3
- package/dist/package-manager.d.ts +26 -3
- package/dist/package-manager.js +7385 -0
- package/dist/package-manager.js.map +1 -0
- package/dist/retry.cjs +137 -0
- package/dist/retry.cjs.map +1 -0
- package/dist/retry.d.cts +19 -0
- package/dist/retry.d.ts +19 -0
- package/dist/retry.js +136 -0
- package/dist/retry.js.map +1 -0
- package/dist/runtime.cjs +58 -40
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.d.cts +3 -0
- package/dist/runtime.d.ts +3 -0
- package/dist/runtime.js +45 -0
- package/dist/runtime.js.map +1 -0
- package/dist/string.cjs +76 -0
- package/dist/string.cjs.map +1 -0
- package/dist/string.d.cts +58 -0
- package/dist/string.d.ts +58 -0
- package/dist/string.js +72 -0
- package/dist/string.js.map +1 -0
- package/dist/terminal.cjs +426 -229
- package/dist/terminal.cjs.map +1 -1
- package/dist/terminal.d.cts +54 -24
- package/dist/terminal.d.ts +54 -24
- package/dist/terminal.js +441 -0
- package/dist/terminal.js.map +1 -0
- package/dist/url.cjs +25 -0
- package/dist/url.cjs.map +1 -0
- package/dist/url.d.cts +20 -0
- package/dist/url.d.ts +20 -0
- package/dist/url.js +24 -0
- package/dist/url.js.map +1 -0
- package/dist/validation.cjs +10486 -193
- package/dist/validation.cjs.map +1 -1
- package/dist/validation.d.cts +124 -94
- package/dist/validation.d.ts +124 -94
- package/dist/validation.js +10482 -0
- package/dist/validation.js.map +1 -0
- package/package.json +6 -6
- package/dist/environment.mjs +0 -384
- package/dist/environment.mjs.map +0 -1
- package/dist/filesystem.mjs +0 -105
- package/dist/filesystem.mjs.map +0 -1
- package/dist/http.mjs +0 -80
- package/dist/http.mjs.map +0 -1
- package/dist/index.mjs +0 -90
- package/dist/index.mjs.map +0 -1
- package/dist/logging.mjs +0 -123
- package/dist/logging.mjs.map +0 -1
- package/dist/package-manager.mjs +0 -167
- package/dist/package-manager.mjs.map +0 -1
- package/dist/runtime.mjs +0 -23
- package/dist/runtime.mjs.map +0 -1
- package/dist/terminal.mjs +0 -230
- package/dist/terminal.mjs.map +0 -1
- package/dist/validation.mjs +0 -161
- package/dist/validation.mjs.map +0 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
//#region src/string.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Capitalizes the first letter of a string.
|
|
4
|
+
*
|
|
5
|
+
* @param val - The string to capitalize
|
|
6
|
+
* @returns The input string with its first letter capitalized
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* import { capitalizeFirstLetter } from "@settlemint/sdk-utils";
|
|
10
|
+
*
|
|
11
|
+
* const capitalized = capitalizeFirstLetter("hello");
|
|
12
|
+
* // Returns: "Hello"
|
|
13
|
+
*/
|
|
14
|
+
declare function capitalizeFirstLetter(val: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Converts a camelCase string to a human-readable string.
|
|
17
|
+
*
|
|
18
|
+
* @param s - The camelCase string to convert
|
|
19
|
+
* @returns The human-readable string
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* import { camelCaseToWords } from "@settlemint/sdk-utils";
|
|
23
|
+
*
|
|
24
|
+
* const words = camelCaseToWords("camelCaseString");
|
|
25
|
+
* // Returns: "Camel Case String"
|
|
26
|
+
*/
|
|
27
|
+
declare function camelCaseToWords(s: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Replaces underscores and hyphens with spaces.
|
|
30
|
+
*
|
|
31
|
+
* @param s - The string to replace underscores and hyphens with spaces
|
|
32
|
+
* @returns The input string with underscores and hyphens replaced with spaces
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* import { replaceUnderscoresAndHyphensWithSpaces } from "@settlemint/sdk-utils";
|
|
36
|
+
*
|
|
37
|
+
* const result = replaceUnderscoresAndHyphensWithSpaces("Already_Spaced-Second");
|
|
38
|
+
* // Returns: "Already Spaced Second"
|
|
39
|
+
*/
|
|
40
|
+
declare function replaceUnderscoresAndHyphensWithSpaces(s: string): string;
|
|
41
|
+
/**
|
|
42
|
+
* Truncates a string to a maximum length and appends "..." if it is longer.
|
|
43
|
+
*
|
|
44
|
+
* @param value - The string to truncate
|
|
45
|
+
* @param maxLength - The maximum length of the string
|
|
46
|
+
* @returns The truncated string or the original string if it is shorter than the maximum length
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* import { truncate } from "@settlemint/sdk-utils";
|
|
50
|
+
*
|
|
51
|
+
* const truncated = truncate("Hello, world!", 10);
|
|
52
|
+
* // Returns: "Hello, wor..."
|
|
53
|
+
*/
|
|
54
|
+
declare function truncate(value: string, maxLength: number): string;
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
export { camelCaseToWords, capitalizeFirstLetter, replaceUnderscoresAndHyphensWithSpaces, truncate };
|
|
58
|
+
//# sourceMappingURL=string.d.cts.map
|
package/dist/string.d.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
//#region src/string.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Capitalizes the first letter of a string.
|
|
4
|
+
*
|
|
5
|
+
* @param val - The string to capitalize
|
|
6
|
+
* @returns The input string with its first letter capitalized
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* import { capitalizeFirstLetter } from "@settlemint/sdk-utils";
|
|
10
|
+
*
|
|
11
|
+
* const capitalized = capitalizeFirstLetter("hello");
|
|
12
|
+
* // Returns: "Hello"
|
|
13
|
+
*/
|
|
14
|
+
declare function capitalizeFirstLetter(val: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Converts a camelCase string to a human-readable string.
|
|
17
|
+
*
|
|
18
|
+
* @param s - The camelCase string to convert
|
|
19
|
+
* @returns The human-readable string
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* import { camelCaseToWords } from "@settlemint/sdk-utils";
|
|
23
|
+
*
|
|
24
|
+
* const words = camelCaseToWords("camelCaseString");
|
|
25
|
+
* // Returns: "Camel Case String"
|
|
26
|
+
*/
|
|
27
|
+
declare function camelCaseToWords(s: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Replaces underscores and hyphens with spaces.
|
|
30
|
+
*
|
|
31
|
+
* @param s - The string to replace underscores and hyphens with spaces
|
|
32
|
+
* @returns The input string with underscores and hyphens replaced with spaces
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* import { replaceUnderscoresAndHyphensWithSpaces } from "@settlemint/sdk-utils";
|
|
36
|
+
*
|
|
37
|
+
* const result = replaceUnderscoresAndHyphensWithSpaces("Already_Spaced-Second");
|
|
38
|
+
* // Returns: "Already Spaced Second"
|
|
39
|
+
*/
|
|
40
|
+
declare function replaceUnderscoresAndHyphensWithSpaces(s: string): string;
|
|
41
|
+
/**
|
|
42
|
+
* Truncates a string to a maximum length and appends "..." if it is longer.
|
|
43
|
+
*
|
|
44
|
+
* @param value - The string to truncate
|
|
45
|
+
* @param maxLength - The maximum length of the string
|
|
46
|
+
* @returns The truncated string or the original string if it is shorter than the maximum length
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* import { truncate } from "@settlemint/sdk-utils";
|
|
50
|
+
*
|
|
51
|
+
* const truncated = truncate("Hello, world!", 10);
|
|
52
|
+
* // Returns: "Hello, wor..."
|
|
53
|
+
*/
|
|
54
|
+
declare function truncate(value: string, maxLength: number): string;
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
export { camelCaseToWords, capitalizeFirstLetter, replaceUnderscoresAndHyphensWithSpaces, truncate };
|
|
58
|
+
//# sourceMappingURL=string.d.ts.map
|
package/dist/string.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
//#region src/string.ts
|
|
2
|
+
/**
|
|
3
|
+
* Capitalizes the first letter of a string.
|
|
4
|
+
*
|
|
5
|
+
* @param val - The string to capitalize
|
|
6
|
+
* @returns The input string with its first letter capitalized
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* import { capitalizeFirstLetter } from "@settlemint/sdk-utils";
|
|
10
|
+
*
|
|
11
|
+
* const capitalized = capitalizeFirstLetter("hello");
|
|
12
|
+
* // Returns: "Hello"
|
|
13
|
+
*/
|
|
14
|
+
function capitalizeFirstLetter(val) {
|
|
15
|
+
return String(val).charAt(0).toUpperCase() + String(val).slice(1);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Converts a camelCase string to a human-readable string.
|
|
19
|
+
*
|
|
20
|
+
* @param s - The camelCase string to convert
|
|
21
|
+
* @returns The human-readable string
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* import { camelCaseToWords } from "@settlemint/sdk-utils";
|
|
25
|
+
*
|
|
26
|
+
* const words = camelCaseToWords("camelCaseString");
|
|
27
|
+
* // Returns: "Camel Case String"
|
|
28
|
+
*/
|
|
29
|
+
function camelCaseToWords(s) {
|
|
30
|
+
const result = s.replace(/([a-z])([A-Z])/g, "$1 $2");
|
|
31
|
+
const withSpaces = result.replace(/([A-Z])([a-z])/g, " $1$2");
|
|
32
|
+
const capitalized = capitalizeFirstLetter(withSpaces);
|
|
33
|
+
return capitalized.replace(/\s+/g, " ").trim();
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Replaces underscores and hyphens with spaces.
|
|
37
|
+
*
|
|
38
|
+
* @param s - The string to replace underscores and hyphens with spaces
|
|
39
|
+
* @returns The input string with underscores and hyphens replaced with spaces
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* import { replaceUnderscoresAndHyphensWithSpaces } from "@settlemint/sdk-utils";
|
|
43
|
+
*
|
|
44
|
+
* const result = replaceUnderscoresAndHyphensWithSpaces("Already_Spaced-Second");
|
|
45
|
+
* // Returns: "Already Spaced Second"
|
|
46
|
+
*/
|
|
47
|
+
function replaceUnderscoresAndHyphensWithSpaces(s) {
|
|
48
|
+
return s.replace(/[-_]/g, " ");
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Truncates a string to a maximum length and appends "..." if it is longer.
|
|
52
|
+
*
|
|
53
|
+
* @param value - The string to truncate
|
|
54
|
+
* @param maxLength - The maximum length of the string
|
|
55
|
+
* @returns The truncated string or the original string if it is shorter than the maximum length
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* import { truncate } from "@settlemint/sdk-utils";
|
|
59
|
+
*
|
|
60
|
+
* const truncated = truncate("Hello, world!", 10);
|
|
61
|
+
* // Returns: "Hello, wor..."
|
|
62
|
+
*/
|
|
63
|
+
function truncate(value, maxLength) {
|
|
64
|
+
if (value.length <= maxLength) {
|
|
65
|
+
return value;
|
|
66
|
+
}
|
|
67
|
+
return `${value.slice(0, maxLength)}...`;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
//#endregion
|
|
71
|
+
export { camelCaseToWords, capitalizeFirstLetter, replaceUnderscoresAndHyphensWithSpaces, truncate };
|
|
72
|
+
//# sourceMappingURL=string.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string.js","names":["val: string","s: string","value: string","maxLength: number"],"sources":["../src/string.ts"],"sourcesContent":["/**\n * Capitalizes the first letter of a string.\n *\n * @param val - The string to capitalize\n * @returns The input string with its first letter capitalized\n *\n * @example\n * import { capitalizeFirstLetter } from \"@settlemint/sdk-utils\";\n *\n * const capitalized = capitalizeFirstLetter(\"hello\");\n * // Returns: \"Hello\"\n */\nexport function capitalizeFirstLetter(val: string) {\n return String(val).charAt(0).toUpperCase() + String(val).slice(1);\n}\n\n/**\n * Converts a camelCase string to a human-readable string.\n *\n * @param s - The camelCase string to convert\n * @returns The human-readable string\n *\n * @example\n * import { camelCaseToWords } from \"@settlemint/sdk-utils\";\n *\n * const words = camelCaseToWords(\"camelCaseString\");\n * // Returns: \"Camel Case String\"\n */\nexport function camelCaseToWords(s: string) {\n const result = s.replace(/([a-z])([A-Z])/g, \"$1 $2\");\n const withSpaces = result.replace(/([A-Z])([a-z])/g, \" $1$2\");\n const capitalized = capitalizeFirstLetter(withSpaces);\n return capitalized.replace(/\\s+/g, \" \").trim();\n}\n\n/**\n * Replaces underscores and hyphens with spaces.\n *\n * @param s - The string to replace underscores and hyphens with spaces\n * @returns The input string with underscores and hyphens replaced with spaces\n *\n * @example\n * import { replaceUnderscoresAndHyphensWithSpaces } from \"@settlemint/sdk-utils\";\n *\n * const result = replaceUnderscoresAndHyphensWithSpaces(\"Already_Spaced-Second\");\n * // Returns: \"Already Spaced Second\"\n */\nexport function replaceUnderscoresAndHyphensWithSpaces(s: string) {\n return s.replace(/[-_]/g, \" \");\n}\n\n/**\n * Truncates a string to a maximum length and appends \"...\" if it is longer.\n *\n * @param value - The string to truncate\n * @param maxLength - The maximum length of the string\n * @returns The truncated string or the original string if it is shorter than the maximum length\n *\n * @example\n * import { truncate } from \"@settlemint/sdk-utils\";\n *\n * const truncated = truncate(\"Hello, world!\", 10);\n * // Returns: \"Hello, wor...\"\n */\nexport function truncate(value: string, maxLength: number) {\n if (value.length <= maxLength) {\n return value;\n }\n return `${value.slice(0, maxLength)}...`;\n}\n"],"mappings":";;;;;;;;;;;;;AAYA,SAAgB,sBAAsBA,KAAa;AACjD,QAAO,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,aAAa,GAAG,OAAO,IAAI,CAAC,MAAM,EAAE;AAClE;;;;;;;;;;;;;AAcD,SAAgB,iBAAiBC,GAAW;CAC1C,MAAM,SAAS,EAAE,QAAQ,mBAAmB,QAAQ;CACpD,MAAM,aAAa,OAAO,QAAQ,mBAAmB,QAAQ;CAC7D,MAAM,cAAc,sBAAsB,WAAW;AACrD,QAAO,YAAY,QAAQ,QAAQ,IAAI,CAAC,MAAM;AAC/C;;;;;;;;;;;;;AAcD,SAAgB,uCAAuCA,GAAW;AAChE,QAAO,EAAE,QAAQ,SAAS,IAAI;AAC/B;;;;;;;;;;;;;;AAeD,SAAgB,SAASC,OAAeC,WAAmB;AACzD,KAAI,MAAM,UAAU,WAAW;AAC7B,SAAO;CACR;AACD,SAAQ,EAAE,MAAM,MAAM,GAAG,UAAU,CAAC;AACrC"}
|