full-utils 1.0.11 → 2.0.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.
Files changed (156) hide show
  1. package/README.md +189 -1
  2. package/dist/index.cjs +1039 -0
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.d.cts +4495 -0
  5. package/dist/index.d.ts +4495 -49
  6. package/dist/index.js +977 -99
  7. package/dist/index.js.map +1 -1
  8. package/package.json +64 -18
  9. package/dist/src/from/fromJSON.d.ts +0 -5
  10. package/dist/src/from/fromJSON.js +0 -71
  11. package/dist/src/from/fromJSON.js.map +0 -1
  12. package/dist/src/from/fromTimestamp.d.ts +0 -6
  13. package/dist/src/from/fromTimestamp.js +0 -8
  14. package/dist/src/from/fromTimestamp.js.map +0 -1
  15. package/dist/src/index.d.ts +0 -49
  16. package/dist/src/index.js +0 -100
  17. package/dist/src/index.js.map +0 -1
  18. package/dist/src/is/isArr.d.ts +0 -1
  19. package/dist/src/is/isArr.js +0 -7
  20. package/dist/src/is/isArr.js.map +0 -1
  21. package/dist/src/is/isArrFilled.d.ts +0 -1
  22. package/dist/src/is/isArrFilled.js +0 -8
  23. package/dist/src/is/isArrFilled.js.map +0 -1
  24. package/dist/src/is/isBool.d.ts +0 -1
  25. package/dist/src/is/isBool.js +0 -7
  26. package/dist/src/is/isBool.js.map +0 -1
  27. package/dist/src/is/isDate.d.ts +0 -1
  28. package/dist/src/is/isDate.js +0 -16
  29. package/dist/src/is/isDate.js.map +0 -1
  30. package/dist/src/is/isEmail.d.ts +0 -1
  31. package/dist/src/is/isEmail.js +0 -9
  32. package/dist/src/is/isEmail.js.map +0 -1
  33. package/dist/src/is/isExists.d.ts +0 -1
  34. package/dist/src/is/isExists.js +0 -7
  35. package/dist/src/is/isExists.js.map +0 -1
  36. package/dist/src/is/isFunc.d.ts +0 -1
  37. package/dist/src/is/isFunc.js +0 -7
  38. package/dist/src/is/isFunc.js.map +0 -1
  39. package/dist/src/is/isIp.d.ts +0 -1
  40. package/dist/src/is/isIp.js +0 -13
  41. package/dist/src/is/isIp.js.map +0 -1
  42. package/dist/src/is/isMac.d.ts +0 -1
  43. package/dist/src/is/isMac.js +0 -8
  44. package/dist/src/is/isMac.js.map +0 -1
  45. package/dist/src/is/isNum.d.ts +0 -1
  46. package/dist/src/is/isNum.js +0 -7
  47. package/dist/src/is/isNum.js.map +0 -1
  48. package/dist/src/is/isNumFloat.d.ts +0 -1
  49. package/dist/src/is/isNumFloat.js +0 -8
  50. package/dist/src/is/isNumFloat.js.map +0 -1
  51. package/dist/src/is/isNumN.d.ts +0 -1
  52. package/dist/src/is/isNumN.js +0 -8
  53. package/dist/src/is/isNumN.js.map +0 -1
  54. package/dist/src/is/isNumNZ.d.ts +0 -1
  55. package/dist/src/is/isNumNZ.js +0 -8
  56. package/dist/src/is/isNumNZ.js.map +0 -1
  57. package/dist/src/is/isNumP.d.ts +0 -1
  58. package/dist/src/is/isNumP.js +0 -8
  59. package/dist/src/is/isNumP.js.map +0 -1
  60. package/dist/src/is/isNumPZ.d.ts +0 -1
  61. package/dist/src/is/isNumPZ.js +0 -8
  62. package/dist/src/is/isNumPZ.js.map +0 -1
  63. package/dist/src/is/isObj.d.ts +0 -1
  64. package/dist/src/is/isObj.js +0 -10
  65. package/dist/src/is/isObj.js.map +0 -1
  66. package/dist/src/is/isObjFilled.d.ts +0 -1
  67. package/dist/src/is/isObjFilled.js +0 -8
  68. package/dist/src/is/isObjFilled.js.map +0 -1
  69. package/dist/src/is/isPassword.d.ts +0 -10
  70. package/dist/src/is/isPassword.js +0 -26
  71. package/dist/src/is/isPassword.js.map +0 -1
  72. package/dist/src/is/isPhone.d.ts +0 -1
  73. package/dist/src/is/isPhone.js +0 -35
  74. package/dist/src/is/isPhone.js.map +0 -1
  75. package/dist/src/is/isStr.d.ts +0 -1
  76. package/dist/src/is/isStr.js +0 -7
  77. package/dist/src/is/isStr.js.map +0 -1
  78. package/dist/src/is/isStrBool.d.ts +0 -1
  79. package/dist/src/is/isStrBool.js +0 -12
  80. package/dist/src/is/isStrBool.js.map +0 -1
  81. package/dist/src/is/isStrFilled.d.ts +0 -1
  82. package/dist/src/is/isStrFilled.js +0 -8
  83. package/dist/src/is/isStrFilled.js.map +0 -1
  84. package/dist/src/is/isStrOrderType.d.ts +0 -1
  85. package/dist/src/is/isStrOrderType.js +0 -12
  86. package/dist/src/is/isStrOrderType.js.map +0 -1
  87. package/dist/src/is/isVar.d.ts +0 -1
  88. package/dist/src/is/isVar.js +0 -8
  89. package/dist/src/is/isVar.js.map +0 -1
  90. package/dist/src/net/netTCP.d.ts +0 -6
  91. package/dist/src/net/netTCP.js +0 -52
  92. package/dist/src/net/netTCP.js.map +0 -1
  93. package/dist/src/to/toArrFuncArgs.d.ts +0 -1
  94. package/dist/src/to/toArrFuncArgs.js +0 -139
  95. package/dist/src/to/toArrFuncArgs.js.map +0 -1
  96. package/dist/src/to/toBool.d.ts +0 -1
  97. package/dist/src/to/toBool.js +0 -23
  98. package/dist/src/to/toBool.js.map +0 -1
  99. package/dist/src/to/toCellDate.d.ts +0 -1
  100. package/dist/src/to/toCellDate.js +0 -12
  101. package/dist/src/to/toCellDate.js.map +0 -1
  102. package/dist/src/to/toDateStr.d.ts +0 -1
  103. package/dist/src/to/toDateStr.js +0 -14
  104. package/dist/src/to/toDateStr.js.map +0 -1
  105. package/dist/src/to/toGB.d.ts +0 -1
  106. package/dist/src/to/toGB.js +0 -47
  107. package/dist/src/to/toGB.js.map +0 -1
  108. package/dist/src/to/toGH.d.ts +0 -1
  109. package/dist/src/to/toGH.js +0 -36
  110. package/dist/src/to/toGH.js.map +0 -1
  111. package/dist/src/to/toH.d.ts +0 -1
  112. package/dist/src/to/toH.js +0 -36
  113. package/dist/src/to/toH.js.map +0 -1
  114. package/dist/src/to/toInetAton.d.ts +0 -1
  115. package/dist/src/to/toInetAton.js +0 -18
  116. package/dist/src/to/toInetAton.js.map +0 -1
  117. package/dist/src/to/toInetNtoa.d.ts +0 -1
  118. package/dist/src/to/toInetNtoa.js +0 -16
  119. package/dist/src/to/toInetNtoa.js.map +0 -1
  120. package/dist/src/to/toJSON.d.ts +0 -1
  121. package/dist/src/to/toJSON.js +0 -14
  122. package/dist/src/to/toJSON.js.map +0 -1
  123. package/dist/src/to/toLower.d.ts +0 -1
  124. package/dist/src/to/toLower.js +0 -14
  125. package/dist/src/to/toLower.js.map +0 -1
  126. package/dist/src/to/toNull.d.ts +0 -1
  127. package/dist/src/to/toNull.js +0 -11
  128. package/dist/src/to/toNull.js.map +0 -1
  129. package/dist/src/to/toNum.d.ts +0 -1
  130. package/dist/src/to/toNum.js +0 -40
  131. package/dist/src/to/toNum.js.map +0 -1
  132. package/dist/src/to/toPhone.d.ts +0 -1
  133. package/dist/src/to/toPhone.js +0 -24
  134. package/dist/src/to/toPhone.js.map +0 -1
  135. package/dist/src/to/toPoolName.d.ts +0 -1
  136. package/dist/src/to/toPoolName.js +0 -19
  137. package/dist/src/to/toPoolName.js.map +0 -1
  138. package/dist/src/to/toPortions.d.ts +0 -1
  139. package/dist/src/to/toPortions.js +0 -16
  140. package/dist/src/to/toPortions.js.map +0 -1
  141. package/dist/src/to/toRangeip.d.ts +0 -1
  142. package/dist/src/to/toRangeip.js +0 -24
  143. package/dist/src/to/toRangeip.js.map +0 -1
  144. package/dist/src/to/toSqlUpdateMany.d.ts +0 -1
  145. package/dist/src/to/toSqlUpdateMany.js +0 -39
  146. package/dist/src/to/toSqlUpdateMany.js.map +0 -1
  147. package/dist/src/to/toTimestamp.d.ts +0 -6
  148. package/dist/src/to/toTimestamp.js +0 -11
  149. package/dist/src/to/toTimestamp.js.map +0 -1
  150. package/dist/src/to/toTrim.d.ts +0 -1
  151. package/dist/src/to/toTrim.js +0 -10
  152. package/dist/src/to/toTrim.js.map +0 -1
  153. package/dist/src/to/toUndefined.d.ts +0 -1
  154. package/dist/src/to/toUndefined.js +0 -11
  155. package/dist/src/to/toUndefined.js.map +0 -1
  156. package/dist/tsconfig.build.tsbuildinfo +0 -1
package/dist/index.js CHANGED
@@ -1,100 +1,978 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.netTCP = exports.toRangeip = exports.toSqlUpdateMany = exports.toUndefined = exports.toNull = exports.toTrim = exports.toPoolName = exports.toLower = exports.toPhone = exports.toJSON = exports.toArrFuncArgs = exports.toDateStr = exports.toTimestamp = exports.toPortions = exports.toNum = exports.toInetNtoa = exports.toInetAton = exports.toH = exports.toGH = exports.toGB = exports.toCellDate = exports.toBool = exports.isVar = exports.isStrOrderType = exports.isStrFilled = exports.isStrBool = exports.isStr = exports.isPhone = exports.isPassword = exports.isObjFilled = exports.isObj = exports.isNumPZ = exports.isNumP = exports.isNumNZ = exports.isNumN = exports.isNumFloat = exports.isNum = exports.isMac = exports.isIp = exports.isFunc = exports.isExists = exports.isEmail = exports.isDate = exports.isBool = exports.isArrFilled = exports.isArr = exports.fromTimestamp = exports.fromJSON = void 0;
4
- const fromJSON_1 = require("./src/from/fromJSON");
5
- Object.defineProperty(exports, "fromJSON", { enumerable: true, get: function () { return fromJSON_1.fromJSON; } });
6
- const fromTimestamp_1 = require("./src/from/fromTimestamp");
7
- Object.defineProperty(exports, "fromTimestamp", { enumerable: true, get: function () { return fromTimestamp_1.fromTimestamp; } });
8
- const isArr_1 = require("./src/is/isArr");
9
- Object.defineProperty(exports, "isArr", { enumerable: true, get: function () { return isArr_1.isArr; } });
10
- const isArrFilled_1 = require("./src/is/isArrFilled");
11
- Object.defineProperty(exports, "isArrFilled", { enumerable: true, get: function () { return isArrFilled_1.isArrFilled; } });
12
- const isBool_1 = require("./src/is/isBool");
13
- Object.defineProperty(exports, "isBool", { enumerable: true, get: function () { return isBool_1.isBool; } });
14
- const isDate_1 = require("./src/is/isDate");
15
- Object.defineProperty(exports, "isDate", { enumerable: true, get: function () { return isDate_1.isDate; } });
16
- const isEmail_1 = require("./src/is/isEmail");
17
- Object.defineProperty(exports, "isEmail", { enumerable: true, get: function () { return isEmail_1.isEmail; } });
18
- const isExists_1 = require("./src/is/isExists");
19
- Object.defineProperty(exports, "isExists", { enumerable: true, get: function () { return isExists_1.isExists; } });
20
- const isFunc_1 = require("./src/is/isFunc");
21
- Object.defineProperty(exports, "isFunc", { enumerable: true, get: function () { return isFunc_1.isFunc; } });
22
- const isIp_1 = require("./src/is/isIp");
23
- Object.defineProperty(exports, "isIp", { enumerable: true, get: function () { return isIp_1.isIp; } });
24
- const isMac_1 = require("./src/is/isMac");
25
- Object.defineProperty(exports, "isMac", { enumerable: true, get: function () { return isMac_1.isMac; } });
26
- const isNum_1 = require("./src/is/isNum");
27
- Object.defineProperty(exports, "isNum", { enumerable: true, get: function () { return isNum_1.isNum; } });
28
- const isNumFloat_1 = require("./src/is/isNumFloat");
29
- Object.defineProperty(exports, "isNumFloat", { enumerable: true, get: function () { return isNumFloat_1.isNumFloat; } });
30
- const isNumN_1 = require("./src/is/isNumN");
31
- Object.defineProperty(exports, "isNumN", { enumerable: true, get: function () { return isNumN_1.isNumN; } });
32
- const isNumNZ_1 = require("./src/is/isNumNZ");
33
- Object.defineProperty(exports, "isNumNZ", { enumerable: true, get: function () { return isNumNZ_1.isNumNZ; } });
34
- const isNumP_1 = require("./src/is/isNumP");
35
- Object.defineProperty(exports, "isNumP", { enumerable: true, get: function () { return isNumP_1.isNumP; } });
36
- const isNumPZ_1 = require("./src/is/isNumPZ");
37
- Object.defineProperty(exports, "isNumPZ", { enumerable: true, get: function () { return isNumPZ_1.isNumPZ; } });
38
- const isObj_1 = require("./src/is/isObj");
39
- Object.defineProperty(exports, "isObj", { enumerable: true, get: function () { return isObj_1.isObj; } });
40
- const isObjFilled_1 = require("./src/is/isObjFilled");
41
- Object.defineProperty(exports, "isObjFilled", { enumerable: true, get: function () { return isObjFilled_1.isObjFilled; } });
42
- const isPassword_1 = require("./src/is/isPassword");
43
- Object.defineProperty(exports, "isPassword", { enumerable: true, get: function () { return isPassword_1.isPassword; } });
44
- const isPhone_1 = require("./src/is/isPhone");
45
- Object.defineProperty(exports, "isPhone", { enumerable: true, get: function () { return isPhone_1.isPhone; } });
46
- const isStr_1 = require("./src/is/isStr");
47
- Object.defineProperty(exports, "isStr", { enumerable: true, get: function () { return isStr_1.isStr; } });
48
- const isStrBool_1 = require("./src/is/isStrBool");
49
- Object.defineProperty(exports, "isStrBool", { enumerable: true, get: function () { return isStrBool_1.isStrBool; } });
50
- const isStrFilled_1 = require("./src/is/isStrFilled");
51
- Object.defineProperty(exports, "isStrFilled", { enumerable: true, get: function () { return isStrFilled_1.isStrFilled; } });
52
- const isStrOrderType_1 = require("./src/is/isStrOrderType");
53
- Object.defineProperty(exports, "isStrOrderType", { enumerable: true, get: function () { return isStrOrderType_1.isStrOrderType; } });
54
- const isVar_1 = require("./src/is/isVar");
55
- Object.defineProperty(exports, "isVar", { enumerable: true, get: function () { return isVar_1.isVar; } });
56
- const toBool_1 = require("./src/to/toBool");
57
- Object.defineProperty(exports, "toBool", { enumerable: true, get: function () { return toBool_1.toBool; } });
58
- const toCellDate_1 = require("./src/to/toCellDate");
59
- Object.defineProperty(exports, "toCellDate", { enumerable: true, get: function () { return toCellDate_1.toCellDate; } });
60
- const toGB_1 = require("./src/to/toGB");
61
- Object.defineProperty(exports, "toGB", { enumerable: true, get: function () { return toGB_1.toGB; } });
62
- const toGH_1 = require("./src/to/toGH");
63
- Object.defineProperty(exports, "toGH", { enumerable: true, get: function () { return toGH_1.toGH; } });
64
- const toH_1 = require("./src/to/toH");
65
- Object.defineProperty(exports, "toH", { enumerable: true, get: function () { return toH_1.toH; } });
66
- const toInetAton_1 = require("./src/to/toInetAton");
67
- Object.defineProperty(exports, "toInetAton", { enumerable: true, get: function () { return toInetAton_1.toInetAton; } });
68
- const toInetNtoa_1 = require("./src/to/toInetNtoa");
69
- Object.defineProperty(exports, "toInetNtoa", { enumerable: true, get: function () { return toInetNtoa_1.toInetNtoa; } });
70
- const toNum_1 = require("./src/to/toNum");
71
- Object.defineProperty(exports, "toNum", { enumerable: true, get: function () { return toNum_1.toNum; } });
72
- const toPortions_1 = require("./src/to/toPortions");
73
- Object.defineProperty(exports, "toPortions", { enumerable: true, get: function () { return toPortions_1.toPortions; } });
74
- const toTimestamp_1 = require("./src/to/toTimestamp");
75
- Object.defineProperty(exports, "toTimestamp", { enumerable: true, get: function () { return toTimestamp_1.toTimestamp; } });
76
- const toDateStr_1 = require("./src/to/toDateStr");
77
- Object.defineProperty(exports, "toDateStr", { enumerable: true, get: function () { return toDateStr_1.toDateStr; } });
78
- const toArrFuncArgs_1 = require("./src/to/toArrFuncArgs");
79
- Object.defineProperty(exports, "toArrFuncArgs", { enumerable: true, get: function () { return toArrFuncArgs_1.toArrFuncArgs; } });
80
- const toJSON_1 = require("./src/to/toJSON");
81
- Object.defineProperty(exports, "toJSON", { enumerable: true, get: function () { return toJSON_1.toJSON; } });
82
- const toPhone_1 = require("./src/to/toPhone");
83
- Object.defineProperty(exports, "toPhone", { enumerable: true, get: function () { return toPhone_1.toPhone; } });
84
- const toLower_1 = require("./src/to/toLower");
85
- Object.defineProperty(exports, "toLower", { enumerable: true, get: function () { return toLower_1.toLower; } });
86
- const toPoolName_1 = require("./src/to/toPoolName");
87
- Object.defineProperty(exports, "toPoolName", { enumerable: true, get: function () { return toPoolName_1.toPoolName; } });
88
- const toTrim_1 = require("./src/to/toTrim");
89
- Object.defineProperty(exports, "toTrim", { enumerable: true, get: function () { return toTrim_1.toTrim; } });
90
- const toNull_1 = require("./src/to/toNull");
91
- Object.defineProperty(exports, "toNull", { enumerable: true, get: function () { return toNull_1.toNull; } });
92
- const toUndefined_1 = require("./src/to/toUndefined");
93
- Object.defineProperty(exports, "toUndefined", { enumerable: true, get: function () { return toUndefined_1.toUndefined; } });
94
- const toSqlUpdateMany_1 = require("./src/to/toSqlUpdateMany");
95
- Object.defineProperty(exports, "toSqlUpdateMany", { enumerable: true, get: function () { return toSqlUpdateMany_1.toSqlUpdateMany; } });
96
- const toRangeip_1 = require("./src/to/toRangeip");
97
- Object.defineProperty(exports, "toRangeip", { enumerable: true, get: function () { return toRangeip_1.toRangeip; } });
98
- const netTCP_1 = require("./src/net/netTCP");
99
- Object.defineProperty(exports, "netTCP", { enumerable: true, get: function () { return netTCP_1.netTCP; } });
1
+ // src/arr/formatStrToFuncArgs.ts
2
+ function formatStrToFuncArgs(value) {
3
+ if (!isStr(value)) {
4
+ return [value];
5
+ }
6
+ let src = value.trim();
7
+ if (src === "") {
8
+ return [];
9
+ }
10
+ if (src.startsWith("[") && src.endsWith("]")) {
11
+ src = src.slice(1, -1).trim();
12
+ if (src === "") {
13
+ return [];
14
+ }
15
+ }
16
+ let buf = "", inQuote = false, quoteChar = null, esc = false, depthParen = 0, depthBracket = 0, depthBrace = 0;
17
+ const items = [];
18
+ const finalize = () => {
19
+ const trimmed = buf.trim();
20
+ if (trimmed !== "") {
21
+ items.push(trimmed);
22
+ }
23
+ buf = "";
24
+ };
25
+ for (let i = 0; i < src.length; i++) {
26
+ const ch = src[i];
27
+ if (inQuote) {
28
+ buf += ch;
29
+ if (esc) {
30
+ esc = false;
31
+ continue;
32
+ }
33
+ if (ch === "\\") {
34
+ esc = true;
35
+ continue;
36
+ }
37
+ if (ch === quoteChar) {
38
+ inQuote = false;
39
+ quoteChar = null;
40
+ }
41
+ continue;
42
+ }
43
+ if (ch === '"' || ch === "'") {
44
+ inQuote = true;
45
+ quoteChar = ch;
46
+ buf += ch;
47
+ continue;
48
+ }
49
+ if (ch === "(") {
50
+ depthParen++;
51
+ buf += ch;
52
+ continue;
53
+ }
54
+ if (ch === ")") {
55
+ depthParen = Math.max(0, depthParen - 1);
56
+ buf += ch;
57
+ continue;
58
+ }
59
+ if (ch === "[") {
60
+ depthBracket++;
61
+ buf += ch;
62
+ continue;
63
+ }
64
+ if (ch === "]") {
65
+ depthBracket = Math.max(0, depthBracket - 1);
66
+ buf += ch;
67
+ continue;
68
+ }
69
+ if (ch === "{") {
70
+ depthBrace++;
71
+ buf += ch;
72
+ continue;
73
+ }
74
+ if (ch === "}") {
75
+ depthBrace = Math.max(0, depthBrace - 1);
76
+ buf += ch;
77
+ continue;
78
+ }
79
+ if (ch === "," && depthParen === 0 && depthBracket === 0 && depthBrace === 0) {
80
+ finalize();
81
+ continue;
82
+ }
83
+ buf += ch;
84
+ }
85
+ if (buf.length) {
86
+ finalize();
87
+ }
88
+ return items.map((raw) => {
89
+ if (raw.startsWith("$") && raw.includes("(") && raw.endsWith(")")) {
90
+ return raw;
91
+ }
92
+ if (raw === "null") {
93
+ return null;
94
+ }
95
+ if (raw === "undefined") {
96
+ return void 0;
97
+ }
98
+ if (isStrBool(raw)) {
99
+ return formatToBool(raw);
100
+ }
101
+ const n = formatToNum(raw);
102
+ if (Number.isFinite(n)) {
103
+ return n;
104
+ }
105
+ if (raw === "Infinity") {
106
+ return Infinity;
107
+ }
108
+ if (raw === "-Infinity") {
109
+ return -Infinity;
110
+ }
111
+ const rawStr = String(raw || "");
112
+ const hasQuotes = rawStr.length >= 2 && (rawStr.startsWith("'") && rawStr.endsWith("'") || rawStr.startsWith('"') && rawStr.endsWith('"'));
113
+ if (hasQuotes) {
114
+ return rawStr.slice(1, -1).replace(/\\\\/g, "\\").replace(/\\'/g, "'").replace(/\\"/g, '"');
115
+ }
116
+ if (rawStr.startsWith("{") && rawStr.endsWith("}") || rawStr.startsWith("[") && rawStr.endsWith("]")) {
117
+ try {
118
+ return jsonDecode(rawStr);
119
+ } catch {
120
+ }
121
+ }
122
+ return rawStr;
123
+ });
124
+ }
125
+
126
+ // src/arr/splitArrToPortions.ts
127
+ function splitArrToPortions(arr, portionLength) {
128
+ if (!Number.isInteger(portionLength) || portionLength <= 0) {
129
+ return [];
130
+ }
131
+ const out = [];
132
+ let i = 0;
133
+ while (i < arr.length) {
134
+ out.push(arr.slice(i, i + portionLength));
135
+ i += portionLength;
136
+ }
137
+ return out;
138
+ }
139
+
140
+ // src/bool/formatToBool.ts
141
+ function formatToBool(value) {
142
+ switch (true) {
143
+ case isBool(value):
144
+ return value;
145
+ case isNumP(value):
146
+ return true;
147
+ case isNumNZ(value):
148
+ return false;
149
+ case (isStrFilled(value) && ["true", "1", "yes", "on"].includes(String(value ?? "").trim().toLowerCase())):
150
+ return true;
151
+ case (isStrFilled(value) && ["false", "0", "no", "off"].includes(String(value ?? "").trim().toLowerCase())):
152
+ return false;
153
+ }
154
+ return false;
155
+ }
156
+
157
+ // src/common/wait.ts
158
+ async function wait(timeout = 0) {
159
+ await new Promise((resolve) => setTimeout(() => resolve(true), timeout));
160
+ }
161
+
162
+ // src/date/floorDateToMinutes.ts
163
+ function floorDateToMinutes(everyMinutes = 1, date = /* @__PURE__ */ new Date()) {
164
+ const step = Math.min(60, Math.max(1, Math.trunc(Math.abs(everyMinutes))));
165
+ const m = date.getMinutes();
166
+ const floored = Math.floor(m / step) * step;
167
+ const d = new Date(date);
168
+ d.setMinutes(floored, 0, 0);
169
+ return d;
170
+ }
171
+
172
+ // src/date/formatDateToString.ts
173
+ function formatDateToString(date = /* @__PURE__ */ new Date()) {
174
+ const pad = (n) => String(n).padStart(2, "0");
175
+ const year = date.getFullYear();
176
+ const month = pad(date.getMonth() + 1);
177
+ const day = pad(date.getDate());
178
+ const hours = pad(date.getHours());
179
+ const minutes = pad(date.getMinutes());
180
+ const seconds = pad(date.getSeconds());
181
+ return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
182
+ }
183
+
184
+ // src/date/partsToSeconds.ts
185
+ function partsToSeconds(parts) {
186
+ const { days = 0, hours = 0, minutes = 0, seconds = 0 } = parts;
187
+ return days * 86400 + hours * 3600 + minutes * 60 + seconds;
188
+ }
189
+
190
+ // src/date/secondsToParts.ts
191
+ function secondsToParts(total) {
192
+ if (!Number.isFinite(total) || total < 0) {
193
+ throw new Error("Invalid total seconds");
194
+ }
195
+ const days = Math.floor(total / 86400);
196
+ const hours = Math.floor(total % 86400 / 3600);
197
+ const minutes = Math.floor(total % 3600 / 60);
198
+ const seconds = total % 60;
199
+ return { days, hours, minutes, seconds };
200
+ }
201
+
202
+ // src/ip-addr/cidrToRange.ts
203
+ function cidrToRange(cidr) {
204
+ const [ip, maskStr] = cidr.split("/");
205
+ const base = parseIPv4(ip);
206
+ const mask = maskStr ? Number(maskStr) : NaN;
207
+ if (base === null || !Number.isInteger(mask) || mask < 0 || mask > 32) {
208
+ return null;
209
+ }
210
+ const netmask = mask === 0 ? 0 : 4294967295 << 32 - mask >>> 0;
211
+ const start = base & netmask;
212
+ const end = start | ~netmask >>> 0;
213
+ return [toIPv4(start), toIPv4(end)];
214
+ }
215
+
216
+ // src/ip-addr/ipAddrToNum.ts
217
+ function ipAddrToNum(ip) {
218
+ const parts = ip.split(".").map((p) => Number(p));
219
+ if (parts.length !== 4 || parts.some((p) => !Number.isInteger(p) || p < 0 || p > 255)) {
220
+ throw new Error("Invalid IPv4 address");
221
+ }
222
+ const buffer = new ArrayBuffer(4);
223
+ const dv = new DataView(buffer);
224
+ let i = 0;
225
+ while (i < 4) {
226
+ dv.setUint8(i, parts[i]);
227
+ i++;
228
+ }
229
+ return dv.getUint32(0, false);
230
+ }
231
+
232
+ // src/ip-addr/numToIpAddr.ts
233
+ function numToIpAddr(num) {
234
+ if (!isNumP(num)) {
235
+ return "";
236
+ }
237
+ const nbuffer = new ArrayBuffer(4);
238
+ const ndv = new DataView(nbuffer);
239
+ ndv.setUint32(0, num, false);
240
+ const output = [];
241
+ let i = 0;
242
+ while (i < 4) {
243
+ output.push(ndv.getUint8(i));
244
+ i++;
245
+ }
246
+ return output.join(".");
247
+ }
248
+
249
+ // src/ip-addr/parseIPv4.ts
250
+ function parseIPv4(ip) {
251
+ if (!isStr(ip)) {
252
+ return null;
253
+ }
254
+ const parts = formatToTrim(ip).split(".");
255
+ if (parts.length !== 4) {
256
+ return null;
257
+ }
258
+ let out = 0;
259
+ for (let i = 0; i < 4; i++) {
260
+ if (!/^\d{1,3}$/.test(parts[i])) {
261
+ return null;
262
+ }
263
+ const n = Number(parts[i]);
264
+ if (n < 0 || n > 255) {
265
+ return null;
266
+ }
267
+ out = out << 8 | n;
268
+ }
269
+ return out >>> 0;
270
+ }
271
+
272
+ // src/ip-addr/rangeIPv4.ts
273
+ function* rangeIPv4(from, to, opts = {}) {
274
+ const { includeNetwork = true, includeBroadcast = true } = opts;
275
+ let startNum;
276
+ let endNum;
277
+ let isCIDR = false;
278
+ let cidrMask = null;
279
+ if (to === void 0 && from.includes("/")) {
280
+ const range = cidrToRange(from);
281
+ if (!range) {
282
+ throw new Error(`Invalid CIDR: "${from}"`);
283
+ }
284
+ const [startStr, endStr] = range;
285
+ const [_, maskStr] = from.split("/");
286
+ cidrMask = Number(maskStr);
287
+ startNum = parseIPv4(startStr);
288
+ endNum = parseIPv4(endStr);
289
+ isCIDR = true;
290
+ } else {
291
+ const s = parseIPv4(from);
292
+ if (s === null) {
293
+ throw new Error(`Invalid IPv4: "${from}"`);
294
+ }
295
+ startNum = s;
296
+ if (to && to.trim() !== "") {
297
+ const e = parseIPv4(to);
298
+ if (e === null) {
299
+ throw new Error(`Invalid IPv4: "${to}"`);
300
+ }
301
+ endNum = e;
302
+ } else {
303
+ const a = startNum >>> 24 & 255;
304
+ const b = startNum >>> 16 & 255;
305
+ const c = startNum >>> 8 & 255;
306
+ endNum = (a << 24 | b << 16 | c << 8 | 255) >>> 0;
307
+ }
308
+ }
309
+ if (startNum > endNum) {
310
+ [startNum, endNum] = [endNum, startNum];
311
+ }
312
+ let skipNetworkAt = -1;
313
+ let skipBroadcastAt = -1;
314
+ if (isCIDR && cidrMask !== null) {
315
+ if (cidrMask <= 30) {
316
+ skipNetworkAt = startNum;
317
+ skipBroadcastAt = endNum;
318
+ }
319
+ }
320
+ for (let cur = startNum; cur <= endNum; cur = cur + 1 >>> 0) {
321
+ if (!includeNetwork && cur === skipNetworkAt) {
322
+ if (cur === endNum) {
323
+ break;
324
+ }
325
+ continue;
326
+ }
327
+ if (!includeBroadcast && cur === skipBroadcastAt) {
328
+ if (cur === endNum) {
329
+ break;
330
+ }
331
+ continue;
332
+ }
333
+ yield toIPv4(cur);
334
+ if (cur === 4294967295) {
335
+ break;
336
+ }
337
+ }
338
+ }
339
+
340
+ // src/ip-addr/rangeIPv4ToArr.ts
341
+ function rangeIPv4ToArr2(from, to, opts = {}) {
342
+ const { limit = 1e6 } = opts;
343
+ const out = [];
344
+ let count = 0;
345
+ for (const ip of rangeIPv4(from, to, opts)) {
346
+ if (count >= limit) {
347
+ throw new Error(`Range is too large (> ${limit}). Use the generator version instead.`);
348
+ }
349
+ out.push(ip);
350
+ count++;
351
+ }
352
+ return out;
353
+ }
354
+
355
+ // src/ip-addr/toIPv4.ts
356
+ function toIPv4(n) {
357
+ if (!Number.isInteger(n) || n < 0 || n > 4294967295) {
358
+ throw new Error(`Invalid IPv4 number: ${n}`);
359
+ }
360
+ return [
361
+ n >>> 24 & 255,
362
+ n >>> 16 & 255,
363
+ n >>> 8 & 255,
364
+ n & 255
365
+ ].join(".");
366
+ }
367
+
368
+ // src/is/isArr.ts
369
+ function isArr(value) {
370
+ return Array.isArray(value);
371
+ }
372
+
373
+ // src/is/isArrFilled.ts
374
+ function isArrFilled(value) {
375
+ return isArr(value) && value.length > 0;
376
+ }
377
+
378
+ // src/is/isBool.ts
379
+ function isBool(value) {
380
+ return typeof value === "boolean";
381
+ }
382
+
383
+ // src/is/isDate.ts
384
+ function isDate(value) {
385
+ if (value instanceof Date) {
386
+ return !Number.isNaN(value.getTime());
387
+ }
388
+ if (isStr(value) || isNum(value)) {
389
+ const d = new Date(value);
390
+ return !Number.isNaN(d.getTime());
391
+ }
392
+ return false;
393
+ }
394
+
395
+ // src/is/isEmail.ts
396
+ var emailRegex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z]{2,})+$/;
397
+ function isEmail(value) {
398
+ if (!isStrFilled(value)) {
399
+ return false;
400
+ }
401
+ return emailRegex.test(value);
402
+ }
403
+
404
+ // src/is/isExists.ts
405
+ function isExists(value) {
406
+ return value !== null && value !== void 0;
407
+ }
408
+
409
+ // src/is/isFunc.ts
410
+ function isFunc(value) {
411
+ return typeof value === "function";
412
+ }
413
+
414
+ // src/is/isIpAddr.ts
415
+ var IPV4_RE = /^(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)$/;
416
+ function isIpAddr(value) {
417
+ if (!isStr(value)) {
418
+ return false;
419
+ }
420
+ const v = value.trim();
421
+ return IPV4_RE.test(v);
422
+ }
423
+
424
+ // src/is/isMacAddr.ts
425
+ function isMacAddr(value) {
426
+ return isStr(value) && /^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$/.test(value);
427
+ }
428
+
429
+ // src/is/isNum.ts
430
+ function isNum(value) {
431
+ return typeof value === "number" && Number.isFinite(value);
432
+ }
433
+
434
+ // src/is/isNumFloat.ts
435
+ function isNumFloat(value) {
436
+ return isNum(value) && !Number.isInteger(value);
437
+ }
438
+
439
+ // src/is/isNumN.ts
440
+ function isNumN(value) {
441
+ return isNum(value) && value < 0;
442
+ }
443
+
444
+ // src/is/isNumNZ.ts
445
+ function isNumNZ(value) {
446
+ return isNum(value) && value <= 0;
447
+ }
448
+
449
+ // src/is/isNumP.ts
450
+ function isNumP(value) {
451
+ return isNum(value) && value > 0;
452
+ }
453
+
454
+ // src/is/isNumPZ.ts
455
+ function isNumPZ(value) {
456
+ return isNum(value) && value >= 0;
457
+ }
458
+
459
+ // src/is/isObj.ts
460
+ function isObj(value) {
461
+ return typeof value === "object" && value !== null && Object.prototype.toString.call(value) === "[object Object]" && !Array.isArray(value);
462
+ }
463
+
464
+ // src/is/isObjFilled.ts
465
+ function isObjFilled(value) {
466
+ return isObj(value) && Object.keys(value).length > 0;
467
+ }
468
+
469
+ // src/is/isPassword.ts
470
+ function isPassword(value, {
471
+ minLength = 8,
472
+ maxLength = 256,
473
+ requireUppercase = true,
474
+ requireLowercase = true,
475
+ requireDigit = true,
476
+ requireSpecial = true
477
+ } = {}) {
478
+ if (!isStr(value)) {
479
+ return false;
480
+ }
481
+ if (value.length < minLength || value.length > maxLength) {
482
+ return false;
483
+ }
484
+ if (requireUppercase && !/[A-ZА-Я]/.test(value)) {
485
+ return false;
486
+ }
487
+ if (requireLowercase && !/[a-zа-я]/.test(value)) {
488
+ return false;
489
+ }
490
+ if (requireDigit && !/\d/.test(value)) {
491
+ return false;
492
+ }
493
+ if (requireSpecial && !/[~!?@#$%^&*_\-+()\[\]{}><\\\/|"'.,:;=]/.test(value)) {
494
+ return false;
495
+ }
496
+ return true;
497
+ }
498
+
499
+ // src/is/isPhone.ts
500
+ function isPhone(value) {
501
+ if (!isStrFilled(value) && !isNum(value)) {
502
+ return false;
503
+ }
504
+ const valueProcessed = String(value).trim();
505
+ if (valueProcessed.startsWith("-")) {
506
+ return false;
507
+ }
508
+ if ((valueProcessed.match(/\+/g) || []).length > 1) {
509
+ return false;
510
+ }
511
+ if (valueProcessed.includes("+") && !valueProcessed.startsWith("+")) {
512
+ return false;
513
+ }
514
+ if (!/^\+?[0-9-]+$/.test(valueProcessed)) {
515
+ return false;
516
+ }
517
+ if (valueProcessed.length < 3 || valueProcessed.length > 20) {
518
+ return false;
519
+ }
520
+ if (!/[0-9]$/.test(valueProcessed)) {
521
+ return false;
522
+ }
523
+ if (valueProcessed.includes("--")) {
524
+ return false;
525
+ }
526
+ return true;
527
+ }
528
+
529
+ // src/is/isStr.ts
530
+ function isStr(value) {
531
+ return typeof value === "string";
532
+ }
533
+
534
+ // src/is/isStrBool.ts
535
+ function isStrBool(value) {
536
+ if (!isStrFilled(value)) {
537
+ return false;
538
+ }
539
+ const normalized = value.trim().toLowerCase();
540
+ return normalized === "true" || normalized === "false";
541
+ }
542
+
543
+ // src/is/isStrFilled.ts
544
+ function isStrFilled(value) {
545
+ return isStr(value) && value.trim().length > 0;
546
+ }
547
+
548
+ // src/is/isStrAscDesc.ts
549
+ function isStrAscDesc(value) {
550
+ if (!isStrFilled(value)) {
551
+ return false;
552
+ }
553
+ const normalized = value.trim().toLowerCase();
554
+ return normalized === "asc" || normalized === "desc";
555
+ }
556
+
557
+ // src/is/isVar.ts
558
+ function isVar(value) {
559
+ return isStr(value) && /^[A-Za-z_][A-Za-z0-9_]*$/.test(value);
560
+ }
561
+
562
+ // src/json/parseStringLike.ts
563
+ var QUOTED_RE = /^(['"`])([\s\S]*)\1$/;
564
+ function parseStringLike(s, allowString) {
565
+ const trimmed = s.trim();
566
+ const pr = tryParseJSON(trimmed);
567
+ if (pr.ok) {
568
+ return pr.value;
569
+ }
570
+ const m = QUOTED_RE.exec(trimmed);
571
+ if (m) {
572
+ return m[2];
573
+ }
574
+ return allowString ? trimmed : null;
575
+ }
576
+
577
+ // src/json/tryParseJSON.ts
578
+ function tryParseJSON(str) {
579
+ try {
580
+ return { ok: true, value: JSON.parse(str) };
581
+ } catch (err) {
582
+ }
583
+ return { ok: false };
584
+ }
585
+
586
+ // src/json/jsonDecode.ts
587
+ function jsonDecode(value, allowString = false) {
588
+ if (value === null || isNum(value) || isBool(value)) {
589
+ return value;
590
+ }
591
+ if (isArrFilled(value)) {
592
+ const arr = value;
593
+ const out = [];
594
+ for (const item of arr) {
595
+ if (isStrFilled(item)) {
596
+ out.push(parseStringLike(String(item), allowString));
597
+ } else {
598
+ out.push(item);
599
+ }
600
+ }
601
+ return out;
602
+ }
603
+ if (isObjFilled(value)) {
604
+ const src = value;
605
+ const out = {};
606
+ for (const key of Object.keys(src)) {
607
+ const v = src[key];
608
+ if (isStrFilled(v)) {
609
+ out[key] = parseStringLike(String(v), allowString);
610
+ } else {
611
+ out[key] = v;
612
+ }
613
+ }
614
+ return out;
615
+ }
616
+ if (isArr(value) || isObj(value)) {
617
+ return value;
618
+ }
619
+ if (isStrFilled(value)) {
620
+ return parseStringLike(String(value), allowString);
621
+ }
622
+ return null;
623
+ }
624
+
625
+ // src/json/jsonEncode.ts
626
+ function jsonEncode2(value) {
627
+ try {
628
+ return isObj(value) || isArr(value) ? JSON.stringify(value) : "";
629
+ } catch (err) {
630
+ }
631
+ return "";
632
+ }
633
+
634
+ // src/num/changeFixedDecimalScale.ts
635
+ function changeFixedDecimalScale(value, scaleDelta) {
636
+ const delta = Math.trunc(scaleDelta);
637
+ if (delta === 0) {
638
+ return { ...value };
639
+ }
640
+ if (delta > 0) {
641
+ return {
642
+ sign: value.sign,
643
+ digitsInteger: value.digitsInteger,
644
+ scale: value.scale + delta
645
+ };
646
+ }
647
+ const multiplier = 10n ** BigInt(-delta);
648
+ return {
649
+ sign: value.sign,
650
+ digitsInteger: value.digitsInteger * multiplier,
651
+ scale: value.scale + delta
652
+ };
653
+ }
654
+
655
+ // src/num/convertExponentialToParts.ts
656
+ function convertExponentialToParts(sign, exponentialString) {
657
+ const match = /^([0-9]+)(?:\.([0-9]*))?e([+\-]?[0-9]+)$/i.exec(
658
+ (() => {
659
+ const [coefficient, exponentText] = exponentialString.split(/e/i);
660
+ const [integerPart, fractionalPart = ""] = coefficient.split(".");
661
+ const allDigits2 = integerPart.replace(/^0+/, "") + fractionalPart;
662
+ const exponentValue = parseInt(exponentText, 10) - fractionalPart.length;
663
+ return `${allDigits2 || "0"}e${exponentValue}`;
664
+ })()
665
+ );
666
+ if (!match) {
667
+ throw new Error("Failed to parse exponential notation.");
668
+ }
669
+ let allDigits = match[1];
670
+ const exponent = parseInt(match[3], 10);
671
+ if (isNumPZ(exponent)) {
672
+ allDigits = allDigits + "0".repeat(exponent);
673
+ return {
674
+ sign,
675
+ integerPart: allDigits || "0",
676
+ fractionalPart: ""
677
+ };
678
+ } else {
679
+ const digitsToLeft = -exponent;
680
+ if (digitsToLeft >= allDigits.length) {
681
+ const missingZeros = "0".repeat(digitsToLeft - allDigits.length);
682
+ return {
683
+ sign,
684
+ integerPart: "0",
685
+ fractionalPart: missingZeros + allDigits
686
+ };
687
+ } else {
688
+ const splitIndex = allDigits.length - digitsToLeft;
689
+ return {
690
+ sign,
691
+ integerPart: allDigits.slice(0, splitIndex),
692
+ fractionalPart: allDigits.slice(splitIndex)
693
+ };
694
+ }
695
+ }
696
+ }
697
+
698
+ // src/num/fixedDecimalToNum.ts
699
+ function fixedDecimalToNum(value) {
700
+ return Number(fixedDecimalToStr(value));
701
+ }
702
+
703
+ // src/num/fixedDecimalToStr.ts
704
+ function fixedDecimalToStr(value) {
705
+ const signSymbol = value.sign < 0 ? "-" : "";
706
+ const allDigitsString = value.digitsInteger.toString();
707
+ if (value.scale === 0) {
708
+ return signSymbol + allDigitsString;
709
+ }
710
+ const padZeros = value.scale - allDigitsString.length;
711
+ if (padZeros >= 0) {
712
+ return signSymbol + "0." + "0".repeat(padZeros) + allDigitsString;
713
+ }
714
+ const integerBoundary = allDigitsString.length - value.scale;
715
+ const integerText = allDigitsString.slice(0, integerBoundary);
716
+ const fractionalText = allDigitsString.slice(integerBoundary);
717
+ return signSymbol + integerText + "." + fractionalText;
718
+ }
719
+
720
+ // src/num/formatToNum.ts
721
+ function formatToNum(value, round = 1) {
722
+ return fixedDecimalToNum(round > 1 ? roundFixedDecimal(parseToFixedDecimal(value), round, "half-up") : parseToFixedDecimal(value));
723
+ }
724
+
725
+ // src/num/normalizeToDecimalComponents.ts
726
+ function normalizeToDecimalComponents(input) {
727
+ if (typeof input === "bigint") {
728
+ const sign = input < 0n ? -1 : 1;
729
+ const absoluteValue = (input < 0n ? -input : input).toString();
730
+ return {
731
+ sign,
732
+ integerPart: absoluteValue,
733
+ fractionalPart: ""
734
+ };
735
+ }
736
+ if (typeof input === "number") {
737
+ if (!Number.isFinite(input)) {
738
+ throw new Error("Input number is not finite.");
739
+ }
740
+ const sign = input < 0 ? -1 : 1;
741
+ const absoluteValue = Math.abs(input);
742
+ const exponentialForm = absoluteValue.toExponential(30);
743
+ return convertExponentialToParts(sign, exponentialForm);
744
+ }
745
+ if (typeof input === "string") {
746
+ let processed = input.trim().replace(",", ".");
747
+ if (!processed) {
748
+ throw new Error("Input string is empty.");
749
+ }
750
+ let sign = 1;
751
+ if (processed.startsWith("+") || processed.startsWith("-")) {
752
+ sign = processed.startsWith("-") ? -1 : 1;
753
+ processed = processed.slice(1);
754
+ }
755
+ if (/^[0-9]*\.?[0-9]*(e[+\-]?[0-9]+)?$/i.test(processed)) {
756
+ if (/e/i.test(processed)) {
757
+ return convertExponentialToParts(sign, processed);
758
+ }
759
+ const [integerPart = "0", fractionalPart = ""] = processed.split(".");
760
+ return {
761
+ sign,
762
+ integerPart,
763
+ fractionalPart
764
+ };
765
+ }
766
+ throw new Error("Invalid numeric string.");
767
+ }
768
+ throw new Error("Unsupported input type.");
769
+ }
770
+
771
+ // src/num/parseToFixedDecimal.ts
772
+ function parseToFixedDecimal(input) {
773
+ const {
774
+ sign,
775
+ integerPart,
776
+ fractionalPart
777
+ } = normalizeToDecimalComponents(input);
778
+ const integerDigits = integerPart.replace(/^0+/, "") || "0";
779
+ const fractionalDigits = fractionalPart.replace(/0+$/, "");
780
+ const combinedDigits = integerDigits + fractionalDigits || "0";
781
+ return {
782
+ sign,
783
+ digitsInteger: BigInt(combinedDigits),
784
+ scale: fractionalDigits.length
785
+ };
786
+ }
787
+
788
+ // src/num/roundFixedDecimal.ts
789
+ function roundFixedDecimal(source, decimalPlaces, roundMode = "half-up") {
790
+ const targetPrecision = Math.max(0, Math.trunc(decimalPlaces));
791
+ if (source.scale <= targetPrecision) {
792
+ return { ...source };
793
+ }
794
+ const digitsToRemove = source.scale - targetPrecision;
795
+ const divisionFactor = 10n ** BigInt(digitsToRemove);
796
+ const integerPart = source.digitsInteger / divisionFactor;
797
+ const remainder = source.digitsInteger % divisionFactor;
798
+ if (roundMode === "trunc" || remainder === 0n) {
799
+ return {
800
+ sign: source.sign,
801
+ digitsInteger: integerPart,
802
+ scale: targetPrecision
803
+ };
804
+ }
805
+ const halfThreshold = divisionFactor / 2n;
806
+ const shouldRoundUp = remainder >= halfThreshold;
807
+ const roundedValue = shouldRoundUp ? integerPart + 1n : integerPart;
808
+ return {
809
+ sign: source.sign,
810
+ digitsInteger: roundedValue,
811
+ scale: targetPrecision
812
+ };
813
+ }
814
+
815
+ // src/str/formatToLowerCase.ts
816
+ function formatToLowerCase(value) {
817
+ if (!isStr(value)) {
818
+ return "";
819
+ }
820
+ const trimmed = formatToTrim(value);
821
+ return isStrFilled(trimmed) ? trimmed.toLowerCase() : "";
822
+ }
823
+
824
+ // src/str/formatToNull.ts
825
+ function formatToNull(value) {
826
+ return isStr(value) && formatToTrim(value) === "" || value === void 0 ? null : value;
827
+ }
828
+
829
+ // src/str/formatToPhone.ts
830
+ function formatToPhone(value, defaultCountry = "+7") {
831
+ if (!isStr(value)) {
832
+ return null;
833
+ }
834
+ let phone = formatToTrim(value).replace(/[\s\-().]/g, "");
835
+ if (/^00\d{8,15}$/.test(phone)) {
836
+ phone = "+" + phone.slice(2);
837
+ } else if (/^\d{10}$/.test(phone)) {
838
+ phone = defaultCountry + phone;
839
+ } else if (/^\d{9,15}$/.test(phone) && !phone.startsWith("0")) {
840
+ phone = "+" + phone;
841
+ }
842
+ return /^\+\d{10,15}$/.test(phone) ? phone : null;
843
+ }
844
+
845
+ // src/str/formatToTrim.ts
846
+ function formatToTrim(value) {
847
+ return String(isStr(value) ? value.trim().normalize("NFKC").replace(/[\u200B-\u200D\uFEFF]/g, "") : "");
848
+ }
849
+
850
+ // src/str/formatToUndefined.ts
851
+ function formatToUndefined2(value) {
852
+ return isStr(value) && formatToTrim(value) === "" || value === null ? void 0 : value;
853
+ }
854
+
855
+ // src/units/toGB.ts
856
+ var KB = 1024;
857
+ var MB = KB * 1024;
858
+ var GB = MB * 1024;
859
+ var TB = GB * 1024;
860
+ var PB = TB * 1024;
861
+ function toGB(value, unit = "") {
862
+ const v = formatToNum(value);
863
+ if (!isNum(v)) {
864
+ throw new Error(`toGB: value "${value}" is not numeric`);
865
+ }
866
+ const u = String(unit).trim().toLowerCase().replace(/\s+/g, "");
867
+ const c = u ? u[0] : "g";
868
+ let out;
869
+ switch (c) {
870
+ case "b":
871
+ out = v / GB;
872
+ break;
873
+ case "k":
874
+ out = v / MB;
875
+ break;
876
+ case "m":
877
+ out = v / GB;
878
+ break;
879
+ case "g":
880
+ out = v;
881
+ break;
882
+ case "t":
883
+ out = v * (TB / GB);
884
+ break;
885
+ case "p":
886
+ out = v * (PB / GB);
887
+ break;
888
+ default:
889
+ out = v;
890
+ break;
891
+ }
892
+ if (!isNum(out)) {
893
+ throw new Error(`toGB: result is not finite (value="${value}", unit="${unit}")`);
894
+ }
895
+ return Object.is(out, -0) ? 0 : out;
896
+ }
897
+
898
+ // src/units/normalizeUnit.ts
899
+ function normalizeUnit(u) {
900
+ return String(u).trim().toLowerCase().replace(/\s+/g, "").replace(/(?:\/?s|hash(?:es)?)$/i, "");
901
+ }
902
+
903
+ // src/units/toGH.ts
904
+ var FACTOR = {
905
+ h: 1e-9,
906
+ k: 1e-6,
907
+ m: 1e-3,
908
+ g: 1,
909
+ t: 1e3,
910
+ p: 1e6,
911
+ e: 1e9
912
+ };
913
+ function toGH(value, unit = "") {
914
+ const v = formatToNum(value);
915
+ if (!isNum(v)) {
916
+ return 0;
917
+ }
918
+ const u = normalizeUnit(unit);
919
+ const c = u ? u[0] : "g";
920
+ const factor = FACTOR[c] ?? 1;
921
+ const out = v * factor;
922
+ if (!isNum(out)) {
923
+ throw new Error(`toGH: result is not finite (value="${v}", unit="${u}")`);
924
+ }
925
+ return Object.is(out, -0) ? 0 : out;
926
+ }
927
+
928
+ // src/units/toH.ts
929
+ var FACTOR_H = {
930
+ h: 1,
931
+ k: 1e3,
932
+ m: 1e6,
933
+ g: 1e9,
934
+ t: 1e12,
935
+ p: 1e15,
936
+ e: 1e18
937
+ };
938
+ function toH(value, unit = "") {
939
+ const v = formatToNum(value);
940
+ if (!isNum(v)) {
941
+ return 0;
942
+ }
943
+ const u = normalizeUnit(unit);
944
+ const c = u ? u[0] : "h";
945
+ const factor = FACTOR_H[c] ?? 1;
946
+ const out = v * factor;
947
+ if (!isNum(out)) {
948
+ throw new Error(`toH: result is not finite (value="${v}", unit="${u}")`);
949
+ }
950
+ return Object.is(out, -0) ? 0 : out;
951
+ }
952
+
953
+ // src/url/extractHost.ts
954
+ var HAS_SCHEME = /^[a-zA-Z][a-zA-Z\d+\-.]*:/;
955
+ function extractHost(value = "") {
956
+ if (!isStrFilled(value)) {
957
+ return "";
958
+ }
959
+ let v = value.trim();
960
+ const candidate = HAS_SCHEME.test(v) ? v : `http://${v}`;
961
+ try {
962
+ const u = new URL(candidate);
963
+ let host = u.hostname;
964
+ return host;
965
+ } catch {
966
+ const withoutCreds = v.split("@").pop() || v;
967
+ const firstSegment = withoutCreds.split(/[/?#]/, 1)[0];
968
+ const mIPv6 = firstSegment.match(/^\[([^\]]+)\]/);
969
+ if (mIPv6) {
970
+ return mIPv6[1];
971
+ }
972
+ return firstSegment.split(":", 1)[0] || "";
973
+ }
974
+ }
975
+
976
+ export { changeFixedDecimalScale, cidrToRange, convertExponentialToParts, extractHost, fixedDecimalToNum, fixedDecimalToStr, floorDateToMinutes, formatDateToString, formatStrToFuncArgs, formatToBool, formatToLowerCase, formatToNull, formatToNum, formatToPhone, formatToTrim, formatToUndefined2 as formatToUndefined, ipAddrToNum, isArr, isArrFilled, isBool, isDate, isEmail, isExists, isFunc, isIpAddr, isMacAddr, isNum, isNumFloat, isNumN, isNumNZ, isNumP, isNumPZ, isObj, isObjFilled, isPassword, isPhone, isStr, isStrAscDesc, isStrBool, isStrFilled, isVar, jsonDecode, jsonEncode2 as jsonEncode, normalizeToDecimalComponents, numToIpAddr, parseIPv4, parseStringLike, parseToFixedDecimal, partsToSeconds, rangeIPv4, rangeIPv4ToArr2 as rangeIPv4ToArr, roundFixedDecimal, secondsToParts, splitArrToPortions, toGB, toGH, toH, toIPv4, tryParseJSON, wait };
977
+ //# sourceMappingURL=index.js.map
100
978
  //# sourceMappingURL=index.js.map