@rzl-zone/utils-js 3.3.1 → 3.5.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 +94 -45
- package/dist/assertions/index.cjs +34 -1
- package/dist/assertions/index.d.ts +2 -2
- package/dist/assertions/index.js +5 -1
- package/dist/chunk-2CQX5CBG.js +247 -1
- package/dist/chunk-2IOOEY45.cjs +20 -1
- package/dist/chunk-2WA36TC5.cjs +176 -0
- package/dist/chunk-3IBQ5MOM.js +6 -1
- package/dist/chunk-3VA554KW.js +23 -1
- package/dist/chunk-5757UBXJ.cjs +144 -1
- package/dist/chunk-5IGC6PBH.js +22 -1
- package/dist/chunk-5KJFVIQT.cjs +55 -1
- package/dist/chunk-6JFCSH7J.js +24 -1
- package/dist/chunk-6JFZL7YE.cjs +14 -1
- package/dist/chunk-7ODAAXX5.cjs +361 -1
- package/dist/chunk-BAV5T2E3.cjs +5 -1
- package/dist/chunk-CAH33WOQ.cjs +25 -1
- package/dist/chunk-CDCERIZ2.js +164 -0
- package/dist/chunk-CKTLUNWX.js +12 -1
- package/dist/chunk-CMW2TBOQ.js +522 -1
- package/dist/chunk-D3ENH7H6.cjs +87 -1
- package/dist/chunk-DEZZUYE2.js +139 -1
- package/dist/chunk-DVMHRLKP.cjs +6 -1
- package/dist/chunk-DWF2R5GD.cjs +212 -1
- package/dist/chunk-E55EQK2U.cjs +8 -1
- package/dist/chunk-E74U6CYP.cjs +8 -1
- package/dist/chunk-EL6A35UR.cjs +51 -1
- package/dist/chunk-F6IPNNSJ.cjs +531 -1
- package/dist/chunk-FJZGG54N.cjs +252 -1
- package/dist/chunk-FWCKOJZM.js +519 -1
- package/dist/chunk-FWHNWL2P.cjs +409 -1
- package/dist/chunk-GGEADHZO.js +78 -1
- package/dist/chunk-GQR4R5WY.js +21 -1
- package/dist/chunk-H66AC7GK.cjs +81 -1
- package/dist/chunk-HQWOFR56.cjs +23 -1
- package/dist/chunk-HYRQMTRH.cjs +14 -1
- package/dist/chunk-IRFL4MAX.js +53 -1
- package/dist/chunk-IVL7CKVH.cjs +26 -1
- package/dist/chunk-IZPBKKPO.js +6 -1
- package/dist/chunk-JBQMXC5I.cjs +93 -1
- package/dist/chunk-JEQEF5WD.js +81 -1
- package/dist/chunk-JMJQCN74.js +334 -1
- package/dist/chunk-KHO2SBNA.cjs +6 -1
- package/dist/chunk-KVAL5PAG.cjs +16 -1
- package/dist/chunk-L5RDAVVH.js +5 -1
- package/dist/chunk-LS6U7FAY.cjs +98 -1
- package/dist/chunk-NBZWMBO6.js +88 -1
- package/dist/chunk-NRF6LWBC.cjs +45 -1
- package/dist/chunk-OI5XKNZO.js +42 -1
- package/dist/chunk-ONZFBJVW.js +5 -1
- package/dist/chunk-OYTYSY7G.js +94 -1
- package/dist/chunk-PET42Z7W.js +107 -1
- package/dist/chunk-PZQ6I4JJ.cjs +559 -1
- package/dist/chunk-QBKAEVYG.js +102 -1
- package/dist/chunk-QNKGP5DY.js +5 -1
- package/dist/chunk-RIPKY4RU.js +407 -1
- package/dist/chunk-RZW35UN5.cjs +105 -1
- package/dist/chunk-SBFNXGTJ.js +207 -1
- package/dist/chunk-SBKGWRS5.js +12 -1
- package/dist/chunk-SIM77PU4.js +46 -1
- package/dist/chunk-T2T7K3KR.js +18 -1
- package/dist/chunk-T7PU2V7X.cjs +111 -1
- package/dist/chunk-UDA26MCU.cjs +6 -1
- package/dist/chunk-V45XJKHW.cjs +8 -1
- package/dist/chunk-VJDDGRIK.cjs +6 -1
- package/dist/chunk-W2WNBUDE.js +6 -1
- package/dist/chunk-WVSPXFTY.js +5 -1
- package/dist/chunk-XABCB3Y7.cjs +563 -1
- package/dist/chunk-XEDXFSGI.js +14 -1
- package/dist/chunk-YKPSRP5G.js +552 -1
- package/dist/chunk-YWHHVDT4.js +4 -1
- package/dist/chunk-ZETAZZLD.cjs +27 -1
- package/dist/conversions/index.cjs +97 -1
- package/dist/conversions/index.d.ts +2 -2
- package/dist/conversions/index.js +16 -1
- package/dist/events/index.cjs +25 -1
- package/dist/events/index.d.ts +1 -1
- package/dist/events/index.js +4 -1
- package/dist/formatters/index.cjs +55 -1
- package/dist/formatters/index.d.ts +2 -2
- package/dist/formatters/index.js +10 -1
- package/dist/generators/index.cjs +31 -1
- package/dist/generators/index.d.ts +2 -2
- package/dist/generators/index.js +6 -1
- package/dist/index.d.ts +1 -1
- package/dist/{isPlainObject-DGJkcFYw.d.ts → isPlainObject-FWmcJF6k.d.ts} +5 -5
- package/dist/next/index.cjs +205 -1
- package/dist/next/index.d.ts +2 -2
- package/dist/next/index.js +200 -1
- package/dist/next/server/index.cjs +34 -1
- package/dist/next/server/index.d.ts +1 -1
- package/dist/next/server/index.js +32 -1
- package/dist/operations/index.cjs +26 -1
- package/dist/operations/index.d.ts +2 -2
- package/dist/operations/index.js +9 -1
- package/dist/parsers/index.cjs +11 -1
- package/dist/parsers/index.d.ts +1 -1
- package/dist/parsers/index.js +2 -1
- package/dist/predicates/index.cjs +292 -1
- package/dist/predicates/index.d.ts +4 -4
- package/dist/predicates/index.js +15 -1
- package/dist/promises/index.cjs +18 -1
- package/dist/promises/index.d.ts +2 -2
- package/dist/promises/index.js +5 -1
- package/dist/rzl-utils.global.js +16 -1
- package/dist/strings/index.cjs +75 -1
- package/dist/strings/index.d.ts +2 -2
- package/dist/strings/index.js +6 -1
- package/dist/tailwind/index.cjs +36 -1
- package/dist/tailwind/index.d.ts +1 -1
- package/dist/tailwind/index.js +3 -1
- package/dist/urls/index.cjs +44 -1
- package/dist/urls/index.d.ts +1 -1
- package/dist/urls/index.js +15 -1
- package/package.json +16 -24
- package/dist/NumberRangeUnion-B6bhM2s7.d.ts +0 -33
- package/dist/any-v4TsK9ES.d.ts +0 -66
- package/dist/arrays-normalize-recursive-BqmVuFlD.d.ts +0 -72
- package/dist/chunk-JYQTCICM.js +0 -1
- package/dist/chunk-YLA3DURS.cjs +0 -1
- package/dist/extends-DtdRjDyU.d.ts +0 -343
- package/dist/if-ChM35c_q.d.ts +0 -19
- package/dist/is-array-BJeHxPM3.d.ts +0 -952
- package/dist/never-D89PbPh5.d.ts +0 -66
- package/dist/nils-CO8zLHSB.d.ts +0 -151
- package/dist/or-C6qzKt2I.d.ts +0 -82
- package/dist/override-CL2olHE5.d.ts +0 -59
- package/dist/pick-BSMX6Xe2.d.ts +0 -15
- package/dist/prettify-3o8_Kw6b.d.ts +0 -564
- package/dist/promises-LU7K00H0.d.ts +0 -72
- package/dist/string-B1jlOnws.d.ts +0 -312
- package/dist/types/index.d.ts +0 -3345
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunk6JFZL7YE_cjs = require('./chunk-6JFZL7YE.cjs');
|
|
4
|
+
var chunkPZQ6I4JJ_cjs = require('./chunk-PZQ6I4JJ.cjs');
|
|
5
|
+
var clsx = require('clsx');
|
|
6
|
+
var tailwindMergeV3 = require('tailwind-merge-v3');
|
|
7
|
+
var tailwindMergeV4 = require('tailwind-merge-v4');
|
|
8
|
+
|
|
9
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
|
|
11
|
+
var clsx__default = /*#__PURE__*/_interopDefault(clsx);
|
|
12
|
+
var validatorPropsTwMerge = (options) => {
|
|
13
|
+
if (!chunkPZQ6I4JJ_cjs.isPlainObject(options)) options = {};
|
|
14
|
+
let { config, prefix, extend, override, cacheSize, experimentalParseClassName } = options;
|
|
15
|
+
if (!chunkPZQ6I4JJ_cjs.isPlainObject(config)) config = {};
|
|
16
|
+
if (!chunkPZQ6I4JJ_cjs.isPlainObject(extend)) extend = {};
|
|
17
|
+
if (!chunkPZQ6I4JJ_cjs.isPlainObject(override)) override = {};
|
|
18
|
+
if (!chunkPZQ6I4JJ_cjs.isNumber(cacheSize)) cacheSize = void 0;
|
|
19
|
+
if (!chunkPZQ6I4JJ_cjs.isNonEmptyString(prefix)) prefix = void 0;
|
|
20
|
+
if (!chunkPZQ6I4JJ_cjs.isFunction(experimentalParseClassName)) experimentalParseClassName = void 0;
|
|
21
|
+
const theme = chunkPZQ6I4JJ_cjs.hasOwnProp(extend, "theme") ? extend.theme : {};
|
|
22
|
+
const classGroups = chunkPZQ6I4JJ_cjs.hasOwnProp(extend, "classGroups") ? extend.classGroups : {};
|
|
23
|
+
const conflictingClassGroupModifiers = chunkPZQ6I4JJ_cjs.hasOwnProp(
|
|
24
|
+
extend,
|
|
25
|
+
"conflictingClassGroupModifiers"
|
|
26
|
+
) ? extend.conflictingClassGroupModifiers : {};
|
|
27
|
+
const conflictingClassGroups = chunkPZQ6I4JJ_cjs.hasOwnProp(extend, "conflictingClassGroups") ? extend.conflictingClassGroups : {};
|
|
28
|
+
const orderSensitiveModifiers = chunkPZQ6I4JJ_cjs.hasOwnProp(extend, "orderSensitiveModifiers") && chunkPZQ6I4JJ_cjs.isNonEmptyArray(extend.orderSensitiveModifiers) ? extend.orderSensitiveModifiers : [];
|
|
29
|
+
return {
|
|
30
|
+
config,
|
|
31
|
+
override,
|
|
32
|
+
cacheSize,
|
|
33
|
+
prefix,
|
|
34
|
+
experimentalParseClassName,
|
|
35
|
+
theme,
|
|
36
|
+
classGroups,
|
|
37
|
+
conflictingClassGroupModifiers,
|
|
38
|
+
conflictingClassGroups,
|
|
39
|
+
orderSensitiveModifiers
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
var defaultConfig = tailwindMergeV3.getDefaultConfig();
|
|
43
|
+
var twMergeDefaultV3 = (options = {}) => {
|
|
44
|
+
if (!chunkPZQ6I4JJ_cjs.isPlainObject(options)) options = {};
|
|
45
|
+
const {
|
|
46
|
+
cacheSize,
|
|
47
|
+
classGroups,
|
|
48
|
+
config,
|
|
49
|
+
conflictingClassGroupModifiers,
|
|
50
|
+
conflictingClassGroups,
|
|
51
|
+
override,
|
|
52
|
+
prefix,
|
|
53
|
+
theme,
|
|
54
|
+
experimentalParseClassName
|
|
55
|
+
} = validatorPropsTwMerge(options);
|
|
56
|
+
return tailwindMergeV3.extendTailwindMerge({
|
|
57
|
+
prefix: prefix ?? config.prefix,
|
|
58
|
+
cacheSize: cacheSize || defaultConfig.cacheSize,
|
|
59
|
+
experimentalParseClassName,
|
|
60
|
+
override,
|
|
61
|
+
extend: {
|
|
62
|
+
conflictingClassGroupModifiers: {
|
|
63
|
+
...defaultConfig.conflictingClassGroupModifiers,
|
|
64
|
+
...conflictingClassGroupModifiers
|
|
65
|
+
},
|
|
66
|
+
theme: { ...defaultConfig.theme, ...theme },
|
|
67
|
+
conflictingClassGroups: {
|
|
68
|
+
...defaultConfig.conflictingClassGroups,
|
|
69
|
+
...conflictingClassGroups
|
|
70
|
+
},
|
|
71
|
+
classGroups: {
|
|
72
|
+
...defaultConfig.classGroups,
|
|
73
|
+
...classGroups,
|
|
74
|
+
"text-shadow": ["", "-sm", "-md", "-lg", "-xl", "-xxl", "-none", "-default"].map(
|
|
75
|
+
(size) => `text-shadow${size}`
|
|
76
|
+
),
|
|
77
|
+
"font-size": Object.keys({
|
|
78
|
+
...config.theme?.fontSize || {},
|
|
79
|
+
...config.theme?.extend?.fontSize || {}
|
|
80
|
+
}).map((size) => `text-${size}`)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
var defaultConfig2 = tailwindMergeV4.getDefaultConfig();
|
|
86
|
+
var twMergeDefaultV4 = (options = {}) => {
|
|
87
|
+
if (!chunkPZQ6I4JJ_cjs.isPlainObject(options)) options = {};
|
|
88
|
+
const {
|
|
89
|
+
cacheSize,
|
|
90
|
+
classGroups,
|
|
91
|
+
config,
|
|
92
|
+
conflictingClassGroupModifiers,
|
|
93
|
+
conflictingClassGroups,
|
|
94
|
+
orderSensitiveModifiers,
|
|
95
|
+
override,
|
|
96
|
+
prefix,
|
|
97
|
+
theme,
|
|
98
|
+
experimentalParseClassName
|
|
99
|
+
} = validatorPropsTwMerge(options);
|
|
100
|
+
return tailwindMergeV4.extendTailwindMerge({
|
|
101
|
+
prefix: prefix || config.prefix,
|
|
102
|
+
cacheSize: cacheSize || defaultConfig2.cacheSize,
|
|
103
|
+
experimentalParseClassName,
|
|
104
|
+
override,
|
|
105
|
+
extend: {
|
|
106
|
+
conflictingClassGroupModifiers: {
|
|
107
|
+
...defaultConfig2.conflictingClassGroupModifiers,
|
|
108
|
+
...conflictingClassGroupModifiers
|
|
109
|
+
},
|
|
110
|
+
theme: { ...defaultConfig2.theme, ...theme },
|
|
111
|
+
conflictingClassGroups: {
|
|
112
|
+
...defaultConfig2.conflictingClassGroups,
|
|
113
|
+
...conflictingClassGroups
|
|
114
|
+
},
|
|
115
|
+
orderSensitiveModifiers: [
|
|
116
|
+
...defaultConfig2.orderSensitiveModifiers,
|
|
117
|
+
...orderSensitiveModifiers
|
|
118
|
+
],
|
|
119
|
+
classGroups: {
|
|
120
|
+
...defaultConfig2.classGroups,
|
|
121
|
+
...classGroups,
|
|
122
|
+
"text-shadow": ["", "-sm", "-md", "-lg", "-xl", "-xxl", "-none", "-default"].map(
|
|
123
|
+
(size) => `text-shadow${size}`
|
|
124
|
+
),
|
|
125
|
+
"font-size": Object.keys({
|
|
126
|
+
...config.theme?.fontSize || {},
|
|
127
|
+
...config.theme?.extend?.fontSize || {}
|
|
128
|
+
}).map((size) => `text-${size}`)
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
var defaultTwMergeV3 = twMergeDefaultV3();
|
|
134
|
+
var defaultTwMergeV4 = twMergeDefaultV4();
|
|
135
|
+
var cnV3 = (...classes) => {
|
|
136
|
+
return defaultTwMergeV3(clsx__default.default(...classes));
|
|
137
|
+
};
|
|
138
|
+
var cnV4 = (...classes) => {
|
|
139
|
+
return defaultTwMergeV4(clsx__default.default(...classes));
|
|
140
|
+
};
|
|
141
|
+
var customCnV3 = (customTwMergeV3, ...classes) => {
|
|
142
|
+
if (!chunkPZQ6I4JJ_cjs.isFunction(customTwMergeV3)) {
|
|
143
|
+
throw new TypeError(
|
|
144
|
+
`first Parameter (\`customTwMergeV3\`) must be of type \`function\`, but received: \`${chunkPZQ6I4JJ_cjs.getPreciseType(
|
|
145
|
+
customTwMergeV3
|
|
146
|
+
)}\`.`
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
return customTwMergeV3(clsx__default.default(...classes));
|
|
150
|
+
};
|
|
151
|
+
var customCnV4 = (customTwMergeV4, ...classes) => {
|
|
152
|
+
if (!chunkPZQ6I4JJ_cjs.isFunction(customTwMergeV4)) {
|
|
153
|
+
throw new TypeError(
|
|
154
|
+
`first Parameter (\`customTwMergeV4\`) must be of type \`function\`, but received: \`${chunkPZQ6I4JJ_cjs.getPreciseType(
|
|
155
|
+
customTwMergeV4
|
|
156
|
+
)}\`.`
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
return customTwMergeV4(clsx__default.default(...classes));
|
|
160
|
+
};
|
|
161
|
+
var shouldForwardProp = (props) => {
|
|
162
|
+
chunk6JFZL7YE_cjs.assertIsArray(props, {
|
|
163
|
+
message: ({ currentType, validType }) => `First parameter (\`props\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
164
|
+
});
|
|
165
|
+
return (propName) => {
|
|
166
|
+
return !props.map((p) => p.toString()).includes(propName.toString());
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
exports.cnV3 = cnV3;
|
|
171
|
+
exports.cnV4 = cnV4;
|
|
172
|
+
exports.customCnV3 = customCnV3;
|
|
173
|
+
exports.customCnV4 = customCnV4;
|
|
174
|
+
exports.shouldForwardProp = shouldForwardProp;
|
|
175
|
+
exports.twMergeDefaultV3 = twMergeDefaultV3;
|
|
176
|
+
exports.twMergeDefaultV4 = twMergeDefaultV4;
|
package/dist/chunk-3IBQ5MOM.js
CHANGED
|
@@ -1 +1,6 @@
|
|
|
1
|
-
import{isNumber
|
|
1
|
+
import { isNumber } from './chunk-CMW2TBOQ.js';
|
|
2
|
+
function isFinite(value) {
|
|
3
|
+
return isNumber(value) && Number.isFinite(value);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export { isFinite };
|
package/dist/chunk-3VA554KW.js
CHANGED
|
@@ -1 +1,23 @@
|
|
|
1
|
-
import{isBigInt
|
|
1
|
+
import { isBigInt } from './chunk-QNKGP5DY.js';
|
|
2
|
+
import { resolveErrorMessageAssertions, hasOwnProp, isNumber } from './chunk-CMW2TBOQ.js';
|
|
3
|
+
var assertIsBigInt = (value, options = {}) => {
|
|
4
|
+
if (isBigInt(value)) return;
|
|
5
|
+
const errorMessage = resolveErrorMessageAssertions({
|
|
6
|
+
value,
|
|
7
|
+
options,
|
|
8
|
+
requiredValidType: "big int"
|
|
9
|
+
});
|
|
10
|
+
throw new TypeError(errorMessage);
|
|
11
|
+
};
|
|
12
|
+
var assertIsNumber = (value, options = {}) => {
|
|
13
|
+
const includeNaN = hasOwnProp(options, "includeNaN") ? options.includeNaN : void 0;
|
|
14
|
+
if (isNumber(value, { includeNaN })) return;
|
|
15
|
+
const errorMessage = resolveErrorMessageAssertions({
|
|
16
|
+
value,
|
|
17
|
+
options,
|
|
18
|
+
requiredValidType: "number"
|
|
19
|
+
});
|
|
20
|
+
throw new TypeError(errorMessage);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { assertIsBigInt, assertIsNumber };
|
package/dist/chunk-5757UBXJ.cjs
CHANGED
|
@@ -1 +1,144 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkDVMHRLKP_cjs = require('./chunk-DVMHRLKP.cjs');
|
|
4
|
+
var chunkT7PU2V7X_cjs = require('./chunk-T7PU2V7X.cjs');
|
|
5
|
+
var chunkPZQ6I4JJ_cjs = require('./chunk-PZQ6I4JJ.cjs');
|
|
6
|
+
function getRandomItem(array) {
|
|
7
|
+
if (!chunkPZQ6I4JJ_cjs.isNonEmptyArray(array)) return void 0;
|
|
8
|
+
const randomIndex = Math.floor(Math.random() * (array.length || 0));
|
|
9
|
+
return array[randomIndex];
|
|
10
|
+
}
|
|
11
|
+
var randomInt = (min, max) => {
|
|
12
|
+
if (!chunkDVMHRLKP_cjs.isInteger(min) || !chunkDVMHRLKP_cjs.isInteger(max)) {
|
|
13
|
+
throw new TypeError(
|
|
14
|
+
`First parameter (\`min\`) and second parameter (\`max\`) must be of type \`integer-number\`${minValueNote(
|
|
15
|
+
min,
|
|
16
|
+
max
|
|
17
|
+
)}value, but received: ['min': \`${chunkPZQ6I4JJ_cjs.getPreciseType(
|
|
18
|
+
min
|
|
19
|
+
)}\` - (with value: \`${chunkT7PU2V7X_cjs.safeStableStringify(min)})\`, 'max': \`${chunkPZQ6I4JJ_cjs.getPreciseType(
|
|
20
|
+
max
|
|
21
|
+
)}\` - (with value: \`${chunkT7PU2V7X_cjs.safeStableStringify(max)}\`)].`
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
if (min > max) {
|
|
25
|
+
throw new RangeError(
|
|
26
|
+
`First parameter (\`min\`) must be less than or equal to second parameter (\`max\`), but received: ['min': ${formatValue(
|
|
27
|
+
min
|
|
28
|
+
)}, 'max': ${formatValue(max)}].`
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
min = Math.max(1, min);
|
|
32
|
+
max = Math.min(Number.MAX_SAFE_INTEGER, max);
|
|
33
|
+
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
34
|
+
};
|
|
35
|
+
var formatValue = (value) => {
|
|
36
|
+
return chunkPZQ6I4JJ_cjs.isNumber(value, { includeNaN: true }) ? value === Number.MIN_VALUE ? "`Number.MIN_VALUE`" : `${value}` : `\`${chunkPZQ6I4JJ_cjs.getPreciseType(value)}\``;
|
|
37
|
+
};
|
|
38
|
+
var minValueNote = (...values) => {
|
|
39
|
+
return values.some((v) => chunkPZQ6I4JJ_cjs.isNumber(v, { includeNaN: true }) && v === Number.MIN_VALUE) ? " and can't be `Number.MIN_VALUE` " : " ";
|
|
40
|
+
};
|
|
41
|
+
var randomIntByLength = (options) => {
|
|
42
|
+
if (!chunkPZQ6I4JJ_cjs.isPlainObject(options)) {
|
|
43
|
+
options = {};
|
|
44
|
+
}
|
|
45
|
+
const { minLength = 1, maxLength = 16, avoidZero = false } = options;
|
|
46
|
+
chunkPZQ6I4JJ_cjs.assertIsBoolean(avoidZero, {
|
|
47
|
+
message({ currentType, validType }) {
|
|
48
|
+
return `Parameters \`avoidZero\` must be of type \`${validType}\`, but received: \`${currentType}\`.`;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
if (!chunkDVMHRLKP_cjs.isInteger(minLength) || !chunkDVMHRLKP_cjs.isInteger(maxLength)) {
|
|
52
|
+
throw new TypeError(
|
|
53
|
+
`Parameters \`minLength\` and \`maxLength\` must be of type \`integer-number\`, but received: ['minLength': \`${chunkPZQ6I4JJ_cjs.getPreciseType(
|
|
54
|
+
minLength
|
|
55
|
+
)}\` - (with value: ${chunkT7PU2V7X_cjs.safeStableStringify(
|
|
56
|
+
minLength
|
|
57
|
+
)}), 'maxLength': \`${chunkPZQ6I4JJ_cjs.getPreciseType(
|
|
58
|
+
maxLength
|
|
59
|
+
)}\` - (with value: ${chunkT7PU2V7X_cjs.safeStableStringify(maxLength)})].`
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
if (minLength < 1 || maxLength > 16 || minLength > maxLength) {
|
|
63
|
+
throw new RangeError(
|
|
64
|
+
`Invalid range at parameters \`minLength\` must be \u2265 1, \`maxLength\` must be \u2264 16, and \`minLength\` \u2264 \`maxLength\`, but received: ['minLength': \`${minLength}\`, 'maxLength': \`${maxLength}\`].`
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
const randomLength = minLength === maxLength ? minLength : randomInt(minLength, maxLength);
|
|
68
|
+
const minValue = 10 ** (randomLength - 1);
|
|
69
|
+
const maxValue = 10 ** randomLength - 1;
|
|
70
|
+
let result = randomInt(minValue, maxValue);
|
|
71
|
+
if (avoidZero && result === 0) {
|
|
72
|
+
result = minValue;
|
|
73
|
+
}
|
|
74
|
+
return result;
|
|
75
|
+
};
|
|
76
|
+
var randomStr = (options) => {
|
|
77
|
+
if (!chunkPZQ6I4JJ_cjs.isPlainObject(options)) {
|
|
78
|
+
options = {};
|
|
79
|
+
}
|
|
80
|
+
const {
|
|
81
|
+
minLength = 40,
|
|
82
|
+
maxLength = 40,
|
|
83
|
+
type = "string",
|
|
84
|
+
avoidWhiteSpace = true
|
|
85
|
+
} = options;
|
|
86
|
+
chunkPZQ6I4JJ_cjs.assertIsBoolean(avoidWhiteSpace, {
|
|
87
|
+
message({ currentType, validType }) {
|
|
88
|
+
return `Parameters \`avoidWhiteSpace\` property of the \`options\` (first-parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
if (!chunkDVMHRLKP_cjs.isInteger(minLength) || !chunkDVMHRLKP_cjs.isInteger(maxLength)) {
|
|
92
|
+
throw new TypeError(
|
|
93
|
+
`Parameters \`minLength\` and \`maxLength\` must be of type \`integer-number\`, but received: ['minLength': \`${chunkPZQ6I4JJ_cjs.getPreciseType(
|
|
94
|
+
minLength
|
|
95
|
+
)}\` - (with value: ${chunkT7PU2V7X_cjs.safeStableStringify(
|
|
96
|
+
minLength
|
|
97
|
+
)}), 'maxLength': \`${chunkPZQ6I4JJ_cjs.getPreciseType(
|
|
98
|
+
maxLength
|
|
99
|
+
)}\` - (with value: ${chunkT7PU2V7X_cjs.safeStableStringify(maxLength)})].`
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
if (minLength < 1 || maxLength > 5e3 || minLength > maxLength) {
|
|
103
|
+
throw new RangeError(
|
|
104
|
+
`Invalid range at parameters \`minLength\` must be \u2265 1, \`maxLength\` must be \u2264 5000, and \`minLength\` \u2264 \`maxLength\`, but received: ['minLength': \`${minLength}\`, 'maxLength': \`${maxLength}\`].`
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
if (type !== "string" && type !== "number") {
|
|
108
|
+
throw new TypeError(
|
|
109
|
+
`Parameter \`type\` must be of type \`string\` with value one of "string" | "number", but received: \`${chunkPZQ6I4JJ_cjs.getPreciseType(
|
|
110
|
+
type
|
|
111
|
+
)}\`, with value: ${chunkT7PU2V7X_cjs.safeStableStringify(type)}.`
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
const length = randomInt(minLength, maxLength);
|
|
115
|
+
const cleanCharacters = (charSet) => {
|
|
116
|
+
return avoidWhiteSpace ? charSet.replace(/\s|\n|\t/g, "") : charSet;
|
|
117
|
+
};
|
|
118
|
+
const defaultNumberSet = "0123456789";
|
|
119
|
+
const defaultStringSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
120
|
+
const baseCharSet = type === "number" ? (!chunkPZQ6I4JJ_cjs.isNaN(Number(options.replaceGenInt)) ? options.replaceGenInt : void 0) ?? defaultNumberSet : (options.replaceGenStr ? options.replaceGenStr : void 0) ?? defaultStringSet;
|
|
121
|
+
const characterSet = cleanCharacters(baseCharSet) + (options.addChar || "");
|
|
122
|
+
if (!characterSet.length) {
|
|
123
|
+
const errCharSet = () => {
|
|
124
|
+
if (type === "number") {
|
|
125
|
+
if (avoidWhiteSpace) {
|
|
126
|
+
return `If \`avoidWhiteSpace\` is true, and \`replaceGenInt\` cant be empty-string value, ensure \`replaceGenInt\` has valid characters and non-nan string number.`;
|
|
127
|
+
}
|
|
128
|
+
return `Ensure \`replaceGenInt\` has valid characters and not a NaN number string while convert to number.`;
|
|
129
|
+
}
|
|
130
|
+
return `Ensure \`replaceGenStr\` has valid characters and non empty string.`;
|
|
131
|
+
};
|
|
132
|
+
throw new Error(`Character set is empty. ${errCharSet()}`);
|
|
133
|
+
}
|
|
134
|
+
let result = "";
|
|
135
|
+
for (let i = 0; i < length; i++) {
|
|
136
|
+
result += characterSet.charAt(Math.floor(Math.random() * characterSet.length));
|
|
137
|
+
}
|
|
138
|
+
return result;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
exports.getRandomItem = getRandomItem;
|
|
142
|
+
exports.randomInt = randomInt;
|
|
143
|
+
exports.randomIntByLength = randomIntByLength;
|
|
144
|
+
exports.randomStr = randomStr;
|
package/dist/chunk-5IGC6PBH.js
CHANGED
|
@@ -1 +1,22 @@
|
|
|
1
|
-
import{isEmptyValue
|
|
1
|
+
import { isEmptyValue } from './chunk-GQR4R5WY.js';
|
|
2
|
+
var isNonEmptyValue = (value, options = {}) => {
|
|
3
|
+
return !isEmptyValue(value, options);
|
|
4
|
+
};
|
|
5
|
+
var typedArrayTags = /* @__PURE__ */ new Set([
|
|
6
|
+
"[object Int8Array]",
|
|
7
|
+
"[object Uint8Array]",
|
|
8
|
+
"[object Uint8ClampedArray]",
|
|
9
|
+
"[object Int16Array]",
|
|
10
|
+
"[object Uint16Array]",
|
|
11
|
+
"[object Int32Array]",
|
|
12
|
+
"[object Uint32Array]",
|
|
13
|
+
"[object Float32Array]",
|
|
14
|
+
"[object Float64Array]",
|
|
15
|
+
"[object BigInt64Array]",
|
|
16
|
+
"[object BigUint64Array]"
|
|
17
|
+
]);
|
|
18
|
+
function isTypedArray(value) {
|
|
19
|
+
return value != null && typeof value === "object" && typedArrayTags.has(Object.prototype.toString.call(value));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { isNonEmptyValue, isTypedArray };
|
package/dist/chunk-5KJFVIQT.cjs
CHANGED
|
@@ -1 +1,55 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkPZQ6I4JJ_cjs = require('./chunk-PZQ6I4JJ.cjs');
|
|
4
|
+
var parseCurrencyString = (input) => {
|
|
5
|
+
if (!chunkPZQ6I4JJ_cjs.isNonEmptyString(input)) return 0;
|
|
6
|
+
let trimmed = input.trim().replace(/\u00A0/g, "").replace(/\u202F/g, "");
|
|
7
|
+
let isNegative = false;
|
|
8
|
+
if (/^\(.*\)$/.test(trimmed)) {
|
|
9
|
+
isNegative = true;
|
|
10
|
+
trimmed = trimmed.slice(1, -1).trim();
|
|
11
|
+
}
|
|
12
|
+
trimmed = trimmed.replace(/^[-\s]+/, (match) => match.includes("-") ? "-" : "").replace(/[\s.,-]+$/, "");
|
|
13
|
+
isNegative = isNegative || /^-/.test(trimmed) || /^[^\d]*-/.test(trimmed);
|
|
14
|
+
const cleaned = trimmed.replace(/[^0-9.,'\s]/g, "");
|
|
15
|
+
let cleanedNoSpace = cleaned.replace(/[\s']/g, "");
|
|
16
|
+
const indianMatches = cleanedNoSpace.match(/,\d{2}/g);
|
|
17
|
+
const isIndianStyle = indianMatches && indianMatches.length > 1;
|
|
18
|
+
if (isIndianStyle) {
|
|
19
|
+
cleanedNoSpace = cleanedNoSpace.replace(/,/g, "");
|
|
20
|
+
} else {
|
|
21
|
+
const dotCount = (cleanedNoSpace.match(/\./g) || []).length;
|
|
22
|
+
const commaCount = (cleanedNoSpace.match(/,/g) || []).length;
|
|
23
|
+
if (dotCount > 1 && commaCount === 0) {
|
|
24
|
+
cleanedNoSpace = cleanedNoSpace.replace(/\./g, "");
|
|
25
|
+
} else if (commaCount > 1 && dotCount === 0) {
|
|
26
|
+
cleanedNoSpace = cleanedNoSpace.replace(/,/g, "");
|
|
27
|
+
} else {
|
|
28
|
+
const lastComma = cleanedNoSpace.lastIndexOf(",");
|
|
29
|
+
const lastDot = cleanedNoSpace.lastIndexOf(".");
|
|
30
|
+
if (lastComma > lastDot) {
|
|
31
|
+
cleanedNoSpace = cleanedNoSpace.replace(/\./g, "").replace(",", ".");
|
|
32
|
+
} else if (lastDot > lastComma) {
|
|
33
|
+
cleanedNoSpace = cleanedNoSpace.replace(/,/g, "");
|
|
34
|
+
} else {
|
|
35
|
+
if (lastComma > lastDot) {
|
|
36
|
+
const beforeDecimal = cleanedNoSpace.slice(0, lastComma).replace(/,/g, "").replace(/\./g, "");
|
|
37
|
+
const afterDecimal = cleanedNoSpace.slice(lastComma + 1);
|
|
38
|
+
cleanedNoSpace = beforeDecimal + "." + afterDecimal;
|
|
39
|
+
} else if (lastDot > lastComma) {
|
|
40
|
+
const beforeDecimal = cleanedNoSpace.slice(0, lastDot).replace(/\./g, "").replace(/,/g, "");
|
|
41
|
+
const afterDecimal = cleanedNoSpace.slice(lastDot + 1);
|
|
42
|
+
cleanedNoSpace = beforeDecimal + "." + afterDecimal;
|
|
43
|
+
} else if (lastComma !== -1) {
|
|
44
|
+
cleanedNoSpace = cleanedNoSpace.replace(/,/g, "");
|
|
45
|
+
} else if (lastDot !== -1) {
|
|
46
|
+
cleanedNoSpace = cleanedNoSpace.replace(/\./g, "");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const num = parseFloat(cleanedNoSpace) || 0;
|
|
52
|
+
return isNegative ? -num : num;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
exports.parseCurrencyString = parseCurrencyString;
|
package/dist/chunk-6JFCSH7J.js
CHANGED
|
@@ -1 +1,24 @@
|
|
|
1
|
-
import{isArray
|
|
1
|
+
import { isArray, isObject, assertIsPlainObject, hasOwnProp, assertIsBoolean } from './chunk-CMW2TBOQ.js';
|
|
2
|
+
var isEmptyArray = (value) => {
|
|
3
|
+
if (!isArray(value)) return true;
|
|
4
|
+
return value.length === 0;
|
|
5
|
+
};
|
|
6
|
+
function isEmptyObject(value, options = {}) {
|
|
7
|
+
if (!isObject(value)) {
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
assertIsPlainObject(options, {
|
|
11
|
+
message: ({ currentType, validType }) => `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
12
|
+
});
|
|
13
|
+
const checkSymbols = hasOwnProp(options, "checkSymbols") ? options.checkSymbols : false;
|
|
14
|
+
assertIsBoolean(checkSymbols, {
|
|
15
|
+
message: ({ currentType, validType }) => `Parameter \`checkSymbols\` property of the \`options\` (second parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
16
|
+
});
|
|
17
|
+
const hasNoKeys = Object.keys(value).length === 0;
|
|
18
|
+
if (checkSymbols) {
|
|
19
|
+
return hasNoKeys && Object.getOwnPropertySymbols(value).length === 0;
|
|
20
|
+
}
|
|
21
|
+
return hasNoKeys;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { isEmptyArray, isEmptyObject };
|
package/dist/chunk-6JFZL7YE.cjs
CHANGED
|
@@ -1 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkPZQ6I4JJ_cjs = require('./chunk-PZQ6I4JJ.cjs');
|
|
4
|
+
function assertIsArray(value, options) {
|
|
5
|
+
if (chunkPZQ6I4JJ_cjs.isArray(value)) return;
|
|
6
|
+
const errorMessage = chunkPZQ6I4JJ_cjs.resolveErrorMessageAssertions({
|
|
7
|
+
value,
|
|
8
|
+
options,
|
|
9
|
+
requiredValidType: "array"
|
|
10
|
+
});
|
|
11
|
+
throw new TypeError(errorMessage);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
exports.assertIsArray = assertIsArray;
|