nhb-toolbox 1.6.6 → 1.6.9
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/string/basics.d.ts
CHANGED
|
@@ -13,11 +13,11 @@ export declare const capitalizeString: (string: string, options?: CapitalizeOpti
|
|
|
13
13
|
*
|
|
14
14
|
* @param string The string to truncate.
|
|
15
15
|
* @param maxLength The maximum length of the truncated string.
|
|
16
|
-
* @returns Truncated string
|
|
16
|
+
* @returns Truncated string with ellipsis (`...`) (only if it has more length than `maxLength`).
|
|
17
17
|
*/
|
|
18
18
|
export declare const truncateString: (string: string, maxLength: number) => string;
|
|
19
19
|
/**
|
|
20
|
-
* * Generates a random alphanumeric (16 characters long, this length is customizable in the options) ID string composed of an optional `prefix`, `suffix`, a `timestamp`, and a customizable separator
|
|
20
|
+
* * Generates a random alphanumeric (16 characters long, this length is customizable in the options) ID string composed of an optional `prefix`, `suffix`, a `timestamp`, `caseOption` and a customizable `separator`.
|
|
21
21
|
*
|
|
22
22
|
* @param options Configuration options for random ID generation.
|
|
23
23
|
* @returns The generated ID string composed of the random alphanumeric string of specified length with optional `timeStamp`, `prefix`, and `suffix`, `caseOption` and `separator`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basics.d.ts","sourceRoot":"","sources":["../../src/string/basics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAElE;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,WACpB,MAAM,YACJ,iBAAiB,KACzB,MA0CF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,WAAY,MAAM,aAAa,MAAM,KAAG,
|
|
1
|
+
{"version":3,"file":"basics.d.ts","sourceRoot":"","sources":["../../src/string/basics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAElE;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,WACpB,MAAM,YACJ,iBAAiB,KACzB,MA0CF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,WAAY,MAAM,aAAa,MAAM,KAAG,MAUlE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,aAAc,eAAe,KAAG,MAmC5D,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;AAElD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC"}
|
package/dist/string/basics.js
CHANGED
|
@@ -46,14 +46,12 @@ exports.capitalizeString = capitalizeString;
|
|
|
46
46
|
*
|
|
47
47
|
* @param string The string to truncate.
|
|
48
48
|
* @param maxLength The maximum length of the truncated string.
|
|
49
|
-
* @returns Truncated string
|
|
49
|
+
* @returns Truncated string with ellipsis (`...`) (only if it has more length than `maxLength`).
|
|
50
50
|
*/
|
|
51
51
|
const truncateString = (string, maxLength) => {
|
|
52
52
|
if (typeof string !== 'string' || !string)
|
|
53
53
|
return '';
|
|
54
54
|
const trimmedString = string.trim();
|
|
55
|
-
if (!trimmedString)
|
|
56
|
-
return '';
|
|
57
55
|
if (!trimmedString)
|
|
58
56
|
return '';
|
|
59
57
|
if (trimmedString.length <= maxLength)
|
|
@@ -62,7 +60,7 @@ const truncateString = (string, maxLength) => {
|
|
|
62
60
|
};
|
|
63
61
|
exports.truncateString = truncateString;
|
|
64
62
|
/**
|
|
65
|
-
* * Generates a random alphanumeric (16 characters long, this length is customizable in the options) ID string composed of an optional `prefix`, `suffix`, a `timestamp`, and a customizable separator
|
|
63
|
+
* * Generates a random alphanumeric (16 characters long, this length is customizable in the options) ID string composed of an optional `prefix`, `suffix`, a `timestamp`, `caseOption` and a customizable `separator`.
|
|
66
64
|
*
|
|
67
65
|
* @param options Configuration options for random ID generation.
|
|
68
66
|
* @returns The generated ID string composed of the random alphanumeric string of specified length with optional `timeStamp`, `prefix`, and `suffix`, `caseOption` and `separator`.
|
|
@@ -81,14 +79,13 @@ const generateRandomID = (options) => {
|
|
|
81
79
|
]
|
|
82
80
|
.filter(Boolean)
|
|
83
81
|
.join(separator);
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
return ID;
|
|
82
|
+
switch (caseOption) {
|
|
83
|
+
case 'upper':
|
|
84
|
+
return ID.toUpperCase();
|
|
85
|
+
case 'lower':
|
|
86
|
+
return ID.toLowerCase();
|
|
87
|
+
default:
|
|
88
|
+
return ID;
|
|
92
89
|
}
|
|
93
90
|
};
|
|
94
91
|
exports.generateRandomID = generateRandomID;
|
package/dist/string/types.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export interface RandomIdOptions {
|
|
|
19
19
|
length?: number;
|
|
20
20
|
/** The separator to use between parts of the ID. Default is an empty string. */
|
|
21
21
|
separator?: string;
|
|
22
|
-
/** Specifies the case for the random alphanumeric string. */
|
|
22
|
+
/** Specifies the case for the random alphanumeric string. Default is `null`. */
|
|
23
23
|
caseOption?: 'upper' | 'lower' | null;
|
|
24
24
|
}
|
|
25
25
|
/** - Options for generating anagrams. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/string/types.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,MAAM,WAAW,iBAAiB;IACjC,iGAAiG;IACjG,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,kFAAkF;IAClF,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,qFAAqF;IACrF,aAAa,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,iDAAiD;AACjD,MAAM,WAAW,eAAe;IAC/B,iEAAiE;IACjE,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,+DAA+D;IAC/D,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,8EAA8E;IAC9E,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,gFAAgF;IAChF,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/string/types.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,MAAM,WAAW,iBAAiB;IACjC,iGAAiG;IACjG,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,kFAAkF;IAClF,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,qFAAqF;IACrF,aAAa,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,iDAAiD;AACjD,MAAM,WAAW,eAAe;IAC/B,iEAAiE;IACjE,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,+DAA+D;IAC/D,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,8EAA8E;IAC9E,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,gFAAgF;IAChF,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,gFAAgF;IAChF,UAAU,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,IAAI,CAAC;CACtC;AAED,yCAAyC;AACzC,MAAM,WAAW,cAAc;IAC9B,mDAAmD;IACnD,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IACvB,+DAA+D;IAC/D,UAAU,CAAC,EAAE,OAAO,CAAC;CACrB"}
|
package/package.json
CHANGED