@rzl-zone/utils-js 3.7.1 → 3.9.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 +28 -1
- package/dist/assertions/index.cjs +11 -11
- package/dist/assertions/index.d.ts +169 -58
- package/dist/assertions/index.js +5 -5
- package/dist/{chunk-EK7FSI7F.cjs → chunk-2XGQQZ6A.cjs} +3 -3
- package/dist/{chunk-YS27V6LS.js → chunk-3LE6NX57.js} +5 -176
- package/dist/{chunk-PZQC3FZY.js → chunk-44X74C26.js} +4 -4
- package/dist/{chunk-4ACKNPL5.js → chunk-5KDVIEVO.js} +2 -2
- package/dist/{chunk-JY4HLZ4W.js → chunk-5O66AUEC.js} +2 -2
- package/dist/chunk-5Y6JL47L.js +302 -0
- package/dist/{chunk-KIYALQQF.cjs → chunk-62FS7WMB.cjs} +35 -35
- package/dist/{chunk-VJVCXEH7.cjs → chunk-6AMDHVS2.cjs} +9 -181
- package/dist/{chunk-6PKW4WCT.js → chunk-6WVOUVWD.js} +27 -15
- package/dist/{chunk-BYUT376O.cjs → chunk-76ATVDCR.cjs} +3 -3
- package/dist/{chunk-F3WBQKRI.cjs → chunk-7C7TQC5J.cjs} +29 -7
- package/dist/{chunk-QUITZ3GP.js → chunk-7EIFPHV3.js} +32 -16
- package/dist/{chunk-6RFNZ2ZZ.cjs → chunk-7NXFGJJE.cjs} +14 -14
- package/dist/{chunk-TFDXRT6D.cjs → chunk-ALRISPTL.cjs} +3 -3
- package/dist/chunk-BAV5T2E3.cjs +1 -1
- package/dist/{chunk-4ZOXSUXB.js → chunk-C7GC2PFX.js} +3 -3
- package/dist/chunk-DVMHRLKP.cjs +1 -1
- package/dist/{chunk-XFTUHS4Y.js → chunk-DXPM4NOU.js} +10 -8
- package/dist/{chunk-DPLL67OT.js → chunk-EJV5AF4L.js} +2 -2
- package/dist/{chunk-NREACG6M.cjs → chunk-FWWPEL7J.cjs} +3 -3
- package/dist/{chunk-LEX4TQW2.js → chunk-GHU356XQ.js} +4 -6
- package/dist/chunk-GKDSBOYE.js +209 -0
- package/dist/{chunk-YC7AK3KX.cjs → chunk-H44QVAZL.cjs} +31 -31
- package/dist/{chunk-AKKM6MOX.cjs → chunk-I33PB44Q.cjs} +15 -15
- package/dist/{chunk-LIU4S3JA.cjs → chunk-IX6PF5ZP.cjs} +4 -4
- package/dist/{chunk-3KTD3QDI.js → chunk-J4TT33ZX.js} +29 -7
- package/dist/{chunk-SZJ7OI4S.js → chunk-J6VLFVIL.js} +3 -3
- package/dist/{chunk-KTQLDIIT.cjs → chunk-JI57K7D4.cjs} +173 -163
- package/dist/{chunk-OFBFGFVH.js → chunk-JYOCB6OV.js} +2 -2
- package/dist/chunk-KHO2SBNA.cjs +1 -1
- package/dist/{chunk-66WLOZOD.cjs → chunk-KUVRZ2JW.cjs} +53 -51
- package/dist/chunk-L5RDAVVH.js +1 -1
- package/dist/{chunk-VCVND6CH.js → chunk-M5QB2GM5.js} +2 -2
- package/dist/{chunk-3LEWQV3R.js → chunk-MBFVTGYS.js} +8 -8
- package/dist/{chunk-UKAUXY2U.cjs → chunk-MMRHKYT6.cjs} +12 -12
- package/dist/{chunk-U5VR4TJN.js → chunk-MS2KSKD7.js} +9 -9
- package/dist/{chunk-7ZNEUWYP.js → chunk-MZ3T6L7Z.js} +2 -2
- package/dist/{chunk-ATLFMKAF.cjs → chunk-NAOVH4OH.cjs} +7 -7
- package/dist/chunk-NJ24M6ZH.cjs +308 -0
- package/dist/chunk-OCTHWEZK.cjs +249 -0
- package/dist/chunk-ONZFBJVW.js +1 -1
- package/dist/{chunk-FI76UZRF.js → chunk-OSSFLQDD.js} +3 -4
- package/dist/{chunk-7WBMA2VE.cjs → chunk-OYFUBKEG.cjs} +4 -5
- package/dist/{chunk-B4SDEBN7.cjs → chunk-PWKOFPAH.cjs} +3 -3
- package/dist/{chunk-2CQI36UD.cjs → chunk-QGTFQ7RO.cjs} +8 -6
- package/dist/chunk-QNKGP5DY.js +1 -1
- package/dist/chunk-QXTJVDWE.js +676 -0
- package/dist/{chunk-B6UIKBHR.cjs → chunk-QZI5PVCI.cjs} +4 -4
- package/dist/{chunk-WNO3EPYT.js → chunk-R2DR7SPJ.js} +102 -26
- package/dist/{chunk-TDYGYHSH.js → chunk-SN5HAK3Y.js} +4 -4
- package/dist/{chunk-D53CE4BT.js → chunk-SRWL4YCP.js} +11 -8
- package/dist/{chunk-7QQV66RX.cjs → chunk-TJ5OY6MC.cjs} +10 -10
- package/dist/{chunk-6WMB5AJR.js → chunk-TXOVQZPU.js} +3 -4
- package/dist/chunk-UDA26MCU.cjs +1 -1
- package/dist/{chunk-R3PBF6F7.cjs → chunk-UFYMRRJH.cjs} +73 -61
- package/dist/{chunk-5NN4ZDE2.cjs → chunk-UV5BKAYW.cjs} +6 -8
- package/dist/{chunk-GAJBF6DR.js → chunk-UXT4XSUK.js} +2 -2
- package/dist/{chunk-TDPYR5JY.js → chunk-VBSLIIDB.js} +24 -14
- package/dist/chunk-VCYXNIZ2.cjs +678 -0
- package/dist/chunk-VJDDGRIK.cjs +1 -1
- package/dist/{chunk-VNADVWSJ.js → chunk-WB3FT62A.js} +6 -4
- package/dist/{chunk-K63WO3XA.cjs → chunk-WKM6UVMG.cjs} +4 -5
- package/dist/{chunk-OS5OT5JA.cjs → chunk-WLEZ2KSG.cjs} +142 -126
- package/dist/{chunk-ZN53RM3R.js → chunk-WRGN6UBK.js} +2 -2
- package/dist/chunk-WVSPXFTY.js +1 -1
- package/dist/{chunk-2VO2CBTU.js → chunk-X6ULJZ3X.js} +2 -2
- package/dist/{chunk-CKUEZF4R.cjs → chunk-XYWC4EQ3.cjs} +71 -71
- package/dist/{chunk-A3YI6Y2P.js → chunk-YHFRCVTN.js} +3 -3
- package/dist/{chunk-RMJC3B5P.cjs → chunk-YQHJB7KR.cjs} +30 -27
- package/dist/{chunk-YGB2BQPB.cjs → chunk-YVRUY4EW.cjs} +8 -8
- package/dist/chunk-YWHHVDT4.js +1 -1
- package/dist/chunk-ZTHJQJ5F.cjs +211 -0
- package/dist/conversions/index.cjs +34 -34
- package/dist/conversions/index.d.ts +10 -12
- package/dist/conversions/index.js +15 -15
- package/dist/events/index.cjs +8 -8
- package/dist/events/index.d.ts +9 -9
- package/dist/events/index.js +4 -4
- package/dist/formatters/index.cjs +19 -19
- package/dist/formatters/index.d.ts +19 -24
- package/dist/formatters/index.js +9 -9
- package/dist/generators/index.cjs +12 -8
- package/dist/generators/index.d.ts +155 -26
- package/dist/generators/index.js +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/{isPlainObject-FWmcJF6k.d.ts → isPlainObject-BTPjv6zB.d.ts} +2 -2
- package/dist/next/index.cjs +39 -36
- package/dist/next/index.d.ts +11 -11
- package/dist/next/index.js +12 -9
- package/dist/next/server/index.cjs +4 -4
- package/dist/next/server/index.d.ts +4 -4
- package/dist/next/server/index.js +2 -2
- package/dist/operations/index.cjs +11 -11
- package/dist/operations/index.d.ts +8 -9
- package/dist/operations/index.js +8 -8
- package/dist/parsers/index.cjs +6 -4
- package/dist/parsers/index.d.ts +224 -32
- package/dist/parsers/index.js +5 -3
- package/dist/predicates/index.cjs +77 -76
- package/dist/predicates/index.d.ts +15 -28
- package/dist/predicates/index.js +14 -13
- package/dist/promises/index.cjs +6 -6
- package/dist/promises/index.d.ts +5 -7
- package/dist/promises/index.js +4 -4
- package/dist/rzl-utils.global.js +2 -2
- package/dist/strings/index.cjs +23 -23
- package/dist/strings/index.d.ts +1 -1
- package/dist/strings/index.js +7 -7
- package/dist/tailwind/index.cjs +13 -13
- package/dist/tailwind/index.d.ts +18 -18
- package/dist/tailwind/index.js +5 -5
- package/dist/urls/index.cjs +23 -21
- package/dist/urls/index.d.ts +188 -121
- package/dist/urls/index.js +16 -14
- package/package.json +1 -1
- package/dist/chunk-ABA2ZSBQ.js +0 -152
- package/dist/chunk-BG3AS5BU.cjs +0 -173
- package/dist/chunk-K3SONK25.cjs +0 -157
- package/dist/chunk-KPCDDYTZ.js +0 -417
- package/dist/chunk-QAPYHLHC.cjs +0 -419
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.9.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
9
9
|
*/
|
|
10
|
-
import { normalizeSpaces } from './chunk-
|
|
11
|
-
import { parseCurrencyString } from './chunk-
|
|
12
|
-
import { isFinite } from './chunk-
|
|
10
|
+
import { normalizeSpaces } from './chunk-JYOCB6OV.js';
|
|
11
|
+
import { parseCurrencyString } from './chunk-EJV5AF4L.js';
|
|
12
|
+
import { isFinite } from './chunk-MZ3T6L7Z.js';
|
|
13
13
|
import { isInteger } from './chunk-WVSPXFTY.js';
|
|
14
|
-
import { isEmptyString } from './chunk-
|
|
15
|
-
import { assertIsString } from './chunk-
|
|
16
|
-
import { safeStableStringify, isDate } from './chunk-
|
|
17
|
-
import { isString, getPreciseType, assertIsPlainObject, hasOwnProp, isBoolean, isPlainObject, isNaN, isUndefined, isFunction, assertIsBoolean, isNil, isNumber, isNonEmptyString } from './chunk-
|
|
14
|
+
import { isEmptyString } from './chunk-5O66AUEC.js';
|
|
15
|
+
import { assertIsString } from './chunk-OSSFLQDD.js';
|
|
16
|
+
import { safeStableStringify, isDate } from './chunk-X6ULJZ3X.js';
|
|
17
|
+
import { isString, getPreciseType, assertIsPlainObject, hasOwnProp, isBoolean, isPlainObject, isNaN, isUndefined, isFunction, assertIsBoolean, isNil, isNumber, isNonEmptyString } from './chunk-J4TT33ZX.js';
|
|
18
18
|
import { isSupportedCountry, AsYouType } from 'libphonenumber-js/max';
|
|
19
19
|
import { id, enUS } from 'date-fns/locale';
|
|
20
20
|
import { parse, format } from 'date-fns';
|
|
@@ -30,7 +30,9 @@ var formatCurrency = (value, options = {}) => {
|
|
|
30
30
|
throw new TypeError(
|
|
31
31
|
`First parameter (\`value\`) must be of type \`string\` or \`primitive-number\`, but received: \`${getPreciseType(
|
|
32
32
|
value
|
|
33
|
-
)}\`, with value: \`${safeStableStringify(value
|
|
33
|
+
)}\`, with value: \`${safeStableStringify(value, {
|
|
34
|
+
keepUndefined: true
|
|
35
|
+
})}\`.`
|
|
34
36
|
);
|
|
35
37
|
}
|
|
36
38
|
assertIsPlainObject(options, {
|
|
@@ -70,21 +72,27 @@ var formatCurrency = (value, options = {}) => {
|
|
|
70
72
|
throw new TypeError(
|
|
71
73
|
`Parameter \`totalDecimal\` property of the \`options\` (second parameter) must be of type \`integer-number\`, but received: \`${getPreciseType(
|
|
72
74
|
totalDecimal
|
|
73
|
-
)}\`, with value: \`${safeStableStringify(length
|
|
75
|
+
)}\`, with value: \`${safeStableStringify(length, {
|
|
76
|
+
keepUndefined: true
|
|
77
|
+
})}\`.`
|
|
74
78
|
);
|
|
75
79
|
}
|
|
76
80
|
if (!(roundedDecimal === false || roundedDecimal === "round" || roundedDecimal === "ceil" || roundedDecimal === "floor")) {
|
|
77
81
|
throw new TypeError(
|
|
78
82
|
`Parameter \`roundedDecimal\` property of the \`options\` (second parameter) must be of type \`false\` or \`string\` must be one of "round" | "ceil" | "floor", but received: \`${getPreciseType(
|
|
79
83
|
roundedDecimal
|
|
80
|
-
)}\`, with value: \`${safeStableStringify(roundedDecimal
|
|
84
|
+
)}\`, with value: \`${safeStableStringify(roundedDecimal, {
|
|
85
|
+
keepUndefined: true
|
|
86
|
+
})}\`.`
|
|
81
87
|
);
|
|
82
88
|
}
|
|
83
89
|
if (!(negativeFormat === "abs" || negativeFormat === "brackets" || negativeFormat === "dash" || isPlainObject(negativeFormat))) {
|
|
84
90
|
throw new TypeError(
|
|
85
91
|
`Parameter \`negativeFormat\` property of the \`options\` (second parameter) must be of type \`string\` must be one of "abs" | "brackets" | "dash" or \`plain-object\` type, but received: \`${getPreciseType(
|
|
86
92
|
negativeFormat
|
|
87
|
-
)}\`, with value: \`${safeStableStringify(negativeFormat
|
|
93
|
+
)}\`, with value: \`${safeStableStringify(negativeFormat, {
|
|
94
|
+
keepUndefined: true
|
|
95
|
+
})}\`.`
|
|
88
96
|
);
|
|
89
97
|
}
|
|
90
98
|
const rawNum = isString(value) ? parseCurrencyString(value) : value;
|
|
@@ -162,7 +170,9 @@ var formatCurrency = (value, options = {}) => {
|
|
|
162
170
|
throw new TypeError(
|
|
163
171
|
`Parameter \`negativeFormat.style\` property of the \`options\` (second parameter) must be of type \`string\` must be of type "abs" | "brackets" | "dash", but received: \`${getPreciseType(
|
|
164
172
|
formatStyleNegative
|
|
165
|
-
)}\`, with value: \`${safeStableStringify(formatStyleNegative
|
|
173
|
+
)}\`, with value: \`${safeStableStringify(formatStyleNegative, {
|
|
174
|
+
keepUndefined: true
|
|
175
|
+
})}\`.`
|
|
166
176
|
);
|
|
167
177
|
}
|
|
168
178
|
switch (formatStyleNegative) {
|
|
@@ -355,7 +365,9 @@ var censorEmail = (email, options = {}) => {
|
|
|
355
365
|
throw new TypeError(
|
|
356
366
|
`Parameter \`mode\` property of the \`options\` (second parameter) must be one of "fixed" or "random", but received: \`${getPreciseType(
|
|
357
367
|
mode
|
|
358
|
-
)}\`, with value: \`${safeStableStringify(mode
|
|
368
|
+
)}\`, with value: \`${safeStableStringify(mode, {
|
|
369
|
+
keepUndefined: true
|
|
370
|
+
})}\`.`
|
|
359
371
|
);
|
|
360
372
|
}
|
|
361
373
|
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
|
@@ -383,7 +395,9 @@ function chunkString(subject, limiter, options = {}) {
|
|
|
383
395
|
throw new TypeError(
|
|
384
396
|
`Second parameter (\`limiter\`) must be of type \`integer-number\`, but received: \`${getPreciseType(
|
|
385
397
|
limiter
|
|
386
|
-
)}\`, with value: \`${safeStableStringify(limiter
|
|
398
|
+
)}\`, with value: \`${safeStableStringify(limiter, {
|
|
399
|
+
keepUndefined: true
|
|
400
|
+
})}\`.`
|
|
387
401
|
);
|
|
388
402
|
}
|
|
389
403
|
assertIsPlainObject(options, {
|
|
@@ -451,7 +465,9 @@ var truncateString = (text, options = {}) => {
|
|
|
451
465
|
throw new TypeError(
|
|
452
466
|
`Parameter \`length\` property of the \`options\` (second parameter) must be of type \`integer-number\`, but received: \`${getPreciseType(
|
|
453
467
|
length2
|
|
454
|
-
)}\`, with value: \`${safeStableStringify(length2
|
|
468
|
+
)}\`, with value: \`${safeStableStringify(length2, {
|
|
469
|
+
keepUndefined: true
|
|
470
|
+
})}\`.`
|
|
455
471
|
);
|
|
456
472
|
}
|
|
457
473
|
if (length2 < 1) return "";
|
|
@@ -2,22 +2,22 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.9.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
9
9
|
*/
|
|
10
10
|
'use strict';
|
|
11
11
|
|
|
12
|
-
var
|
|
13
|
-
var
|
|
12
|
+
var chunkFWWPEL7J_cjs = require('./chunk-FWWPEL7J.cjs');
|
|
13
|
+
var chunk7C7TQC5J_cjs = require('./chunk-7C7TQC5J.cjs');
|
|
14
14
|
|
|
15
15
|
var capitalizeFirst = (string, options = {
|
|
16
16
|
lowerCaseNextRest: true,
|
|
17
17
|
trim: false
|
|
18
18
|
}) => {
|
|
19
|
-
if (!
|
|
20
|
-
if (!
|
|
19
|
+
if (!chunk7C7TQC5J_cjs.isNonEmptyString(string)) return "";
|
|
20
|
+
if (!chunk7C7TQC5J_cjs.isPlainObject(options)) {
|
|
21
21
|
options = {};
|
|
22
22
|
}
|
|
23
23
|
const lowerCaseNextRest = options.lowerCaseNextRest !== false;
|
|
@@ -30,9 +30,9 @@ var capitalizeWords = (value, options = {
|
|
|
30
30
|
collapseSpaces: false,
|
|
31
31
|
trim: false
|
|
32
32
|
}) => {
|
|
33
|
-
if (!
|
|
33
|
+
if (!chunk7C7TQC5J_cjs.isNonEmptyString(value)) return "";
|
|
34
34
|
let result = value;
|
|
35
|
-
if (!
|
|
35
|
+
if (!chunk7C7TQC5J_cjs.isPlainObject(options)) {
|
|
36
36
|
options = {};
|
|
37
37
|
}
|
|
38
38
|
const collapseSpaces = options.collapseSpaces === true;
|
|
@@ -50,10 +50,10 @@ var capitalizeWords = (value, options = {
|
|
|
50
50
|
};
|
|
51
51
|
|
|
52
52
|
function stripHtmlTags(input) {
|
|
53
|
-
if (!
|
|
53
|
+
if (!chunk7C7TQC5J_cjs.isString(input)) {
|
|
54
54
|
return void 0;
|
|
55
55
|
}
|
|
56
|
-
if (
|
|
56
|
+
if (chunkFWWPEL7J_cjs.isEmptyString(input)) {
|
|
57
57
|
return "";
|
|
58
58
|
}
|
|
59
59
|
const stripped = input.replace(/<\/?[a-zA-Z][^<>]*\/?>/g, " ").trim();
|
|
@@ -62,7 +62,7 @@ function stripHtmlTags(input) {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
var getInitialsName = (name) => {
|
|
65
|
-
if (!
|
|
65
|
+
if (!chunk7C7TQC5J_cjs.isNonEmptyString(name)) return "";
|
|
66
66
|
name = name.replace(/\s+/g, " ").trim();
|
|
67
67
|
const nameParts = name.split(" ");
|
|
68
68
|
if (nameParts.length > 1) {
|
|
@@ -75,13 +75,13 @@ var getInitialsName = (name) => {
|
|
|
75
75
|
};
|
|
76
76
|
|
|
77
77
|
var replaceAt = (index, originalString, replaceTo) => {
|
|
78
|
-
if (!
|
|
78
|
+
if (!chunk7C7TQC5J_cjs.isNumber(index) || !chunk7C7TQC5J_cjs.isString(replaceTo) || !chunk7C7TQC5J_cjs.isString(originalString)) {
|
|
79
79
|
throw new TypeError(
|
|
80
|
-
`First parameter (\`index\`) must be of type \`number\`, second parameter (\`originalString\`) and third parameter (\`replaceTo\`) must be of type \`string\`, but received: "['index': \`${
|
|
80
|
+
`First parameter (\`index\`) must be of type \`number\`, second parameter (\`originalString\`) and third parameter (\`replaceTo\`) must be of type \`string\`, but received: "['index': \`${chunk7C7TQC5J_cjs.getPreciseType(
|
|
81
81
|
index
|
|
82
|
-
)}\`, 'originalString': \`${
|
|
82
|
+
)}\`, 'originalString': \`${chunk7C7TQC5J_cjs.getPreciseType(
|
|
83
83
|
originalString
|
|
84
|
-
)}\`, 'replaceTo': \`${
|
|
84
|
+
)}\`, 'replaceTo': \`${chunk7C7TQC5J_cjs.getPreciseType(replaceTo)}\`]".`
|
|
85
85
|
);
|
|
86
86
|
}
|
|
87
87
|
if (index < 0 || index >= originalString.length) {
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.9.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
9
9
|
*/
|
|
10
10
|
'use strict';
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var chunkMMRHKYT6_cjs = require('./chunk-MMRHKYT6.cjs');
|
|
13
13
|
|
|
14
14
|
var isNonEmptyValue = (value, options = {}) => {
|
|
15
|
-
return !
|
|
15
|
+
return !chunkMMRHKYT6_cjs.isEmptyValue(value, options);
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
var typedArrayTags = /* @__PURE__ */ new Set([
|
package/dist/chunk-BAV5T2E3.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.9.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.9.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
9
9
|
*/
|
|
10
10
|
import { isServer } from './chunk-L5RDAVVH.js';
|
|
11
|
-
import { assertIsString } from './chunk-
|
|
12
|
-
import { isPlainObject, hasOwnProp, isNonEmptyString, isNumber } from './chunk-
|
|
11
|
+
import { assertIsString } from './chunk-OSSFLQDD.js';
|
|
12
|
+
import { isPlainObject, hasOwnProp, isNonEmptyString, isNumber } from './chunk-J4TT33ZX.js';
|
|
13
13
|
|
|
14
14
|
var disableUserInteraction = (className = "on_processing") => {
|
|
15
15
|
if (isServer()) return;
|
package/dist/chunk-DVMHRLKP.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.9.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
@@ -2,26 +2,28 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.9.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
9
9
|
*/
|
|
10
|
-
import { isEmptyArray, isEmptyObject } from './chunk-
|
|
10
|
+
import { isEmptyArray, isEmptyObject } from './chunk-M5QB2GM5.js';
|
|
11
11
|
import { noop } from './chunk-YWHHVDT4.js';
|
|
12
|
-
import { safeStableStringify } from './chunk-
|
|
13
|
-
import { isNonEmptyString, getPreciseType, isNull, isUndefined, isString, isArray, isObject, isNumber, isNaN as isNaN$1, isError, assertIsPlainObject, hasOwnProp, isBoolean, isFunction } from './chunk-
|
|
12
|
+
import { safeStableStringify } from './chunk-X6ULJZ3X.js';
|
|
13
|
+
import { isNonEmptyString, getPreciseType, isNull, isUndefined, isString, isArray, isObject, isNumber, isNaN as isNaN$1, isError, assertIsPlainObject, hasOwnProp, isBoolean, isFunction } from './chunk-J4TT33ZX.js';
|
|
14
14
|
|
|
15
15
|
var parseCustomDate = (dateString, format) => {
|
|
16
16
|
if (!isNonEmptyString(dateString) || !isNonEmptyString(format)) {
|
|
17
17
|
throw new TypeError(
|
|
18
18
|
`Parameter \`dateString\` and \`format\` must be of type \`string\` and not empty-string, but received: "['dateString': \`${getPreciseType(
|
|
19
19
|
dateString
|
|
20
|
-
)}\` - (current value: \`${safeStableStringify(
|
|
21
|
-
|
|
22
|
-
)}\`), 'format': \`${getPreciseType(
|
|
20
|
+
)}\` - (current value: \`${safeStableStringify(dateString, {
|
|
21
|
+
keepUndefined: true
|
|
22
|
+
})}\`), 'format': \`${getPreciseType(
|
|
23
23
|
format
|
|
24
|
-
)}\` - (current value: \`${safeStableStringify(format
|
|
24
|
+
)}\` - (current value: \`${safeStableStringify(format, {
|
|
25
|
+
keepUndefined: true
|
|
26
|
+
})}\`)]".`
|
|
25
27
|
);
|
|
26
28
|
}
|
|
27
29
|
const dateParts = dateString.split(/[-/]/).map(Number);
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.9.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
9
9
|
*/
|
|
10
|
-
import { isNonEmptyString } from './chunk-
|
|
10
|
+
import { isNonEmptyString } from './chunk-J4TT33ZX.js';
|
|
11
11
|
|
|
12
12
|
var parseCurrencyString = (input) => {
|
|
13
13
|
if (!isNonEmptyString(input)) return 0;
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.9.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
9
9
|
*/
|
|
10
10
|
'use strict';
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var chunk7C7TQC5J_cjs = require('./chunk-7C7TQC5J.cjs');
|
|
13
13
|
|
|
14
14
|
var isEmptyString = (value, options = {}) => {
|
|
15
|
-
return !
|
|
15
|
+
return !chunk7C7TQC5J_cjs.isNonEmptyString(value, options);
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
exports.isEmptyString = isEmptyString;
|
|
@@ -2,33 +2,31 @@
|
|
|
2
2
|
* ====================================================
|
|
3
3
|
* Rzl Utils-JS.
|
|
4
4
|
* ----------------------------------------------------
|
|
5
|
-
* Version: 3.
|
|
5
|
+
* Version: 3.9.0.
|
|
6
6
|
* Author: Rizalvin Dwiky.
|
|
7
7
|
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
8
|
* ====================================================
|
|
9
9
|
*/
|
|
10
10
|
import { isBigInt } from './chunk-QNKGP5DY.js';
|
|
11
|
-
import { resolveErrorMessageAssertions, hasOwnProp, isNumber } from './chunk-
|
|
11
|
+
import { resolveErrorMessageAssertions, hasOwnProp, isNumber } from './chunk-J4TT33ZX.js';
|
|
12
12
|
|
|
13
13
|
var assertIsBigInt = (value, options = {}) => {
|
|
14
14
|
if (isBigInt(value)) return;
|
|
15
|
-
|
|
15
|
+
resolveErrorMessageAssertions({
|
|
16
16
|
value,
|
|
17
17
|
options,
|
|
18
18
|
requiredValidType: "big int"
|
|
19
19
|
});
|
|
20
|
-
throw new TypeError(errorMessage);
|
|
21
20
|
};
|
|
22
21
|
|
|
23
22
|
var assertIsNumber = (value, options = {}) => {
|
|
24
23
|
const includeNaN = hasOwnProp(options, "includeNaN") ? options.includeNaN : void 0;
|
|
25
24
|
if (isNumber(value, { includeNaN })) return;
|
|
26
|
-
|
|
25
|
+
resolveErrorMessageAssertions({
|
|
27
26
|
value,
|
|
28
27
|
options,
|
|
29
28
|
requiredValidType: "number"
|
|
30
29
|
});
|
|
31
|
-
throw new TypeError(errorMessage);
|
|
32
30
|
};
|
|
33
31
|
|
|
34
32
|
export { assertIsBigInt, assertIsNumber };
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* ====================================================
|
|
3
|
+
* Rzl Utils-JS.
|
|
4
|
+
* ----------------------------------------------------
|
|
5
|
+
* Version: 3.9.0.
|
|
6
|
+
* Author: Rizalvin Dwiky.
|
|
7
|
+
* Repository: https://github.com/rzl-zone/utils-js.
|
|
8
|
+
* ====================================================
|
|
9
|
+
*/
|
|
10
|
+
import { assertIsString } from './chunk-OSSFLQDD.js';
|
|
11
|
+
import { getPreciseType } from './chunk-J4TT33ZX.js';
|
|
12
|
+
|
|
13
|
+
var maxInt = 2147483647;
|
|
14
|
+
var base = 36;
|
|
15
|
+
var tMin = 1;
|
|
16
|
+
var tMax = 26;
|
|
17
|
+
var skew = 38;
|
|
18
|
+
var damp = 700;
|
|
19
|
+
var initialBias = 72;
|
|
20
|
+
var initialN = 128;
|
|
21
|
+
var delimiter = "-";
|
|
22
|
+
var regexPunycode = /^xn--/;
|
|
23
|
+
var regexNonASCII = /[^\0-\x7F]/;
|
|
24
|
+
var regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g;
|
|
25
|
+
var errors = {
|
|
26
|
+
overflow: "Overflow: input needs wider integers to process",
|
|
27
|
+
"not-basic": "Illegal input >= 0x80 (not a basic code point)",
|
|
28
|
+
"invalid-input": "Invalid input"
|
|
29
|
+
};
|
|
30
|
+
var floor = Math.floor;
|
|
31
|
+
var stringFromCharCode = String.fromCharCode;
|
|
32
|
+
function error(type) {
|
|
33
|
+
throw new RangeError(errors[type]);
|
|
34
|
+
}
|
|
35
|
+
function map(array, fn) {
|
|
36
|
+
const result = [];
|
|
37
|
+
let length = array.length;
|
|
38
|
+
while (length--) result[length] = fn(array[length]);
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
function mapDomain(domain, fn) {
|
|
42
|
+
const parts = domain.split("@");
|
|
43
|
+
let result = "";
|
|
44
|
+
if (parts.length > 1) {
|
|
45
|
+
result = parts[0] + "@";
|
|
46
|
+
domain = parts[1];
|
|
47
|
+
}
|
|
48
|
+
domain = domain.replace(regexSeparators, ".");
|
|
49
|
+
const labels = domain.split(".");
|
|
50
|
+
return result + map(labels, fn).join(".");
|
|
51
|
+
}
|
|
52
|
+
function ucs2decode(input) {
|
|
53
|
+
assertIsString(input, {
|
|
54
|
+
message: ({ currentType, validType }) => `Utils \`punycodeUtilsJS.ucs2.decode\`, parameter \`input\` must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
55
|
+
});
|
|
56
|
+
const output = [];
|
|
57
|
+
let counter = 0;
|
|
58
|
+
const length = input.length;
|
|
59
|
+
while (counter < length) {
|
|
60
|
+
const value = input.charCodeAt(counter++);
|
|
61
|
+
if (value >= 55296 && value <= 56319 && counter < length) {
|
|
62
|
+
const extra = input.charCodeAt(counter++);
|
|
63
|
+
if ((extra & 64512) === 56320)
|
|
64
|
+
output.push(((value & 1023) << 10) + (extra & 1023) + 65536);
|
|
65
|
+
else {
|
|
66
|
+
output.push(value);
|
|
67
|
+
counter--;
|
|
68
|
+
}
|
|
69
|
+
} else output.push(value);
|
|
70
|
+
}
|
|
71
|
+
return output;
|
|
72
|
+
}
|
|
73
|
+
var ucs2encode = (points) => {
|
|
74
|
+
if (!Array.isArray(points) || !points.every((p) => typeof p === "number" && Number.isFinite(p))) {
|
|
75
|
+
throw new TypeError(
|
|
76
|
+
`Utils \`punycodeUtilsJS.ucs2.encode\`, parameter \`points\` must be an array of numbers, but received: \`${getPreciseType(
|
|
77
|
+
points
|
|
78
|
+
)}\`.`
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
return String.fromCodePoint(...points);
|
|
82
|
+
};
|
|
83
|
+
function basicToDigit(codePoint) {
|
|
84
|
+
if (codePoint >= 48 && codePoint < 58) return 26 + (codePoint - 48);
|
|
85
|
+
if (codePoint >= 65 && codePoint < 91) return codePoint - 65;
|
|
86
|
+
if (codePoint >= 97 && codePoint < 123) return codePoint - 97;
|
|
87
|
+
return base;
|
|
88
|
+
}
|
|
89
|
+
function digitToBasic(digit, flag) {
|
|
90
|
+
return digit + 22 + 75 * (digit < 26 ? 1 : 0) - Number(flag !== 0) * 32;
|
|
91
|
+
}
|
|
92
|
+
function adapt(delta, numPoints, firstTime) {
|
|
93
|
+
let k = 0;
|
|
94
|
+
delta = firstTime ? floor(delta / damp) : delta >> 1;
|
|
95
|
+
delta += floor(delta / numPoints);
|
|
96
|
+
while (delta > (base - tMin) * tMax >> 1) {
|
|
97
|
+
delta = floor(delta / (base - tMin));
|
|
98
|
+
k += base;
|
|
99
|
+
}
|
|
100
|
+
return floor(k + (base - tMin + 1) * delta / (delta + skew));
|
|
101
|
+
}
|
|
102
|
+
function decode(input) {
|
|
103
|
+
assertIsString(input, {
|
|
104
|
+
message: ({ currentType, validType }) => `Utils \`punycodeUtilsJS.decode\`, parameter \`input\` must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
105
|
+
});
|
|
106
|
+
const output = [];
|
|
107
|
+
const inputLength = input.length;
|
|
108
|
+
let i = 0, n = initialN, bias = initialBias;
|
|
109
|
+
let basic = input.lastIndexOf(delimiter);
|
|
110
|
+
if (basic < 0) basic = 0;
|
|
111
|
+
for (let j = 0; j < basic; j++) {
|
|
112
|
+
if (input.charCodeAt(j) >= 128) error("not-basic");
|
|
113
|
+
output.push(input.charCodeAt(j));
|
|
114
|
+
}
|
|
115
|
+
for (let index = basic > 0 ? basic + 1 : 0; index < inputLength; ) {
|
|
116
|
+
const oldi = i;
|
|
117
|
+
let w = 1;
|
|
118
|
+
for (let k = base; ; k += base) {
|
|
119
|
+
if (index >= inputLength) error("invalid-input");
|
|
120
|
+
const digit = basicToDigit(input.charCodeAt(index++));
|
|
121
|
+
if (digit >= base) error("invalid-input");
|
|
122
|
+
if (digit > floor((maxInt - i) / w)) error("overflow");
|
|
123
|
+
i += digit * w;
|
|
124
|
+
const t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
|
|
125
|
+
if (digit < t) break;
|
|
126
|
+
const baseMinusT = base - t;
|
|
127
|
+
if (w > floor(maxInt / baseMinusT)) error("overflow");
|
|
128
|
+
w *= baseMinusT;
|
|
129
|
+
}
|
|
130
|
+
const out = output.length + 1;
|
|
131
|
+
bias = adapt(i - oldi, out, oldi === 0);
|
|
132
|
+
if (floor(i / out) > maxInt - n) error("overflow");
|
|
133
|
+
n += floor(i / out);
|
|
134
|
+
i %= out;
|
|
135
|
+
output.splice(i++, 0, n);
|
|
136
|
+
}
|
|
137
|
+
return String.fromCodePoint(...output);
|
|
138
|
+
}
|
|
139
|
+
function encode(input) {
|
|
140
|
+
assertIsString(input, {
|
|
141
|
+
message: ({ currentType, validType }) => `Utils \`punycodeUtilsJS.encode\`, parameter \`input\` must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
142
|
+
});
|
|
143
|
+
const output = [];
|
|
144
|
+
const points = ucs2decode(input);
|
|
145
|
+
const inputLength = points.length;
|
|
146
|
+
let n = initialN, delta = 0, bias = initialBias;
|
|
147
|
+
for (const cp of points) if (cp < 128) output.push(stringFromCharCode(cp));
|
|
148
|
+
const basicLength = output.length;
|
|
149
|
+
let handledCPCount = basicLength;
|
|
150
|
+
if (basicLength) output.push(delimiter);
|
|
151
|
+
while (handledCPCount < inputLength) {
|
|
152
|
+
let m = maxInt;
|
|
153
|
+
for (const cp of points) if (cp >= n && cp < m) m = cp;
|
|
154
|
+
const handledCPCountPlusOne = handledCPCount + 1;
|
|
155
|
+
if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) error("overflow");
|
|
156
|
+
delta += (m - n) * handledCPCountPlusOne;
|
|
157
|
+
n = m;
|
|
158
|
+
for (const cp of points) {
|
|
159
|
+
if (cp < n) delta++;
|
|
160
|
+
if (cp === n) {
|
|
161
|
+
let q = delta;
|
|
162
|
+
for (let k = base; ; k += base) {
|
|
163
|
+
const t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
|
|
164
|
+
if (q < t) break;
|
|
165
|
+
output.push(stringFromCharCode(digitToBasic(t + (q - t) % (base - t), 0)));
|
|
166
|
+
q = floor((q - t) / (base - t));
|
|
167
|
+
}
|
|
168
|
+
output.push(stringFromCharCode(digitToBasic(q, 0)));
|
|
169
|
+
bias = adapt(delta, handledCPCountPlusOne, handledCPCount === basicLength);
|
|
170
|
+
delta = 0;
|
|
171
|
+
handledCPCount++;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
delta++;
|
|
175
|
+
n++;
|
|
176
|
+
}
|
|
177
|
+
return output.join("");
|
|
178
|
+
}
|
|
179
|
+
function toUnicode(input) {
|
|
180
|
+
assertIsString(input, {
|
|
181
|
+
message: ({ currentType, validType }) => `Utils \`punycodeUtilsJS.toUnicode\`, parameter \`input\` must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
182
|
+
});
|
|
183
|
+
return mapDomain(
|
|
184
|
+
input,
|
|
185
|
+
(str) => regexPunycode.test(str) ? decode(str.slice(4).toLowerCase()) : str
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
function toASCII(input) {
|
|
189
|
+
assertIsString(input, {
|
|
190
|
+
message: ({ currentType, validType }) => `Utils \`punycodeUtilsJS.toASCII\`, parameter \`input\` must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
191
|
+
});
|
|
192
|
+
return mapDomain(
|
|
193
|
+
input,
|
|
194
|
+
(str) => regexNonASCII.test(str) ? "xn--" + encode(str) : str
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
var punycodeUtilsJS = {
|
|
198
|
+
version: "1.0.0",
|
|
199
|
+
ucs2: {
|
|
200
|
+
decode: ucs2decode,
|
|
201
|
+
encode: ucs2encode
|
|
202
|
+
},
|
|
203
|
+
decode,
|
|
204
|
+
encode,
|
|
205
|
+
toASCII,
|
|
206
|
+
toUnicode
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
export { punycodeUtilsJS };
|