@rzl-zone/utils-js 3.1.0-beta.2 → 3.1.2-beta.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/README.md +2 -2
- package/dist/NumberRangeUnion-DC-C3_Kq.d.ts +23 -23
- package/dist/any-BmdI8UbK.d.ts +56 -56
- package/dist/arrays-normalize-recursive-CnjYJ9xg.d.ts +66 -66
- package/dist/assertions/index.cjs +1 -1
- package/dist/assertions/index.d.ts +396 -396
- package/dist/assertions/index.js +1 -1
- package/dist/chunk-26W3VZIK.cjs +1 -0
- package/dist/chunk-2KRCHXFG.cjs +2 -0
- package/dist/{chunk-TQMZ2LPI.js → chunk-33ZLH266.js} +1 -1
- package/dist/{chunk-VQLAPEL3.js → chunk-4L4EJTNZ.js} +1 -1
- package/dist/{chunk-CK3BZGEU.js → chunk-5Q37AP7P.js} +1 -1
- package/dist/chunk-7CHFAMS2.js +1 -0
- package/dist/{chunk-REFMEB4A.js → chunk-7MMJZ6HS.js} +1 -1
- package/dist/chunk-7TC6DE3J.cjs +1 -0
- package/dist/{chunk-K4PLGD7C.js → chunk-7VX33E3V.js} +1 -1
- package/dist/chunk-BEZPD44N.cjs +1 -0
- package/dist/{chunk-2AUUPGMN.js → chunk-BI263OHW.js} +1 -1
- package/dist/{chunk-LVUSFXQS.cjs → chunk-CII6WWLO.cjs} +1 -1
- package/dist/{chunk-OX6RLS2F.cjs → chunk-D5TYPCWU.cjs} +1 -1
- package/dist/{chunk-MWLEM7ED.js → chunk-EEQY5QUG.js} +1 -1
- package/dist/chunk-ESJYBIYH.js +1 -0
- package/dist/{chunk-MJAW5RAK.js → chunk-EWYPSKKM.js} +1 -1
- package/dist/chunk-EXCOQLWX.cjs +1 -0
- package/dist/chunk-FWQVTMYA.cjs +1 -0
- package/dist/{chunk-25G6B35W.js → chunk-G4EWCRKS.js} +1 -1
- package/dist/{chunk-PFLNHD4B.cjs → chunk-G7R5XZRM.cjs} +1 -1
- package/dist/{chunk-EXXLUO7L.cjs → chunk-GGEV7LXX.cjs} +1 -1
- package/dist/{chunk-VTR75UID.cjs → chunk-HJOZOENU.cjs} +1 -1
- package/dist/{chunk-HXTACM3O.cjs → chunk-IRDZVLNZ.cjs} +1 -1
- package/dist/chunk-IW73G523.cjs +1 -0
- package/dist/chunk-IY5OZAB3.cjs +1 -0
- package/dist/{chunk-467VEMJH.js → chunk-J4NCYYGS.js} +1 -1
- package/dist/{chunk-RHIBYOFQ.js → chunk-J7JAZAJD.js} +1 -1
- package/dist/{chunk-JQZUWBIX.js → chunk-JYNSO7ZY.js} +1 -1
- package/dist/{chunk-UUMKL74S.js → chunk-K3UVKYEU.js} +1 -1
- package/dist/{chunk-ME5OV5HN.js → chunk-LQ76EDZG.js} +1 -1
- package/dist/chunk-MROH35V3.cjs +1 -0
- package/dist/chunk-NJSAV73S.js +1 -0
- package/dist/{chunk-HXST7RJB.js → chunk-NR44SNYE.js} +1 -1
- package/dist/{chunk-BLCANGFS.js → chunk-NXMTWY77.js} +1 -1
- package/dist/chunk-OZCQZO2V.cjs +4 -0
- package/dist/chunk-Q3NTKN5I.cjs +1 -0
- package/dist/{chunk-NSVLG7NY.js → chunk-QDNSC57Z.js} +1 -1
- package/dist/{chunk-NUVGETPD.js → chunk-QGXTL5ZH.js} +1 -1
- package/dist/{chunk-D43GV6EF.cjs → chunk-QSQDP7L2.cjs} +1 -1
- package/dist/{chunk-U4TZO7WV.js → chunk-S5M33A4O.js} +1 -1
- package/dist/{chunk-S7GMG4TB.js → chunk-SGTHOQQ2.js} +1 -1
- package/dist/chunk-SL3RQOWA.js +1 -0
- package/dist/{chunk-NUHOOAUN.cjs → chunk-SZPWZZYG.cjs} +1 -1
- package/dist/{chunk-RHE3M2NJ.cjs → chunk-UA4B7JBO.cjs} +1 -1
- package/dist/chunk-UQDJF5RR.cjs +1 -0
- package/dist/chunk-UTQUYABU.cjs +1 -0
- package/dist/{chunk-G72VSVGO.js → chunk-VPW3DRV5.js} +1 -1
- package/dist/{chunk-PSWITZK5.js → chunk-W32WALNU.js} +1 -1
- package/dist/chunk-XGZ6K753.cjs +1 -0
- package/dist/chunk-YFTR64N5.cjs +1 -0
- package/dist/chunk-ZFDS7W6B.cjs +1 -0
- package/dist/chunk-ZQOLZE6Z.cjs +1 -0
- package/dist/conversions/index.cjs +1 -1
- package/dist/conversions/index.d.ts +1285 -1285
- package/dist/conversions/index.js +1 -1
- package/dist/env/index.d.ts +14 -14
- package/dist/events/index.cjs +1 -1
- package/dist/events/index.d.ts +109 -109
- package/dist/events/index.js +1 -1
- package/dist/extends-Bk_SBGdT.d.ts +330 -330
- package/dist/formatting/index.cjs +1 -1
- package/dist/formatting/index.d.ts +855 -855
- package/dist/formatting/index.js +1 -1
- package/dist/generator/index.cjs +1 -1
- package/dist/generator/index.d.ts +155 -155
- package/dist/generator/index.js +1 -1
- package/dist/if-CvT4R7Kh.d.ts +16 -16
- package/dist/is-array--YjXV-Wx.d.ts +1084 -1084
- package/dist/isPlainObject-BVhBAPHX.d.ts +154 -154
- package/dist/never-BfayMBF9.d.ts +64 -64
- package/dist/next/index.cjs +5 -5
- package/dist/next/index.d.ts +183 -183
- package/dist/next/index.js +1 -1
- package/dist/next/server/index.cjs +1 -1
- package/dist/next/server/index.d.ts +25 -25
- package/dist/next/server/index.js +1 -1
- package/dist/nils-DMz3kU7M.d.ts +155 -155
- package/dist/omit-VvmIsZmX.d.ts +25 -25
- package/dist/operations/index.cjs +1 -1
- package/dist/operations/index.d.ts +120 -120
- package/dist/operations/index.js +1 -1
- package/dist/parsers/index.cjs +1 -1
- package/dist/parsers/index.d.ts +34 -34
- package/dist/parsers/index.js +1 -1
- package/dist/predicates/index.cjs +1 -1
- package/dist/predicates/index.d.ts +1674 -1674
- package/dist/predicates/index.js +1 -1
- package/dist/prettify-C4xLcYOP.d.ts +328 -328
- package/dist/promise/index.cjs +1 -1
- package/dist/promise/index.d.ts +29 -29
- package/dist/promise/index.js +1 -1
- package/dist/rzl-utils.global.js +1 -1
- package/dist/string-XA-til3C.d.ts +318 -318
- package/dist/strings/index.cjs +1 -1
- package/dist/strings/index.d.ts +690 -690
- package/dist/strings/index.js +1 -1
- package/dist/stylings/index.cjs +1 -1
- package/dist/stylings/index.d.ts +35 -35
- package/dist/stylings/index.js +1 -1
- package/dist/type-data-DDs-u2kq.d.ts +241 -241
- package/dist/types/index.d.ts +3264 -3264
- package/dist/urls/index.cjs +1 -1
- package/dist/urls/index.d.ts +373 -373
- package/dist/urls/index.js +1 -1
- package/package.json +3 -15
- package/dist/chunk-2JQQQ625.js +0 -1
- package/dist/chunk-445TAVT4.cjs +0 -1
- package/dist/chunk-6Q4I2RPC.cjs +0 -1
- package/dist/chunk-6SMJMZ7G.cjs +0 -1
- package/dist/chunk-DFSTVQFI.cjs +0 -1
- package/dist/chunk-DYRDBYPF.cjs +0 -1
- package/dist/chunk-GAJTFCUA.js +0 -1
- package/dist/chunk-GOJNH55O.cjs +0 -1
- package/dist/chunk-IJTZWWRJ.cjs +0 -1
- package/dist/chunk-ISJ33O2J.cjs +0 -1
- package/dist/chunk-JISH2VGG.js +0 -1
- package/dist/chunk-KZQB7H4E.cjs +0 -1
- package/dist/chunk-LUVV5KSD.cjs +0 -2
- package/dist/chunk-MF5Y5K4N.cjs +0 -1
- package/dist/chunk-O5VXBNUQ.cjs +0 -4
- package/dist/chunk-O7SJR4CY.cjs +0 -1
- package/dist/chunk-PYUVKHUF.cjs +0 -1
- package/dist/chunk-XFCJDSB2.cjs +0 -1
- package/dist/chunk-XOYX4PLZ.cjs +0 -1
- package/dist/chunk-Z6FLCEN6.js +0 -1
- package/dist/chunk-ZO5364A6.cjs +0 -1
- package/dist/index.cjs +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
package/dist/formatting/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{h as censorEmail,i as chunkString,a as formatCurrency,f as formatDateFns,e as formatDateIntl,d as formatDateTime,b as formatNumber,c as formatPhoneNumber,g as getGMTOffset,j as truncateString}from'../chunk-
|
|
1
|
+
export{h as censorEmail,i as chunkString,a as formatCurrency,f as formatDateFns,e as formatDateIntl,d as formatDateTime,b as formatNumber,c as formatPhoneNumber,g as getGMTOffset,j as truncateString}from'../chunk-G4EWCRKS.js';import'../chunk-7VX33E3V.js';import'../chunk-ESJYBIYH.js';import'../chunk-NR44SNYE.js';import'../chunk-7CHFAMS2.js';import'../chunk-NJSAV73S.js';import'../chunk-ELDDNERR.js';import'../chunk-J4NCYYGS.js';import'../chunk-5SZUSNGZ.js';import'../chunk-EWYPSKKM.js';
|
package/dist/generator/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkSZPWZZYG_cjs=require('../chunk-SZPWZZYG.cjs'),chunkRV2VULM7_cjs=require('../chunk-RV2VULM7.cjs');require('../chunk-PUQXRLZH.cjs'),require('../chunk-26W3VZIK.cjs'),require('../chunk-7YWAQOA4.cjs'),require('../chunk-CII6WWLO.cjs');Object.defineProperty(exports,"getRandomItem",{enumerable:true,get:function(){return chunkSZPWZZYG_cjs.a}});Object.defineProperty(exports,"randomInt",{enumerable:true,get:function(){return chunkSZPWZZYG_cjs.b}});Object.defineProperty(exports,"randomIntByLength",{enumerable:true,get:function(){return chunkSZPWZZYG_cjs.c}});Object.defineProperty(exports,"randomStr",{enumerable:true,get:function(){return chunkSZPWZZYG_cjs.d}});Object.defineProperty(exports,"noop",{enumerable:true,get:function(){return chunkRV2VULM7_cjs.a}});
|
|
@@ -1,186 +1,186 @@
|
|
|
1
1
|
import{f as IfNonEmptyArray,E as Extends}from'../extends-Bk_SBGdT.js';import{F as FixNeverArrayRecursive}from'../arrays-normalize-recursive-CnjYJ9xg.js';import{g as NullToUndefined}from'../nils-DMz3kU7M.js';import'../if-CvT4R7Kh.js';import'../never-BfayMBF9.js';type OptionsRandomStr={
|
|
2
2
|
/** Ensures no whitespace characters in the generated string, defaultValue: `true`.
|
|
3
|
-
*
|
|
4
|
-
* @default true
|
|
5
|
-
*/
|
|
3
|
+
*
|
|
4
|
+
* @default true
|
|
5
|
+
*/
|
|
6
6
|
avoidWhiteSpace?:boolean;
|
|
7
7
|
/** Custom characters to replace the default number set if `type` is `"number"`, defaultValue: `undefined`.
|
|
8
|
-
*
|
|
9
|
-
* @default undefined
|
|
10
|
-
*/
|
|
8
|
+
*
|
|
9
|
+
* @default undefined
|
|
10
|
+
*/
|
|
11
11
|
replaceGenInt?:string;
|
|
12
12
|
/** Custom characters to replace the default string set if `type` is `"string"`, defaultValue: `undefined`.
|
|
13
|
-
*
|
|
14
|
-
* @default undefined
|
|
15
|
-
*/
|
|
13
|
+
*
|
|
14
|
+
* @default undefined
|
|
15
|
+
*/
|
|
16
16
|
replaceGenStr?:string;
|
|
17
17
|
/** Additional characters to include in the generated string, defaultValue: `undefined`.
|
|
18
|
-
*
|
|
19
|
-
* @default undefined
|
|
20
|
-
*/
|
|
18
|
+
*
|
|
19
|
+
* @default undefined
|
|
20
|
+
*/
|
|
21
21
|
addChar?:string;
|
|
22
22
|
/** Minimum length of the generated string (1 to 5000), defaultValue: `40`.
|
|
23
|
-
*
|
|
24
|
-
* @default 40
|
|
25
|
-
*/
|
|
23
|
+
*
|
|
24
|
+
* @default 40
|
|
25
|
+
*/
|
|
26
26
|
minLength?:number;
|
|
27
27
|
/** Maximum length of the generated string (1 to 5000), defaultValue: `40`.
|
|
28
|
-
*
|
|
29
|
-
* @default 40
|
|
30
|
-
*/
|
|
28
|
+
*
|
|
29
|
+
* @default 40
|
|
30
|
+
*/
|
|
31
31
|
maxLength?:number;
|
|
32
32
|
/** Type of output: `"string"` or `"number"`, defaultValue: `"string"`.
|
|
33
|
-
*
|
|
34
|
-
* @default "string"
|
|
35
|
-
*/
|
|
33
|
+
*
|
|
34
|
+
* @default "string"
|
|
35
|
+
*/
|
|
36
36
|
type?:"string"|"number";};
|
|
37
37
|
/** ---------------------------------
|
|
38
|
-
* * ***Returns a random element from a given array.***
|
|
39
|
-
* ---------------------------------
|
|
40
|
-
* @template T - The type of the input array.
|
|
41
|
-
* @param {*} array - The input array. Can be `null`, `undefined`, or an empty array.
|
|
42
|
-
* @returns
|
|
43
|
-
* - If `array` is a non-empty tuple, returns one of its elements.
|
|
44
|
-
* - If `array` is empty, `null`, or `undefined`, returns `undefined`.
|
|
45
|
-
* @example
|
|
46
|
-
* getRandomItem([]);
|
|
47
|
-
* // ➔ undefined
|
|
48
|
-
* getRandomItem(null);
|
|
49
|
-
* // ➔ undefined
|
|
50
|
-
* getRandomItem(undefined);
|
|
51
|
-
* // ➔ undefined
|
|
52
|
-
* getRandomItem([1, 2, 3, 4]);
|
|
53
|
-
* // ➔ number
|
|
54
|
-
* getRandomItem(["apple", "banana", "cherry"]);
|
|
55
|
-
* // ➔ string
|
|
56
|
-
* getRandomItem(["apple", 123, true]);
|
|
57
|
-
* // ➔ string | number | boolean
|
|
58
|
-
* getRandomItem(["apple", 123, true, null]);
|
|
59
|
-
* // ➔ string | number | boolean | undefined
|
|
60
|
-
* getRandomItem(["apple", 123, true, undefined]);
|
|
61
|
-
* // ➔ string | number | boolean | undefined
|
|
62
|
-
*
|
|
63
|
-
* // Tuple example:
|
|
64
|
-
* const tuple = [1, "two", true] as const;
|
|
65
|
-
* getRandomItem(tuple); // 1 | "two" | true
|
|
66
|
-
*/
|
|
38
|
+
* * ***Returns a random element from a given array.***
|
|
39
|
+
* ---------------------------------
|
|
40
|
+
* @template T - The type of the input array.
|
|
41
|
+
* @param {*} array - The input array. Can be `null`, `undefined`, or an empty array.
|
|
42
|
+
* @returns
|
|
43
|
+
* - If `array` is a non-empty tuple, returns one of its elements.
|
|
44
|
+
* - If `array` is empty, `null`, or `undefined`, returns `undefined`.
|
|
45
|
+
* @example
|
|
46
|
+
* getRandomItem([]);
|
|
47
|
+
* // ➔ undefined
|
|
48
|
+
* getRandomItem(null);
|
|
49
|
+
* // ➔ undefined
|
|
50
|
+
* getRandomItem(undefined);
|
|
51
|
+
* // ➔ undefined
|
|
52
|
+
* getRandomItem([1, 2, 3, 4]);
|
|
53
|
+
* // ➔ number
|
|
54
|
+
* getRandomItem(["apple", "banana", "cherry"]);
|
|
55
|
+
* // ➔ string
|
|
56
|
+
* getRandomItem(["apple", 123, true]);
|
|
57
|
+
* // ➔ string | number | boolean
|
|
58
|
+
* getRandomItem(["apple", 123, true, null]);
|
|
59
|
+
* // ➔ string | number | boolean | undefined
|
|
60
|
+
* getRandomItem(["apple", 123, true, undefined]);
|
|
61
|
+
* // ➔ string | number | boolean | undefined
|
|
62
|
+
*
|
|
63
|
+
* // Tuple example:
|
|
64
|
+
* const tuple = [1, "two", true] as const;
|
|
65
|
+
* getRandomItem(tuple); // 1 | "two" | true
|
|
66
|
+
*/
|
|
67
67
|
declare function getRandomItem(array:undefined):undefined;declare function getRandomItem(array:null):undefined;declare function getRandomItem(array:[]):undefined;declare function getRandomItem<T extends readonly unknown[]>(array:T):T extends never[][]?[]:number extends T["length"]?NullToUndefined<FixNeverArrayRecursive<T[number]>>:IfNonEmptyArray<T,NullToUndefined<FixNeverArrayRecursive<T[number]>>,undefined>;declare function getRandomItem<T extends readonly unknown[]|undefined|null>(array:T):T extends readonly unknown[]?NullToUndefined<FixNeverArrayRecursive<T[number]>>|undefined:undefined;declare function getRandomItem<T>(array:T):unknown extends T?unknown:Extends<any[]|readonly any[],T>extends true?Extract<T,unknown[]|readonly unknown[]>[number]|undefined:Extends<any[],T>extends true?Extract<T,unknown[]|readonly unknown[]>[number]|undefined:Extends<readonly any[],T>extends true?Extract<T,unknown[]|readonly unknown[]>[number]|undefined:undefined;
|
|
68
68
|
/** -----------------------------------------------------------------------
|
|
69
|
-
* * ***Generates a random integer within a specified range (inclusive).***
|
|
70
|
-
* ------------------------------------------------------------------------
|
|
71
|
-
* Generates a random integer between `min` and `max` (inclusive), with safety constraints:
|
|
72
|
-
* - `min` will be forced to be at least `1`.
|
|
73
|
-
* - `max` will be capped at `Number.MAX_SAFE_INTEGER`.
|
|
74
|
-
*
|
|
75
|
-
* Validates input parameters to ensure robust behavior.
|
|
76
|
-
* @param {number} min - The minimum value (inclusive), must be an integer.
|
|
77
|
-
* @param {number} max - The maximum value (inclusive), must be an integer.
|
|
78
|
-
* @returns {number} A random integer N where `min ≤ N ≤ max`.
|
|
79
|
-
* @throws {TypeError} If:
|
|
80
|
-
* - `min` or `max` is not an integer and value is `Number.MIN_VALUE`.
|
|
81
|
-
* - `min` is greater than `max`.
|
|
82
|
-
* @example
|
|
83
|
-
* randomInt(1, 10); // ➔ returns 1 to 10
|
|
84
|
-
* randomInt(50, 100); // ➔ returns 50 to 100
|
|
85
|
-
* randomInt(5, 5); // ➔ always returns 5
|
|
86
|
-
* randomInt(-5, 3); // ➔ always returns ≥ 1, since min is adjusted
|
|
87
|
-
* randomInt(1, Number.MAX_SAFE_INTEGER + 10000);
|
|
88
|
-
* // ➔ still safely capped at MAX_SAFE_INTEGER
|
|
89
|
-
* randomInt(Number.MIN_VALUE, 3);
|
|
90
|
-
* // ➔ Error, min or max cant be as `Number.MIN_VALUE` value.
|
|
91
|
-
*/
|
|
69
|
+
* * ***Generates a random integer within a specified range (inclusive).***
|
|
70
|
+
* ------------------------------------------------------------------------
|
|
71
|
+
* Generates a random integer between `min` and `max` (inclusive), with safety constraints:
|
|
72
|
+
* - `min` will be forced to be at least `1`.
|
|
73
|
+
* - `max` will be capped at `Number.MAX_SAFE_INTEGER`.
|
|
74
|
+
*
|
|
75
|
+
* Validates input parameters to ensure robust behavior.
|
|
76
|
+
* @param {number} min - The minimum value (inclusive), must be an integer.
|
|
77
|
+
* @param {number} max - The maximum value (inclusive), must be an integer.
|
|
78
|
+
* @returns {number} A random integer N where `min ≤ N ≤ max`.
|
|
79
|
+
* @throws {TypeError} If:
|
|
80
|
+
* - `min` or `max` is not an integer and value is `Number.MIN_VALUE`.
|
|
81
|
+
* - `min` is greater than `max`.
|
|
82
|
+
* @example
|
|
83
|
+
* randomInt(1, 10); // ➔ returns 1 to 10
|
|
84
|
+
* randomInt(50, 100); // ➔ returns 50 to 100
|
|
85
|
+
* randomInt(5, 5); // ➔ always returns 5
|
|
86
|
+
* randomInt(-5, 3); // ➔ always returns ≥ 1, since min is adjusted
|
|
87
|
+
* randomInt(1, Number.MAX_SAFE_INTEGER + 10000);
|
|
88
|
+
* // ➔ still safely capped at MAX_SAFE_INTEGER
|
|
89
|
+
* randomInt(Number.MIN_VALUE, 3);
|
|
90
|
+
* // ➔ Error, min or max cant be as `Number.MIN_VALUE` value.
|
|
91
|
+
*/
|
|
92
92
|
declare const randomInt:(min:number,max:number)=>number;type OptionsRandomIntByLength={
|
|
93
93
|
/** * Minimum length of the random number, the `allowed minimal value` `integer` is `1` `and not bigger than value of` `maxLength`, defaultValue: `1`.
|
|
94
|
-
*
|
|
95
|
-
* @default 1
|
|
96
|
-
*/
|
|
94
|
+
*
|
|
95
|
+
* @default 1
|
|
96
|
+
*/
|
|
97
97
|
minLength?:number;
|
|
98
98
|
/** * Maximum length of the random number, the `allowed maximal value` `integer` is `16`, defaultValue: `16`.
|
|
99
|
-
*
|
|
100
|
-
* @default 16
|
|
101
|
-
*/
|
|
99
|
+
*
|
|
100
|
+
* @default 16
|
|
101
|
+
*/
|
|
102
102
|
maxLength?:number;
|
|
103
103
|
/** * If true, prevents the result from being zero, defaultValue: `false`.
|
|
104
|
-
*
|
|
105
|
-
* @default false
|
|
106
|
-
*/
|
|
104
|
+
*
|
|
105
|
+
* @default false
|
|
106
|
+
*/
|
|
107
107
|
avoidZero?:boolean;};
|
|
108
108
|
/** ----------------------------------------------------------------------------
|
|
109
|
-
* * ***Generates a random integer within a specified range of digit lengths.***
|
|
110
|
-
* -----------------------------------------------------------------------------
|
|
111
|
-
* **This function allows generating random integers that strictly conform to a specified minimum and
|
|
112
|
-
* maximum digit length, it is useful for scenarios such as generating realistic-looking IDs, codes,
|
|
113
|
-
* or random test data.**
|
|
114
|
-
* - **The function ensures:**
|
|
115
|
-
* - `minLength` is at least 1 and not greater than `maxLength`.
|
|
116
|
-
* - `maxLength` is no more than 16 (due to JavaScript's Number.MAX_SAFE_INTEGER).
|
|
117
|
-
* - If `avoidZero` is `true`, ensures that `0` is never returned.
|
|
118
|
-
* @param {OptionsRandomIntByLength} [options] - Configuration options.
|
|
119
|
-
* @param {OptionsRandomIntByLength["minLength"]} [options.minLength=1] - Minimum number of digits (must be ≥1 and ≤ `maxLength`).
|
|
120
|
-
* @param {OptionsRandomIntByLength["maxLength"]} [options.maxLength=16] - Maximum number of digits (must be ≤16).
|
|
121
|
-
* @param {OptionsRandomIntByLength["avoidZero"]} [options.avoidZero=false] - If true, will ensure the result is never zero.
|
|
122
|
-
* @returns {number} A randomly generated integer within the specified constraints.
|
|
123
|
-
* @throws {TypeError} If parameters are invalid, such as:
|
|
124
|
-
* - `minLength` < `1`
|
|
125
|
-
* - `maxLength` > `16`
|
|
126
|
-
* - `minLength` > `maxLength`
|
|
127
|
-
* - non-integer values for `minLength` or `maxLength`
|
|
128
|
-
* @example
|
|
129
|
-
* randomIntByLength({ minLength: 3, maxLength: 5 });
|
|
130
|
-
* // ➔ (`4829` << random), (`192` << random) or (`71492` << random).
|
|
131
|
-
* randomIntByLength({ minLength: 4, maxLength: 4 });
|
|
132
|
-
* // ➔ `5930` (exact 4 digits)
|
|
133
|
-
* randomIntByLength({ avoidZero: true });
|
|
134
|
-
* // ➔ never 0
|
|
135
|
-
*/
|
|
109
|
+
* * ***Generates a random integer within a specified range of digit lengths.***
|
|
110
|
+
* -----------------------------------------------------------------------------
|
|
111
|
+
* **This function allows generating random integers that strictly conform to a specified minimum and
|
|
112
|
+
* maximum digit length, it is useful for scenarios such as generating realistic-looking IDs, codes,
|
|
113
|
+
* or random test data.**
|
|
114
|
+
* - **The function ensures:**
|
|
115
|
+
* - `minLength` is at least 1 and not greater than `maxLength`.
|
|
116
|
+
* - `maxLength` is no more than 16 (due to JavaScript's Number.MAX_SAFE_INTEGER).
|
|
117
|
+
* - If `avoidZero` is `true`, ensures that `0` is never returned.
|
|
118
|
+
* @param {OptionsRandomIntByLength} [options] - Configuration options.
|
|
119
|
+
* @param {OptionsRandomIntByLength["minLength"]} [options.minLength=1] - Minimum number of digits (must be ≥1 and ≤ `maxLength`).
|
|
120
|
+
* @param {OptionsRandomIntByLength["maxLength"]} [options.maxLength=16] - Maximum number of digits (must be ≤16).
|
|
121
|
+
* @param {OptionsRandomIntByLength["avoidZero"]} [options.avoidZero=false] - If true, will ensure the result is never zero.
|
|
122
|
+
* @returns {number} A randomly generated integer within the specified constraints.
|
|
123
|
+
* @throws {TypeError} If parameters are invalid, such as:
|
|
124
|
+
* - `minLength` < `1`
|
|
125
|
+
* - `maxLength` > `16`
|
|
126
|
+
* - `minLength` > `maxLength`
|
|
127
|
+
* - non-integer values for `minLength` or `maxLength`
|
|
128
|
+
* @example
|
|
129
|
+
* randomIntByLength({ minLength: 3, maxLength: 5 });
|
|
130
|
+
* // ➔ (`4829` << random), (`192` << random) or (`71492` << random).
|
|
131
|
+
* randomIntByLength({ minLength: 4, maxLength: 4 });
|
|
132
|
+
* // ➔ `5930` (exact 4 digits)
|
|
133
|
+
* randomIntByLength({ avoidZero: true });
|
|
134
|
+
* // ➔ never 0
|
|
135
|
+
*/
|
|
136
136
|
declare const randomIntByLength:(options?:OptionsRandomIntByLength)=>number;
|
|
137
137
|
/** ---------------------------------------------------------------------------------
|
|
138
|
-
* * ***Generates a random alphanumeric string or number with a specified length range.***
|
|
139
|
-
* ---------------------------------------------------------------------------------
|
|
140
|
-
* **This function allows you to generate random strings or numbers with fully
|
|
141
|
-
* customizable options, such as length range, character sets, inclusion of
|
|
142
|
-
* additional characters, and whether to avoid whitespace.**
|
|
143
|
-
* @param {OptionsRandomStr} [options] - Configuration options for generating the string.
|
|
144
|
-
* @param {OptionsRandomStr["minLength"]} [options.minLength=40] - Minimum length of the generated string (must be `≥` `1`).
|
|
145
|
-
* @param {OptionsRandomStr["maxLength"]} [options.maxLength=40] - Maximum length of the generated string (must be `≤` `5000`).
|
|
146
|
-
* @param {OptionsRandomStr["type"]} [options.type="string"] - Whether to generate a general alphanumeric string or purely numeric string.
|
|
147
|
-
* @param {OptionsRandomStr["avoidWhiteSpace"]} [options.avoidWhiteSpace=true] - If true, removes all whitespace, tabs, and newlines from the character set before generating.
|
|
148
|
-
* @param {OptionsRandomStr["replaceGenStr"]} [options.replaceGenStr] - A custom character set to use when `type` is `"string"`.
|
|
149
|
-
* @param {OptionsRandomStr["replaceGenInt"]} [options.replaceGenInt] - A custom character set to use when `type` is `"number"`.
|
|
150
|
-
* @param {OptionsRandomStr["addChar"]} [options.addChar] - Additional characters to always include in the character set.
|
|
151
|
-
* @returns {string} The randomly generated string or numeric string of the desired length.
|
|
152
|
-
* @throws {TypeError} If provided options are invalid (such as minLength > maxLength, invalid type, or empty character set).
|
|
153
|
-
* @example
|
|
154
|
-
* randomStr();
|
|
155
|
-
* // ➔ Generates a 40-character random alphanumeric string
|
|
156
|
-
* randomStr({ minLength: 10, maxLength: 20 });
|
|
157
|
-
* // ➔ Generates a string between 10 and 20 characters
|
|
158
|
-
* randomStr({ type: "number", minLength: 5, maxLength: 5 });
|
|
159
|
-
* // ➔ "48302"
|
|
160
|
-
* randomStr({ replaceGenStr: "ABC ", avoidWhiteSpace: false });
|
|
161
|
-
* // ➔ String using A, B, C and space
|
|
162
|
-
* randomStr({ addChar: "!@#", minLength: 15, maxLength: 15 });
|
|
163
|
-
* // ➔ Guaranteed to include !@# in the set
|
|
164
|
-
*/
|
|
138
|
+
* * ***Generates a random alphanumeric string or number with a specified length range.***
|
|
139
|
+
* ---------------------------------------------------------------------------------
|
|
140
|
+
* **This function allows you to generate random strings or numbers with fully
|
|
141
|
+
* customizable options, such as length range, character sets, inclusion of
|
|
142
|
+
* additional characters, and whether to avoid whitespace.**
|
|
143
|
+
* @param {OptionsRandomStr} [options] - Configuration options for generating the string.
|
|
144
|
+
* @param {OptionsRandomStr["minLength"]} [options.minLength=40] - Minimum length of the generated string (must be `≥` `1`).
|
|
145
|
+
* @param {OptionsRandomStr["maxLength"]} [options.maxLength=40] - Maximum length of the generated string (must be `≤` `5000`).
|
|
146
|
+
* @param {OptionsRandomStr["type"]} [options.type="string"] - Whether to generate a general alphanumeric string or purely numeric string.
|
|
147
|
+
* @param {OptionsRandomStr["avoidWhiteSpace"]} [options.avoidWhiteSpace=true] - If true, removes all whitespace, tabs, and newlines from the character set before generating.
|
|
148
|
+
* @param {OptionsRandomStr["replaceGenStr"]} [options.replaceGenStr] - A custom character set to use when `type` is `"string"`.
|
|
149
|
+
* @param {OptionsRandomStr["replaceGenInt"]} [options.replaceGenInt] - A custom character set to use when `type` is `"number"`.
|
|
150
|
+
* @param {OptionsRandomStr["addChar"]} [options.addChar] - Additional characters to always include in the character set.
|
|
151
|
+
* @returns {string} The randomly generated string or numeric string of the desired length.
|
|
152
|
+
* @throws {TypeError} If provided options are invalid (such as minLength > maxLength, invalid type, or empty character set).
|
|
153
|
+
* @example
|
|
154
|
+
* randomStr();
|
|
155
|
+
* // ➔ Generates a 40-character random alphanumeric string
|
|
156
|
+
* randomStr({ minLength: 10, maxLength: 20 });
|
|
157
|
+
* // ➔ Generates a string between 10 and 20 characters
|
|
158
|
+
* randomStr({ type: "number", minLength: 5, maxLength: 5 });
|
|
159
|
+
* // ➔ "48302"
|
|
160
|
+
* randomStr({ replaceGenStr: "ABC ", avoidWhiteSpace: false });
|
|
161
|
+
* // ➔ String using A, B, C and space
|
|
162
|
+
* randomStr({ addChar: "!@#", minLength: 15, maxLength: 15 });
|
|
163
|
+
* // ➔ Guaranteed to include !@# in the set
|
|
164
|
+
*/
|
|
165
165
|
declare const randomStr:(options?:OptionsRandomStr)=>string;
|
|
166
166
|
/** --------------------------------------------------
|
|
167
|
-
* * ***A no-operation function that always returns `undefined`.***
|
|
168
|
-
* --------------------------------------------------
|
|
169
|
-
* **Useful as a default callback, placeholder, or stub function.**
|
|
170
|
-
* @returns {undefined} Always returns `undefined`.
|
|
171
|
-
* @example
|
|
172
|
-
* // Direct call returns undefined
|
|
173
|
-
* noop();
|
|
174
|
-
* // ➔ undefined
|
|
175
|
-
*
|
|
176
|
-
* // Can be used with type-checking helpers
|
|
177
|
-
* isUndefined(noop()); // ➔ true
|
|
178
|
-
* isFunction(noop); // ➔ true
|
|
179
|
-
* isFunction(noop()); // ➔ false
|
|
180
|
-
*
|
|
181
|
-
* // Often used as a default function
|
|
182
|
-
* const callback = noop;
|
|
183
|
-
* callback();
|
|
184
|
-
* // ➔ undefined
|
|
185
|
-
*/
|
|
167
|
+
* * ***A no-operation function that always returns `undefined`.***
|
|
168
|
+
* --------------------------------------------------
|
|
169
|
+
* **Useful as a default callback, placeholder, or stub function.**
|
|
170
|
+
* @returns {undefined} Always returns `undefined`.
|
|
171
|
+
* @example
|
|
172
|
+
* // Direct call returns undefined
|
|
173
|
+
* noop();
|
|
174
|
+
* // ➔ undefined
|
|
175
|
+
*
|
|
176
|
+
* // Can be used with type-checking helpers
|
|
177
|
+
* isUndefined(noop()); // ➔ true
|
|
178
|
+
* isFunction(noop); // ➔ true
|
|
179
|
+
* isFunction(noop()); // ➔ false
|
|
180
|
+
*
|
|
181
|
+
* // Often used as a default function
|
|
182
|
+
* const callback = noop;
|
|
183
|
+
* callback();
|
|
184
|
+
* // ➔ undefined
|
|
185
|
+
*/
|
|
186
186
|
declare const noop:()=>void;export{getRandomItem,noop,randomInt,randomIntByLength,randomStr};
|
package/dist/generator/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{a as getRandomItem,b as randomInt,c as randomIntByLength,d as randomStr}from'../chunk-
|
|
1
|
+
export{a as getRandomItem,b as randomInt,c as randomIntByLength,d as randomStr}from'../chunk-5Q37AP7P.js';export{a as noop}from'../chunk-SYJC7UAW.js';import'../chunk-ELDDNERR.js';import'../chunk-J4NCYYGS.js';import'../chunk-5SZUSNGZ.js';import'../chunk-EWYPSKKM.js';
|
package/dist/if-CvT4R7Kh.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/** -------------------------------------------------------
|
|
2
|
-
* * ***If.***
|
|
3
|
-
* -------------------------------------------------------
|
|
4
|
-
* Conditional: returns the second argument if the first argument is `true`, otherwise returns the third argument.
|
|
5
|
-
* - Defaults: `IfTrue = true`, `IfFalse = false`.
|
|
6
|
-
*
|
|
7
|
-
* @template Condition - The boolean condition to check.
|
|
8
|
-
* @template IfTrue - The branch type if condition is `true`. (default: `true`)
|
|
9
|
-
* @template IfFalse - The branch type if condition is `false`. (default: `false`)
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* type A = If<true, "valid">;
|
|
13
|
-
* // ➔ "valid"
|
|
14
|
-
* type B = If<false, "valid", "invalid">;
|
|
15
|
-
* // ➔ "invalid"
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
2
|
+
* * ***If.***
|
|
3
|
+
* -------------------------------------------------------
|
|
4
|
+
* Conditional: returns the second argument if the first argument is `true`, otherwise returns the third argument.
|
|
5
|
+
* - Defaults: `IfTrue = true`, `IfFalse = false`.
|
|
6
|
+
*
|
|
7
|
+
* @template Condition - The boolean condition to check.
|
|
8
|
+
* @template IfTrue - The branch type if condition is `true`. (default: `true`)
|
|
9
|
+
* @template IfFalse - The branch type if condition is `false`. (default: `false`)
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* type A = If<true, "valid">;
|
|
13
|
+
* // ➔ "valid"
|
|
14
|
+
* type B = If<false, "valid", "invalid">;
|
|
15
|
+
* // ➔ "invalid"
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
18
|
type If<Condition,IfTrue=true,IfFalse=false>=Condition extends true?IfTrue:IfFalse;export type{If as I};
|