@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,23 +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
|
|
12
|
+
var chunk7C7TQC5J_cjs = require('./chunk-7C7TQC5J.cjs');
|
|
13
13
|
|
|
14
14
|
var assertIsString = (value, options = {}) => {
|
|
15
|
-
if (
|
|
16
|
-
|
|
15
|
+
if (chunk7C7TQC5J_cjs.isString(value)) return;
|
|
16
|
+
chunk7C7TQC5J_cjs.resolveErrorMessageAssertions({
|
|
17
17
|
value,
|
|
18
18
|
options,
|
|
19
19
|
requiredValidType: "string"
|
|
20
20
|
});
|
|
21
|
-
throw new TypeError(errorMessage);
|
|
22
21
|
};
|
|
23
22
|
|
|
24
23
|
exports.assertIsString = assertIsString;
|
|
@@ -2,21 +2,21 @@
|
|
|
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
|
|
14
|
-
var
|
|
12
|
+
var chunkQZI5PVCI_cjs = require('./chunk-QZI5PVCI.cjs');
|
|
13
|
+
var chunk2XGQQZ6A_cjs = require('./chunk-2XGQQZ6A.cjs');
|
|
14
|
+
var chunkPWKOFPAH_cjs = require('./chunk-PWKOFPAH.cjs');
|
|
15
15
|
var chunkDVMHRLKP_cjs = require('./chunk-DVMHRLKP.cjs');
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
var
|
|
16
|
+
var chunkFWWPEL7J_cjs = require('./chunk-FWWPEL7J.cjs');
|
|
17
|
+
var chunkWKM6UVMG_cjs = require('./chunk-WKM6UVMG.cjs');
|
|
18
|
+
var chunkH44QVAZL_cjs = require('./chunk-H44QVAZL.cjs');
|
|
19
|
+
var chunk7C7TQC5J_cjs = require('./chunk-7C7TQC5J.cjs');
|
|
20
20
|
var max = require('libphonenumber-js/max');
|
|
21
21
|
var locale = require('date-fns/locale');
|
|
22
22
|
var dateFns = require('date-fns');
|
|
@@ -28,69 +28,77 @@ var formatIndianNumber = (numStr, separator) => {
|
|
|
28
28
|
return rest.replace(/\B(?=(\d{2})+(?!\d))/g, separator) + separator + lastThree;
|
|
29
29
|
};
|
|
30
30
|
var formatCurrency = (value, options = {}) => {
|
|
31
|
-
if (!
|
|
31
|
+
if (!chunk7C7TQC5J_cjs.isString(value) && !chunkPWKOFPAH_cjs.isFinite(value)) {
|
|
32
32
|
throw new TypeError(
|
|
33
|
-
`First parameter (\`value\`) must be of type \`string\` or \`primitive-number\`, but received: \`${
|
|
33
|
+
`First parameter (\`value\`) must be of type \`string\` or \`primitive-number\`, but received: \`${chunk7C7TQC5J_cjs.getPreciseType(
|
|
34
34
|
value
|
|
35
|
-
)}\`, with value: \`${
|
|
35
|
+
)}\`, with value: \`${chunkH44QVAZL_cjs.safeStableStringify(value, {
|
|
36
|
+
keepUndefined: true
|
|
37
|
+
})}\`.`
|
|
36
38
|
);
|
|
37
39
|
}
|
|
38
|
-
|
|
40
|
+
chunk7C7TQC5J_cjs.assertIsPlainObject(options, {
|
|
39
41
|
message: ({ currentType, validType }) => `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
40
42
|
});
|
|
41
|
-
const decimal =
|
|
42
|
-
const totalDecimal =
|
|
43
|
-
const endDecimal =
|
|
44
|
-
const indianFormat =
|
|
45
|
-
const suffixCurrency =
|
|
46
|
-
const suffixDecimal =
|
|
47
|
-
const roundedDecimal =
|
|
48
|
-
const negativeFormat =
|
|
49
|
-
let separatorDecimals =
|
|
50
|
-
let separator =
|
|
51
|
-
if (!
|
|
43
|
+
const decimal = chunk7C7TQC5J_cjs.hasOwnProp(options, "decimal") ? options.decimal : false;
|
|
44
|
+
const totalDecimal = chunk7C7TQC5J_cjs.hasOwnProp(options, "totalDecimal") ? options.totalDecimal : 2;
|
|
45
|
+
const endDecimal = chunk7C7TQC5J_cjs.hasOwnProp(options, "endDecimal") ? options.endDecimal : true;
|
|
46
|
+
const indianFormat = chunk7C7TQC5J_cjs.hasOwnProp(options, "indianFormat") ? options.indianFormat : false;
|
|
47
|
+
const suffixCurrency = chunk7C7TQC5J_cjs.hasOwnProp(options, "suffixCurrency") ? options.suffixCurrency : "";
|
|
48
|
+
const suffixDecimal = chunk7C7TQC5J_cjs.hasOwnProp(options, "suffixDecimal") ? options.suffixDecimal : "";
|
|
49
|
+
const roundedDecimal = chunk7C7TQC5J_cjs.hasOwnProp(options, "roundedDecimal") ? options.roundedDecimal : "round";
|
|
50
|
+
const negativeFormat = chunk7C7TQC5J_cjs.hasOwnProp(options, "negativeFormat") ? options.negativeFormat : "dash";
|
|
51
|
+
let separatorDecimals = chunk7C7TQC5J_cjs.hasOwnProp(options, "separatorDecimals") ? options.separatorDecimals : ",";
|
|
52
|
+
let separator = chunk7C7TQC5J_cjs.hasOwnProp(options, "separator") ? options.separator : ".";
|
|
53
|
+
if (!chunk7C7TQC5J_cjs.isString(separator) || !chunk7C7TQC5J_cjs.isString(separatorDecimals) || !chunk7C7TQC5J_cjs.isString(suffixCurrency) || !chunk7C7TQC5J_cjs.isString(suffixDecimal)) {
|
|
52
54
|
throw new TypeError(
|
|
53
|
-
`Parameter \`separator\`, \`separatorDecimals\`, \`suffixCurrency\` and \`suffixDecimal\` property of the \`options\` (second parameter) must be of type \`string\`, but received: ['separator': \`${
|
|
55
|
+
`Parameter \`separator\`, \`separatorDecimals\`, \`suffixCurrency\` and \`suffixDecimal\` property of the \`options\` (second parameter) must be of type \`string\`, but received: ['separator': \`${chunk7C7TQC5J_cjs.getPreciseType(
|
|
54
56
|
separator
|
|
55
|
-
)}\`, 'separatorDecimals': \`${
|
|
57
|
+
)}\`, 'separatorDecimals': \`${chunk7C7TQC5J_cjs.getPreciseType(
|
|
56
58
|
separatorDecimals
|
|
57
|
-
)}\`, 'suffixCurrency': \`${
|
|
59
|
+
)}\`, 'suffixCurrency': \`${chunk7C7TQC5J_cjs.getPreciseType(
|
|
58
60
|
suffixCurrency
|
|
59
|
-
)}\`, 'suffixDecimal': \`${
|
|
61
|
+
)}\`, 'suffixDecimal': \`${chunk7C7TQC5J_cjs.getPreciseType(suffixDecimal)}\`].`
|
|
60
62
|
);
|
|
61
63
|
}
|
|
62
|
-
if (!
|
|
64
|
+
if (!chunk7C7TQC5J_cjs.isBoolean(decimal) || !chunk7C7TQC5J_cjs.isBoolean(endDecimal) || !chunk7C7TQC5J_cjs.isBoolean(indianFormat)) {
|
|
63
65
|
throw new TypeError(
|
|
64
|
-
`Parameter \`decimal\`, \`endDecimal\` and \`indianFormat\` property of the \`options\` (second parameter) must be of type \`boolean\`, but received: ['decimal': \`${
|
|
66
|
+
`Parameter \`decimal\`, \`endDecimal\` and \`indianFormat\` property of the \`options\` (second parameter) must be of type \`boolean\`, but received: ['decimal': \`${chunk7C7TQC5J_cjs.getPreciseType(
|
|
65
67
|
decimal
|
|
66
|
-
)}\`, 'endDecimal': \`${
|
|
68
|
+
)}\`, 'endDecimal': \`${chunk7C7TQC5J_cjs.getPreciseType(
|
|
67
69
|
endDecimal
|
|
68
|
-
)}\`, 'indianFormat': \`${
|
|
70
|
+
)}\`, 'indianFormat': \`${chunk7C7TQC5J_cjs.getPreciseType(indianFormat)}\`].`
|
|
69
71
|
);
|
|
70
72
|
}
|
|
71
73
|
if (!chunkDVMHRLKP_cjs.isInteger(totalDecimal)) {
|
|
72
74
|
throw new TypeError(
|
|
73
|
-
`Parameter \`totalDecimal\` property of the \`options\` (second parameter) must be of type \`integer-number\`, but received: \`${
|
|
75
|
+
`Parameter \`totalDecimal\` property of the \`options\` (second parameter) must be of type \`integer-number\`, but received: \`${chunk7C7TQC5J_cjs.getPreciseType(
|
|
74
76
|
totalDecimal
|
|
75
|
-
)}\`, with value: \`${
|
|
77
|
+
)}\`, with value: \`${chunkH44QVAZL_cjs.safeStableStringify(length, {
|
|
78
|
+
keepUndefined: true
|
|
79
|
+
})}\`.`
|
|
76
80
|
);
|
|
77
81
|
}
|
|
78
82
|
if (!(roundedDecimal === false || roundedDecimal === "round" || roundedDecimal === "ceil" || roundedDecimal === "floor")) {
|
|
79
83
|
throw new TypeError(
|
|
80
|
-
`Parameter \`roundedDecimal\` property of the \`options\` (second parameter) must be of type \`false\` or \`string\` must be one of "round" | "ceil" | "floor", but received: \`${
|
|
84
|
+
`Parameter \`roundedDecimal\` property of the \`options\` (second parameter) must be of type \`false\` or \`string\` must be one of "round" | "ceil" | "floor", but received: \`${chunk7C7TQC5J_cjs.getPreciseType(
|
|
81
85
|
roundedDecimal
|
|
82
|
-
)}\`, with value: \`${
|
|
86
|
+
)}\`, with value: \`${chunkH44QVAZL_cjs.safeStableStringify(roundedDecimal, {
|
|
87
|
+
keepUndefined: true
|
|
88
|
+
})}\`.`
|
|
83
89
|
);
|
|
84
90
|
}
|
|
85
|
-
if (!(negativeFormat === "abs" || negativeFormat === "brackets" || negativeFormat === "dash" ||
|
|
91
|
+
if (!(negativeFormat === "abs" || negativeFormat === "brackets" || negativeFormat === "dash" || chunk7C7TQC5J_cjs.isPlainObject(negativeFormat))) {
|
|
86
92
|
throw new TypeError(
|
|
87
|
-
`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: \`${
|
|
93
|
+
`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: \`${chunk7C7TQC5J_cjs.getPreciseType(
|
|
88
94
|
negativeFormat
|
|
89
|
-
)}\`, with value: \`${
|
|
95
|
+
)}\`, with value: \`${chunkH44QVAZL_cjs.safeStableStringify(negativeFormat, {
|
|
96
|
+
keepUndefined: true
|
|
97
|
+
})}\`.`
|
|
90
98
|
);
|
|
91
99
|
}
|
|
92
|
-
const rawNum =
|
|
93
|
-
if (
|
|
100
|
+
const rawNum = chunk7C7TQC5J_cjs.isString(value) ? chunk2XGQQZ6A_cjs.parseCurrencyString(value) : value;
|
|
101
|
+
if (chunk7C7TQC5J_cjs.isNaN(rawNum)) {
|
|
94
102
|
throw new TypeError(
|
|
95
103
|
`First parameter (\`value\`) could not be parsed into a valid \`number\`.`
|
|
96
104
|
);
|
|
@@ -129,7 +137,7 @@ var formatCurrency = (value, options = {}) => {
|
|
|
129
137
|
} else {
|
|
130
138
|
formattedInteger = (suffixCurrency.trim().length ? suffixCurrency : "") + integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, separator);
|
|
131
139
|
}
|
|
132
|
-
if (decimal && !
|
|
140
|
+
if (decimal && !chunk7C7TQC5J_cjs.isUndefined(decimalPartRaw) && totalDecimal > 0) {
|
|
133
141
|
let formattedDecimal = separatorDecimals + decimalPartRaw;
|
|
134
142
|
if (endDecimal) formattedDecimal += suffixDecimal;
|
|
135
143
|
formattedInteger += formattedDecimal;
|
|
@@ -139,32 +147,34 @@ var formatCurrency = (value, options = {}) => {
|
|
|
139
147
|
formattedInteger = "-" + formattedInteger;
|
|
140
148
|
} else if (negativeFormat === "brackets") {
|
|
141
149
|
formattedInteger = "(" + formattedInteger + ")";
|
|
142
|
-
} else if (negativeFormat === "abs") ; else if (
|
|
143
|
-
if (
|
|
150
|
+
} else if (negativeFormat === "abs") ; else if (chunk7C7TQC5J_cjs.isPlainObject(negativeFormat)) {
|
|
151
|
+
if (chunk7C7TQC5J_cjs.hasOwnProp(negativeFormat, "custom")) {
|
|
144
152
|
const formatCustomNegative = negativeFormat.custom;
|
|
145
|
-
if (!
|
|
153
|
+
if (!chunk7C7TQC5J_cjs.isFunction(formatCustomNegative)) {
|
|
146
154
|
throw new TypeError(
|
|
147
|
-
`Parameter \`negativeFormat.custom\` property of the \`options\` (second parameter) must be of type function: \`(formatted: string) => string\`, but received: \`${
|
|
155
|
+
`Parameter \`negativeFormat.custom\` property of the \`options\` (second parameter) must be of type function: \`(formatted: string) => string\`, but received: \`${chunk7C7TQC5J_cjs.getPreciseType(
|
|
148
156
|
formatCustomNegative
|
|
149
157
|
)}\`.`
|
|
150
158
|
);
|
|
151
159
|
}
|
|
152
160
|
const result = formatCustomNegative(formattedInteger);
|
|
153
|
-
|
|
161
|
+
chunkWKM6UVMG_cjs.assertIsString(result, {
|
|
154
162
|
message: ({ currentType, validType }) => `Parameter \`negativeFormat.custom\` property of the \`options\` (second parameter) expected return a \`${validType}\` type value, but received: \`${currentType}\`.`
|
|
155
163
|
});
|
|
156
164
|
formattedInteger = result;
|
|
157
165
|
} else {
|
|
158
166
|
const formatStyleNegative = negativeFormat.style || "dash";
|
|
159
|
-
const formatSpaceNegative = !
|
|
160
|
-
|
|
167
|
+
const formatSpaceNegative = !chunk7C7TQC5J_cjs.isUndefined(negativeFormat.space) ? negativeFormat.space : false;
|
|
168
|
+
chunk7C7TQC5J_cjs.assertIsBoolean(formatSpaceNegative, {
|
|
161
169
|
message: ({ currentType, validType }) => `Parameter \`negativeFormat.space\` property of the \`options\` (second parameter) must be of type \`${validType} or undefined\`, but received: \`${currentType}\`.`
|
|
162
170
|
});
|
|
163
171
|
if (!(formatStyleNegative === "abs" || formatStyleNegative === "brackets" || formatStyleNegative === "dash")) {
|
|
164
172
|
throw new TypeError(
|
|
165
|
-
`Parameter \`negativeFormat.style\` property of the \`options\` (second parameter) must be of type \`string\` must be of type "abs" | "brackets" | "dash", but received: \`${
|
|
173
|
+
`Parameter \`negativeFormat.style\` property of the \`options\` (second parameter) must be of type \`string\` must be of type "abs" | "brackets" | "dash", but received: \`${chunk7C7TQC5J_cjs.getPreciseType(
|
|
166
174
|
formatStyleNegative
|
|
167
|
-
)}\`, with value: \`${
|
|
175
|
+
)}\`, with value: \`${chunkH44QVAZL_cjs.safeStableStringify(formatStyleNegative, {
|
|
176
|
+
keepUndefined: true
|
|
177
|
+
})}\`.`
|
|
168
178
|
);
|
|
169
179
|
}
|
|
170
180
|
switch (formatStyleNegative) {
|
|
@@ -182,21 +192,21 @@ var formatCurrency = (value, options = {}) => {
|
|
|
182
192
|
};
|
|
183
193
|
|
|
184
194
|
var formatNumber = (value, separator = ",") => {
|
|
185
|
-
if (!
|
|
195
|
+
if (!chunk7C7TQC5J_cjs.isString(value) && !chunkPWKOFPAH_cjs.isFinite(value)) {
|
|
186
196
|
throw new TypeError(
|
|
187
|
-
`First parameter (\`value\`) must be of type \`string\` or \`primitive number\`, but received: \`${
|
|
197
|
+
`First parameter (\`value\`) must be of type \`string\` or \`primitive number\`, but received: \`${chunk7C7TQC5J_cjs.getPreciseType(
|
|
188
198
|
value
|
|
189
199
|
)}\`.`
|
|
190
200
|
);
|
|
191
201
|
}
|
|
192
|
-
if (!
|
|
202
|
+
if (!chunk7C7TQC5J_cjs.isString(separator)) {
|
|
193
203
|
throw new TypeError(
|
|
194
|
-
`Second parameter (\`separator\`) must be of type \`string\` or empty as \`undefined\`, but received: \`${
|
|
204
|
+
`Second parameter (\`separator\`) must be of type \`string\` or empty as \`undefined\`, but received: \`${chunk7C7TQC5J_cjs.getPreciseType(
|
|
195
205
|
separator
|
|
196
206
|
)}\`.`
|
|
197
207
|
);
|
|
198
208
|
}
|
|
199
|
-
separator =
|
|
209
|
+
separator = chunk7C7TQC5J_cjs.isString(separator) ? separator : ",";
|
|
200
210
|
const decimalSeparator = separator === "." ? "," : separator === "," ? "." : ".";
|
|
201
211
|
const stringValue = value.toString().trim();
|
|
202
212
|
const lastDot = stringValue.lastIndexOf(".");
|
|
@@ -235,42 +245,42 @@ var isValidParseAsYouType = (parsedAsYouType) => {
|
|
|
235
245
|
};
|
|
236
246
|
|
|
237
247
|
function formatPhoneNumber(value, options = {}) {
|
|
238
|
-
if (
|
|
239
|
-
if (!
|
|
248
|
+
if (chunk7C7TQC5J_cjs.isNil(value)) return "";
|
|
249
|
+
if (!chunk7C7TQC5J_cjs.isString(value) && !chunk7C7TQC5J_cjs.isNumber(value)) {
|
|
240
250
|
throw new TypeError(
|
|
241
|
-
`First parameter (\`value\`) must be of type \`string\`, \`number\`, \`null\` or \`undefined\`, but received: \`${
|
|
251
|
+
`First parameter (\`value\`) must be of type \`string\`, \`number\`, \`null\` or \`undefined\`, but received: \`${chunk7C7TQC5J_cjs.getPreciseType(
|
|
242
252
|
value
|
|
243
253
|
)}\`.`
|
|
244
254
|
);
|
|
245
255
|
}
|
|
246
|
-
|
|
256
|
+
chunk7C7TQC5J_cjs.assertIsPlainObject(options, {
|
|
247
257
|
message: ({ currentType, validType }) => `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
248
258
|
});
|
|
249
|
-
const takeNumberOnly =
|
|
250
|
-
const checkValidOnly =
|
|
251
|
-
const defaultCountry =
|
|
259
|
+
const takeNumberOnly = chunk7C7TQC5J_cjs.hasOwnProp(options, "takeNumberOnly") ? options.takeNumberOnly : false;
|
|
260
|
+
const checkValidOnly = chunk7C7TQC5J_cjs.hasOwnProp(options, "checkValidOnly") ? options.checkValidOnly : false;
|
|
261
|
+
const defaultCountry = chunk7C7TQC5J_cjs.hasOwnProp(
|
|
252
262
|
options,
|
|
253
263
|
"defaultCountry"
|
|
254
264
|
) ? options.defaultCountry : void 0;
|
|
255
|
-
const separator =
|
|
256
|
-
const prependPlusCountryCode =
|
|
257
|
-
const outputFormat =
|
|
258
|
-
const openingNumberCountry =
|
|
259
|
-
const closingNumberCountry =
|
|
260
|
-
if (!
|
|
265
|
+
const separator = chunk7C7TQC5J_cjs.hasOwnProp(options, "separator") ? options.separator : " ";
|
|
266
|
+
const prependPlusCountryCode = chunk7C7TQC5J_cjs.hasOwnProp(options, "prependPlusCountryCode") ? options.prependPlusCountryCode : true;
|
|
267
|
+
const outputFormat = chunk7C7TQC5J_cjs.hasOwnProp(options, "outputFormat") ? options.outputFormat : "INTERNATIONAL";
|
|
268
|
+
const openingNumberCountry = chunk7C7TQC5J_cjs.hasOwnProp(options, "openingNumberCountry") ? options.openingNumberCountry : "";
|
|
269
|
+
const closingNumberCountry = chunk7C7TQC5J_cjs.hasOwnProp(options, "closingNumberCountry") ? options.closingNumberCountry : "";
|
|
270
|
+
if (!chunk7C7TQC5J_cjs.isBoolean(takeNumberOnly) || !chunk7C7TQC5J_cjs.isBoolean(checkValidOnly) || !chunk7C7TQC5J_cjs.isBoolean(prependPlusCountryCode)) {
|
|
261
271
|
throw new TypeError(
|
|
262
|
-
`Parameter \`takeNumberOnly\`, \`checkValidOnly\` and \`prependPlusCountryCode\` property of the \`options\` (second parameter) must be of type \`boolean\` or unset as \`undefined\` value, but received: ['takeNumberOnly': \`${
|
|
272
|
+
`Parameter \`takeNumberOnly\`, \`checkValidOnly\` and \`prependPlusCountryCode\` property of the \`options\` (second parameter) must be of type \`boolean\` or unset as \`undefined\` value, but received: ['takeNumberOnly': \`${chunk7C7TQC5J_cjs.getPreciseType(
|
|
263
273
|
takeNumberOnly
|
|
264
|
-
)}\`, 'checkValidOnly': \`${
|
|
274
|
+
)}\`, 'checkValidOnly': \`${chunk7C7TQC5J_cjs.getPreciseType(
|
|
265
275
|
checkValidOnly
|
|
266
|
-
)}\`, 'prependPlusCountryCode': \`${
|
|
276
|
+
)}\`, 'prependPlusCountryCode': \`${chunk7C7TQC5J_cjs.getPreciseType(prependPlusCountryCode)}\`].`
|
|
267
277
|
);
|
|
268
278
|
}
|
|
269
|
-
if (!
|
|
279
|
+
if (!chunk7C7TQC5J_cjs.isUndefined(defaultCountry) && !max.isSupportedCountry(defaultCountry)) {
|
|
270
280
|
throw new TypeError(
|
|
271
|
-
`Parameter \`defaultCountry\` property of the \`options\` (second parameter) must be of type \`string\` as \`CountryCode\` (ISO-3166-1 alpha-2) or unset as \`undefined\` value, but received: \`${
|
|
281
|
+
`Parameter \`defaultCountry\` property of the \`options\` (second parameter) must be of type \`string\` as \`CountryCode\` (ISO-3166-1 alpha-2) or unset as \`undefined\` value, but received: \`${chunk7C7TQC5J_cjs.getPreciseType(
|
|
272
282
|
defaultCountry
|
|
273
|
-
)}\`, with value: \`${
|
|
283
|
+
)}\`, with value: \`${chunkH44QVAZL_cjs.safeStableStringify(defaultCountry, {
|
|
274
284
|
keepUndefined: true
|
|
275
285
|
})}\`.
|
|
276
286
|
|
|
@@ -279,21 +289,21 @@ See: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_e
|
|
|
279
289
|
}
|
|
280
290
|
if (!["INTERNATIONAL", "NATIONAL", "RFC3966", "E.164"].includes(outputFormat)) {
|
|
281
291
|
throw new TypeError(
|
|
282
|
-
`Parameter \`outputFormat\` property of the \`options\` (second parameter) must be of type \`string\` as \`OutputFormat\` ("NATIONAL" | "INTERNATIONAL" | "E.164" | "RFC3966") or unset as \`undefined\` (default value to: \`INTERNATIONAL\`) value, but received: \`${
|
|
292
|
+
`Parameter \`outputFormat\` property of the \`options\` (second parameter) must be of type \`string\` as \`OutputFormat\` ("NATIONAL" | "INTERNATIONAL" | "E.164" | "RFC3966") or unset as \`undefined\` (default value to: \`INTERNATIONAL\`) value, but received: \`${chunk7C7TQC5J_cjs.getPreciseType(
|
|
283
293
|
outputFormat
|
|
284
|
-
)}\`, with value: ${
|
|
294
|
+
)}\`, with value: ${chunkH44QVAZL_cjs.safeStableStringify(outputFormat, { keepUndefined: true })}.`
|
|
285
295
|
);
|
|
286
296
|
}
|
|
287
|
-
if (!
|
|
297
|
+
if (!chunk7C7TQC5J_cjs.isString(separator) || !chunk7C7TQC5J_cjs.isString(openingNumberCountry) || !chunk7C7TQC5J_cjs.isString(closingNumberCountry)) {
|
|
288
298
|
throw new TypeError(
|
|
289
|
-
`Parameter \`separator\`, \`plusNumberCountry\`, \`openingNumberCountry\` and \`closingNumberCountry\` property of the \`options\` (second parameter) must be of type \`string\` or unset as \`undefined\` value, but received: ['separator': \`${
|
|
299
|
+
`Parameter \`separator\`, \`plusNumberCountry\`, \`openingNumberCountry\` and \`closingNumberCountry\` property of the \`options\` (second parameter) must be of type \`string\` or unset as \`undefined\` value, but received: ['separator': \`${chunk7C7TQC5J_cjs.getPreciseType(
|
|
290
300
|
separator
|
|
291
|
-
)}\`,'openingNumberCountry': \`${
|
|
301
|
+
)}\`,'openingNumberCountry': \`${chunk7C7TQC5J_cjs.getPreciseType(
|
|
292
302
|
openingNumberCountry
|
|
293
|
-
)}\`, 'closingNumberCountry': \`${
|
|
303
|
+
)}\`, 'closingNumberCountry': \`${chunk7C7TQC5J_cjs.getPreciseType(closingNumberCountry)}\`].`
|
|
294
304
|
);
|
|
295
305
|
}
|
|
296
|
-
if (!
|
|
306
|
+
if (!chunk7C7TQC5J_cjs.isString(value)) value = String(value);
|
|
297
307
|
const parsedPhoneNumber = parsingAsYouType(value, defaultCountry);
|
|
298
308
|
const validPhoneNumber = isValidParseAsYouType(parsedPhoneNumber);
|
|
299
309
|
if (checkValidOnly) return validPhoneNumber;
|
|
@@ -307,7 +317,7 @@ See: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_e
|
|
|
307
317
|
const [cc, ...rest] = intlNumb.split(" ");
|
|
308
318
|
const countryCode = prependPlusCountryCode ? cc : cc.replace(/^\++/, "");
|
|
309
319
|
const restWithSeparator = rest.join(separator);
|
|
310
|
-
if (
|
|
320
|
+
if (chunk7C7TQC5J_cjs.isNonEmptyString(openingNumberCountry) && chunk7C7TQC5J_cjs.isNonEmptyString(closingNumberCountry)) {
|
|
311
321
|
return `${openingNumberCountry}${countryCode}${closingNumberCountry} ${restWithSeparator}`;
|
|
312
322
|
}
|
|
313
323
|
return `${countryCode} ${restWithSeparator}`;
|
|
@@ -337,7 +347,7 @@ var _censor = (str, minCensor, maxPercentage, hashSeed) => {
|
|
|
337
347
|
const indexes = /* @__PURE__ */ new Set();
|
|
338
348
|
let i = 0;
|
|
339
349
|
while (indexes.size < totalCensor) {
|
|
340
|
-
const idx = !
|
|
350
|
+
const idx = !chunk7C7TQC5J_cjs.isUndefined(hashSeed) ? (hashSeed + str.length + i * 31) % str.length : Math.floor(Math.random() * str.length);
|
|
341
351
|
indexes.add(idx);
|
|
342
352
|
i++;
|
|
343
353
|
}
|
|
@@ -348,16 +358,18 @@ var _censor = (str, minCensor, maxPercentage, hashSeed) => {
|
|
|
348
358
|
};
|
|
349
359
|
|
|
350
360
|
var censorEmail = (email, options = {}) => {
|
|
351
|
-
if (!
|
|
352
|
-
|
|
361
|
+
if (!chunk7C7TQC5J_cjs.isNonEmptyString(email)) return "";
|
|
362
|
+
chunk7C7TQC5J_cjs.assertIsPlainObject(options, {
|
|
353
363
|
message: ({ currentType, validType }) => `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
354
364
|
});
|
|
355
|
-
const mode =
|
|
365
|
+
const mode = chunk7C7TQC5J_cjs.hasOwnProp(options, "mode") ? options.mode : "fixed";
|
|
356
366
|
if (mode !== "random" && mode !== "fixed") {
|
|
357
367
|
throw new TypeError(
|
|
358
|
-
`Parameter \`mode\` property of the \`options\` (second parameter) must be one of "fixed" or "random", but received: \`${
|
|
368
|
+
`Parameter \`mode\` property of the \`options\` (second parameter) must be one of "fixed" or "random", but received: \`${chunk7C7TQC5J_cjs.getPreciseType(
|
|
359
369
|
mode
|
|
360
|
-
)}\`, with value: \`${
|
|
370
|
+
)}\`, with value: \`${chunkH44QVAZL_cjs.safeStableStringify(mode, {
|
|
371
|
+
keepUndefined: true
|
|
372
|
+
})}\`.`
|
|
361
373
|
);
|
|
362
374
|
}
|
|
363
375
|
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
|
@@ -377,29 +389,31 @@ var censorEmail = (email, options = {}) => {
|
|
|
377
389
|
};
|
|
378
390
|
|
|
379
391
|
function chunkString(subject, limiter, options = {}) {
|
|
380
|
-
if (
|
|
381
|
-
|
|
392
|
+
if (chunk7C7TQC5J_cjs.isNil(subject) || limiter <= 0) return subject;
|
|
393
|
+
chunkWKM6UVMG_cjs.assertIsString(subject, {
|
|
382
394
|
message: ({ currentType, validType }) => `First parameter (\`subject\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
383
395
|
});
|
|
384
396
|
if (!chunkDVMHRLKP_cjs.isInteger(limiter)) {
|
|
385
397
|
throw new TypeError(
|
|
386
|
-
`Second parameter (\`limiter\`) must be of type \`integer-number\`, but received: \`${
|
|
398
|
+
`Second parameter (\`limiter\`) must be of type \`integer-number\`, but received: \`${chunk7C7TQC5J_cjs.getPreciseType(
|
|
387
399
|
limiter
|
|
388
|
-
)}\`, with value: \`${
|
|
400
|
+
)}\`, with value: \`${chunkH44QVAZL_cjs.safeStableStringify(limiter, {
|
|
401
|
+
keepUndefined: true
|
|
402
|
+
})}\`.`
|
|
389
403
|
);
|
|
390
404
|
}
|
|
391
|
-
|
|
405
|
+
chunk7C7TQC5J_cjs.assertIsPlainObject(options, {
|
|
392
406
|
message: ({ currentType, validType }) => `Third parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
393
407
|
});
|
|
394
|
-
const separator =
|
|
395
|
-
const reCountAfterSpace =
|
|
396
|
-
|
|
408
|
+
const separator = chunk7C7TQC5J_cjs.hasOwnProp(options, "separator") ? options.separator : " ";
|
|
409
|
+
const reCountAfterSpace = chunk7C7TQC5J_cjs.hasOwnProp(options, "reCountAfterSpace") ? options.reCountAfterSpace : false;
|
|
410
|
+
chunkWKM6UVMG_cjs.assertIsString(separator, {
|
|
397
411
|
message: ({ currentType, validType }) => `Parameter \`separator\` property of the \`options\` (third parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
398
412
|
});
|
|
399
|
-
|
|
413
|
+
chunk7C7TQC5J_cjs.assertIsBoolean(reCountAfterSpace, {
|
|
400
414
|
message: ({ currentType, validType }) => `Parameter \`reCountAfterSpace\` property of the \`options\` (third parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
401
415
|
});
|
|
402
|
-
subject =
|
|
416
|
+
subject = chunkQZI5PVCI_cjs.normalizeSpaces(subject);
|
|
403
417
|
if (!reCountAfterSpace) {
|
|
404
418
|
let result = "";
|
|
405
419
|
let currentCount = 0;
|
|
@@ -442,28 +456,30 @@ function chunkString(subject, limiter, options = {}) {
|
|
|
442
456
|
}
|
|
443
457
|
|
|
444
458
|
var truncateString = (text, options = {}) => {
|
|
445
|
-
if (!
|
|
446
|
-
|
|
459
|
+
if (!chunk7C7TQC5J_cjs.isNonEmptyString(text)) return "";
|
|
460
|
+
chunk7C7TQC5J_cjs.assertIsPlainObject(options, {
|
|
447
461
|
message: ({ currentType, validType }) => `Seconds parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
448
462
|
});
|
|
449
|
-
const trim =
|
|
450
|
-
const length2 =
|
|
451
|
-
let ending =
|
|
463
|
+
const trim = chunk7C7TQC5J_cjs.hasOwnProp(options, "trim") ? options.trim : true;
|
|
464
|
+
const length2 = chunk7C7TQC5J_cjs.hasOwnProp(options, "length") ? options.length : 10;
|
|
465
|
+
let ending = chunk7C7TQC5J_cjs.hasOwnProp(options, "ending") ? options.ending : "...";
|
|
452
466
|
if (!chunkDVMHRLKP_cjs.isInteger(length2)) {
|
|
453
467
|
throw new TypeError(
|
|
454
|
-
`Parameter \`length\` property of the \`options\` (second parameter) must be of type \`integer-number\`, but received: \`${
|
|
468
|
+
`Parameter \`length\` property of the \`options\` (second parameter) must be of type \`integer-number\`, but received: \`${chunk7C7TQC5J_cjs.getPreciseType(
|
|
455
469
|
length2
|
|
456
|
-
)}\`, with value: \`${
|
|
470
|
+
)}\`, with value: \`${chunkH44QVAZL_cjs.safeStableStringify(length2, {
|
|
471
|
+
keepUndefined: true
|
|
472
|
+
})}\`.`
|
|
457
473
|
);
|
|
458
474
|
}
|
|
459
475
|
if (length2 < 1) return "";
|
|
460
|
-
|
|
476
|
+
chunkWKM6UVMG_cjs.assertIsString(ending, {
|
|
461
477
|
message: ({ currentType, validType }) => `Parameter \`ending\` property of the \`options\` (second parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
462
478
|
});
|
|
463
|
-
|
|
479
|
+
chunk7C7TQC5J_cjs.assertIsBoolean(trim, {
|
|
464
480
|
message: ({ currentType, validType }) => `Parameter \`trim\` property of the \`options\` (second parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`
|
|
465
481
|
});
|
|
466
|
-
if (
|
|
482
|
+
if (chunkFWWPEL7J_cjs.isEmptyString(ending)) {
|
|
467
483
|
ending = "...";
|
|
468
484
|
} else {
|
|
469
485
|
ending = ending.trim();
|
|
@@ -476,24 +492,24 @@ var truncateString = (text, options = {}) => {
|
|
|
476
492
|
return cleanSliced + ending;
|
|
477
493
|
};
|
|
478
494
|
var formatDateFns = (date, options = {}) => {
|
|
479
|
-
if (
|
|
480
|
-
if (!
|
|
495
|
+
if (chunk7C7TQC5J_cjs.isNil(date) || !(chunkH44QVAZL_cjs.isDate(date) || chunk7C7TQC5J_cjs.isNonEmptyString(date))) return null;
|
|
496
|
+
if (!chunk7C7TQC5J_cjs.isPlainObject(options)) {
|
|
481
497
|
options = {};
|
|
482
498
|
}
|
|
483
499
|
const { inputFormat, locale: locale$1 = "en", inputLocale = "en", ...restOptions } = options;
|
|
484
|
-
const format =
|
|
500
|
+
const format = chunk7C7TQC5J_cjs.hasOwnProp(options, "format") && chunk7C7TQC5J_cjs.isNonEmptyString(options.format) ? options.format : "dd MMM yyyy - HH:mm:ss";
|
|
485
501
|
let parsedDate;
|
|
486
502
|
try {
|
|
487
|
-
if (
|
|
488
|
-
const valueOfInputLocale =
|
|
503
|
+
if (chunk7C7TQC5J_cjs.isNonEmptyString(date) && inputFormat && inputLocale) {
|
|
504
|
+
const valueOfInputLocale = chunk7C7TQC5J_cjs.isNonEmptyString(inputLocale) ? inputLocale === "id" ? locale.id : locale.enUS : inputLocale;
|
|
489
505
|
parsedDate = dateFns.parse(date, inputFormat, /* @__PURE__ */ new Date(), {
|
|
490
506
|
locale: valueOfInputLocale
|
|
491
507
|
});
|
|
492
508
|
} else {
|
|
493
509
|
parsedDate = new Date(date);
|
|
494
510
|
}
|
|
495
|
-
if (
|
|
496
|
-
const valueOfLocale =
|
|
511
|
+
if (chunk7C7TQC5J_cjs.isNaN(parsedDate.getTime())) return null;
|
|
512
|
+
const valueOfLocale = chunk7C7TQC5J_cjs.isNonEmptyString(locale$1) ? locale$1 === "id" ? locale.id : locale.enUS : locale$1;
|
|
497
513
|
return dateFns.format(parsedDate, format, {
|
|
498
514
|
...restOptions,
|
|
499
515
|
locale: valueOfLocale
|
|
@@ -504,16 +520,16 @@ var formatDateFns = (date, options = {}) => {
|
|
|
504
520
|
};
|
|
505
521
|
|
|
506
522
|
var formatDateIntl = (date, options) => {
|
|
507
|
-
if (
|
|
523
|
+
if (chunk7C7TQC5J_cjs.isNil(date) || !(chunkH44QVAZL_cjs.isDate(date) || chunk7C7TQC5J_cjs.isNonEmptyString(date))) return null;
|
|
508
524
|
const parsedDate = new Date(date);
|
|
509
|
-
if (
|
|
510
|
-
if (!
|
|
525
|
+
if (chunk7C7TQC5J_cjs.isNaN(parsedDate.getTime())) return null;
|
|
526
|
+
if (!chunk7C7TQC5J_cjs.isPlainObject(options)) {
|
|
511
527
|
options = {};
|
|
512
528
|
}
|
|
513
529
|
const { locale = "en-US", ...restProps } = options;
|
|
514
530
|
try {
|
|
515
531
|
return new Intl.DateTimeFormat(
|
|
516
|
-
|
|
532
|
+
chunk7C7TQC5J_cjs.isNonEmptyString(locale) ? locale.trim() : "en-US",
|
|
517
533
|
restProps
|
|
518
534
|
).format(parsedDate);
|
|
519
535
|
} catch {
|
|
@@ -522,16 +538,16 @@ var formatDateIntl = (date, options) => {
|
|
|
522
538
|
};
|
|
523
539
|
|
|
524
540
|
var formatDateTime = (date, format) => {
|
|
525
|
-
if (
|
|
541
|
+
if (chunk7C7TQC5J_cjs.isNil(format)) {
|
|
526
542
|
format = "YYYY-MM-DD hh:mm:ss";
|
|
527
543
|
}
|
|
528
|
-
if (!
|
|
529
|
-
if (
|
|
544
|
+
if (!chunk7C7TQC5J_cjs.isString(format)) return null;
|
|
545
|
+
if (chunk7C7TQC5J_cjs.isNil(date) || !(chunkH44QVAZL_cjs.isDate(date) || chunk7C7TQC5J_cjs.isNonEmptyString(date))) {
|
|
530
546
|
return null;
|
|
531
547
|
}
|
|
532
548
|
try {
|
|
533
549
|
const parsedDate = new Date(date);
|
|
534
|
-
if (
|
|
550
|
+
if (chunk7C7TQC5J_cjs.isNaN(parsedDate.getTime())) return null;
|
|
535
551
|
const pad2 = (n) => n.toString().padStart(2, "0");
|
|
536
552
|
const map = {
|
|
537
553
|
YYYY: parsedDate.getFullYear().toString(),
|
|
@@ -553,13 +569,13 @@ var formatDateTime = (date, format) => {
|
|
|
553
569
|
|
|
554
570
|
var getGMTOffset = (date) => {
|
|
555
571
|
try {
|
|
556
|
-
if (
|
|
572
|
+
if (chunk7C7TQC5J_cjs.isNil(date) || chunk7C7TQC5J_cjs.isString(date) && chunkFWWPEL7J_cjs.isEmptyString(date)) {
|
|
557
573
|
date = /* @__PURE__ */ new Date();
|
|
558
|
-
} else if (!(
|
|
574
|
+
} else if (!(chunkH44QVAZL_cjs.isDate(date) || chunk7C7TQC5J_cjs.isNonEmptyString(date))) {
|
|
559
575
|
return "0";
|
|
560
576
|
}
|
|
561
577
|
const parsedDate = new Date(date);
|
|
562
|
-
if (
|
|
578
|
+
if (chunk7C7TQC5J_cjs.isNaN(parsedDate.getTime())) return "0";
|
|
563
579
|
const padZero = (num) => num.toString().padStart(2, "0");
|
|
564
580
|
let offset = parsedDate.getTimezoneOffset();
|
|
565
581
|
const sign = offset < 0 ? "+" : "-";
|
|
@@ -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 { isEmptyValue } from './chunk-
|
|
10
|
+
import { isEmptyValue } from './chunk-44X74C26.js';
|
|
11
11
|
|
|
12
12
|
var isNonEmptyValue = (value, options = {}) => {
|
|
13
13
|
return !isEmptyValue(value, options);
|
package/dist/chunk-WVSPXFTY.js
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,13 +2,13 @@
|
|
|
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 { assertIsPlainObject, isPlainObject, isBoolean, isNaN, hasOwnProp, getPreciseType, isUndefined, isNumberObject, isInfinityNumber, isStringObject, isBooleanObject, isFunction, isSymbol, isObjectOrArray, isSet, isArray, isNull, isNumber, isObject } from './chunk-
|
|
11
|
+
import { assertIsPlainObject, isPlainObject, isBoolean, isNaN, hasOwnProp, getPreciseType, isUndefined, isNumberObject, isInfinityNumber, isStringObject, isBooleanObject, isFunction, isSymbol, isObjectOrArray, isSet, isArray, isNull, isNumber, isObject } from './chunk-J4TT33ZX.js';
|
|
12
12
|
|
|
13
13
|
function isMap(value) {
|
|
14
14
|
return Object.prototype.toString.call(value) === "[object Map]" || value instanceof Map;
|