@rzl-zone/utils-js 3.4.0 → 3.5.1

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 (118) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +94 -45
  3. package/dist/assertions/index.cjs +41 -1
  4. package/dist/assertions/index.d.ts +11 -2
  5. package/dist/assertions/index.js +14 -1
  6. package/dist/chunk-2CQX5CBG.js +262 -1
  7. package/dist/chunk-2IOOEY45.cjs +30 -1
  8. package/dist/chunk-2WA36TC5.cjs +189 -0
  9. package/dist/chunk-3IBQ5MOM.js +16 -1
  10. package/dist/chunk-3VA554KW.js +34 -1
  11. package/dist/chunk-5757UBXJ.cjs +157 -1
  12. package/dist/chunk-5IGC6PBH.js +33 -1
  13. package/dist/chunk-5KJFVIQT.cjs +65 -1
  14. package/dist/chunk-6JFCSH7J.js +35 -1
  15. package/dist/chunk-6JFZL7YE.cjs +24 -1
  16. package/dist/chunk-7ODAAXX5.cjs +397 -1
  17. package/dist/chunk-BAV5T2E3.cjs +15 -1
  18. package/dist/chunk-CAH33WOQ.cjs +36 -1
  19. package/dist/chunk-CDCERIZ2.js +177 -0
  20. package/dist/chunk-CKTLUNWX.js +22 -1
  21. package/dist/chunk-CMW2TBOQ.js +567 -1
  22. package/dist/chunk-D3ENH7H6.cjs +101 -1
  23. package/dist/chunk-DEZZUYE2.js +152 -1
  24. package/dist/chunk-DVMHRLKP.cjs +16 -1
  25. package/dist/chunk-DWF2R5GD.cjs +225 -1
  26. package/dist/chunk-E55EQK2U.cjs +18 -1
  27. package/dist/chunk-E74U6CYP.cjs +18 -1
  28. package/dist/chunk-EL6A35UR.cjs +64 -1
  29. package/dist/chunk-F6IPNNSJ.cjs +554 -1
  30. package/dist/chunk-FJZGG54N.cjs +267 -1
  31. package/dist/chunk-FWCKOJZM.js +542 -1
  32. package/dist/chunk-FWHNWL2P.cjs +419 -1
  33. package/dist/chunk-GGEADHZO.js +90 -1
  34. package/dist/chunk-GQR4R5WY.js +31 -1
  35. package/dist/chunk-H66AC7GK.cjs +93 -1
  36. package/dist/chunk-HQWOFR56.cjs +33 -1
  37. package/dist/chunk-HYRQMTRH.cjs +24 -1
  38. package/dist/chunk-IRFL4MAX.js +63 -1
  39. package/dist/chunk-IVL7CKVH.cjs +37 -1
  40. package/dist/chunk-IZPBKKPO.js +16 -1
  41. package/dist/chunk-JBQMXC5I.cjs +106 -1
  42. package/dist/chunk-JEQEF5WD.js +95 -1
  43. package/dist/chunk-JMJQCN74.js +370 -1
  44. package/dist/chunk-KHO2SBNA.cjs +16 -1
  45. package/dist/chunk-KVAL5PAG.cjs +26 -1
  46. package/dist/chunk-L5RDAVVH.js +14 -1
  47. package/dist/chunk-LS6U7FAY.cjs +110 -1
  48. package/dist/chunk-NBZWMBO6.js +101 -1
  49. package/dist/chunk-NRF6LWBC.cjs +56 -1
  50. package/dist/chunk-OI5XKNZO.js +53 -1
  51. package/dist/chunk-ONZFBJVW.js +14 -1
  52. package/dist/chunk-OYTYSY7G.js +106 -1
  53. package/dist/chunk-PET42Z7W.js +119 -1
  54. package/dist/chunk-PZQ6I4JJ.cjs +605 -1
  55. package/dist/chunk-QBKAEVYG.js +113 -1
  56. package/dist/chunk-QNKGP5DY.js +14 -1
  57. package/dist/chunk-RIPKY4RU.js +417 -1
  58. package/dist/chunk-RZW35UN5.cjs +116 -1
  59. package/dist/chunk-SBFNXGTJ.js +220 -1
  60. package/dist/chunk-SBKGWRS5.js +22 -1
  61. package/dist/chunk-SIM77PU4.js +59 -1
  62. package/dist/chunk-T2T7K3KR.js +28 -1
  63. package/dist/chunk-T7PU2V7X.cjs +123 -1
  64. package/dist/chunk-UDA26MCU.cjs +16 -1
  65. package/dist/chunk-V45XJKHW.cjs +18 -1
  66. package/dist/chunk-VJDDGRIK.cjs +16 -1
  67. package/dist/chunk-W2WNBUDE.js +16 -1
  68. package/dist/chunk-WVSPXFTY.js +14 -1
  69. package/dist/chunk-XABCB3Y7.cjs +582 -1
  70. package/dist/chunk-XEDXFSGI.js +24 -1
  71. package/dist/chunk-YKPSRP5G.js +571 -1
  72. package/dist/chunk-YWHHVDT4.js +13 -1
  73. package/dist/chunk-ZETAZZLD.cjs +38 -1
  74. package/dist/conversions/index.cjs +104 -1
  75. package/dist/conversions/index.d.ts +10 -1
  76. package/dist/conversions/index.js +25 -1
  77. package/dist/events/index.cjs +32 -1
  78. package/dist/events/index.d.ts +10 -1
  79. package/dist/events/index.js +13 -1
  80. package/dist/formatters/index.cjs +62 -1
  81. package/dist/formatters/index.d.ts +10 -1
  82. package/dist/formatters/index.js +19 -1
  83. package/dist/generators/index.cjs +38 -1
  84. package/dist/generators/index.d.ts +10 -1
  85. package/dist/generators/index.js +15 -1
  86. package/dist/index.d.ts +39 -12
  87. package/dist/{isPlainObject-CEPWPiXh.d.ts → isPlainObject-FWmcJF6k.d.ts} +13 -4
  88. package/dist/next/index.cjs +218 -1
  89. package/dist/next/index.d.ts +10 -1
  90. package/dist/next/index.js +213 -1
  91. package/dist/next/server/index.cjs +43 -1
  92. package/dist/next/server/index.d.ts +10 -1
  93. package/dist/next/server/index.js +41 -1
  94. package/dist/operations/index.cjs +33 -1
  95. package/dist/operations/index.d.ts +10 -1
  96. package/dist/operations/index.js +18 -1
  97. package/dist/parsers/index.cjs +18 -1
  98. package/dist/parsers/index.d.ts +10 -1
  99. package/dist/parsers/index.js +11 -1
  100. package/dist/predicates/index.cjs +299 -1
  101. package/dist/predicates/index.d.ts +13 -4
  102. package/dist/predicates/index.js +24 -1
  103. package/dist/promises/index.cjs +25 -1
  104. package/dist/promises/index.d.ts +10 -1
  105. package/dist/promises/index.js +14 -1
  106. package/dist/rzl-utils.global.js +25 -1
  107. package/dist/strings/index.cjs +82 -1
  108. package/dist/strings/index.d.ts +10 -1
  109. package/dist/strings/index.js +15 -1
  110. package/dist/tailwind/index.cjs +43 -1
  111. package/dist/tailwind/index.d.ts +10 -1
  112. package/dist/tailwind/index.js +12 -1
  113. package/dist/urls/index.cjs +51 -1
  114. package/dist/urls/index.d.ts +10 -1
  115. package/dist/urls/index.js +24 -1
  116. package/package.json +60 -179
  117. package/dist/chunk-JYQTCICM.js +0 -1
  118. package/dist/chunk-YLA3DURS.cjs +0 -1
@@ -1 +1,24 @@
1
- "use strict";var r=require("./chunk-PZQ6I4JJ.cjs");exports.assertIsString=(e,s={})=>{if(r.isString(e))return;const t=r.resolveErrorMessageAssertions({value:e,options:s,requiredValidType:"string"});throw new TypeError(t)};
1
+ /*!
2
+ * ====================================================
3
+ * Rzl Utils-JS.
4
+ * ----------------------------------------------------
5
+ * Version: 3.5.1.
6
+ * Author: Rizalvin Dwiky.
7
+ * Repository: https://github.com/rzl-zone/utils-js.
8
+ * ====================================================
9
+ */
10
+ 'use strict';
11
+
12
+ var chunkPZQ6I4JJ_cjs = require('./chunk-PZQ6I4JJ.cjs');
13
+
14
+ var assertIsString = (value, options = {}) => {
15
+ if (chunkPZQ6I4JJ_cjs.isString(value)) return;
16
+ const errorMessage = chunkPZQ6I4JJ_cjs.resolveErrorMessageAssertions({
17
+ value,
18
+ options,
19
+ requiredValidType: "string"
20
+ });
21
+ throw new TypeError(errorMessage);
22
+ };
23
+
24
+ exports.assertIsString = assertIsString;
@@ -1 +1,63 @@
1
- import{isNonEmptyString as e}from"./chunk-CMW2TBOQ.js";var l=l=>{if(!e(l))return 0;let c=l.trim().replace(/\u00A0/g,"").replace(/\u202F/g,""),s=!1;/^\(.*\)$/.test(c)&&(s=!0,c=c.slice(1,-1).trim()),c=c.replace(/^[-\s]+/,e=>e.includes("-")?"-":"").replace(/[\s.,-]+$/,""),s=s||/^-/.test(c)||/^[^\d]*-/.test(c);let r=c.replace(/[^0-9.,'\s]/g,"").replace(/[\s']/g,"");const t=r.match(/,\d{2}/g);if(t&&t.length>1)r=r.replace(/,/g,"");else{const e=(r.match(/\./g)||[]).length,l=(r.match(/,/g)||[]).length;if(e>1&&0===l)r=r.replace(/\./g,"");else if(l>1&&0===e)r=r.replace(/,/g,"");else{const e=r.lastIndexOf(","),l=r.lastIndexOf(".");if(e>l)r=r.replace(/\./g,"").replace(",",".");else if(l>e)r=r.replace(/,/g,"");else if(e>l){const l=r.slice(0,e).replace(/,/g,"").replace(/\./g,""),c=r.slice(e+1);r=l+"."+c}else if(l>e){const e=r.slice(0,l).replace(/\./g,"").replace(/,/g,""),c=r.slice(l+1);r=e+"."+c}else-1!==e?r=r.replace(/,/g,""):-1!==l&&(r=r.replace(/\./g,""))}}const a=parseFloat(r)||0;return s?-a:a};export{l as parseCurrencyString};
1
+ /*!
2
+ * ====================================================
3
+ * Rzl Utils-JS.
4
+ * ----------------------------------------------------
5
+ * Version: 3.5.1.
6
+ * Author: Rizalvin Dwiky.
7
+ * Repository: https://github.com/rzl-zone/utils-js.
8
+ * ====================================================
9
+ */
10
+ import { isNonEmptyString } from './chunk-CMW2TBOQ.js';
11
+
12
+ var parseCurrencyString = (input) => {
13
+ if (!isNonEmptyString(input)) return 0;
14
+ let trimmed = input.trim().replace(/\u00A0/g, "").replace(/\u202F/g, "");
15
+ let isNegative = false;
16
+ if (/^\(.*\)$/.test(trimmed)) {
17
+ isNegative = true;
18
+ trimmed = trimmed.slice(1, -1).trim();
19
+ }
20
+ trimmed = trimmed.replace(/^[-\s]+/, (match) => match.includes("-") ? "-" : "").replace(/[\s.,-]+$/, "");
21
+ isNegative = isNegative || /^-/.test(trimmed) || /^[^\d]*-/.test(trimmed);
22
+ const cleaned = trimmed.replace(/[^0-9.,'\s]/g, "");
23
+ let cleanedNoSpace = cleaned.replace(/[\s']/g, "");
24
+ const indianMatches = cleanedNoSpace.match(/,\d{2}/g);
25
+ const isIndianStyle = indianMatches && indianMatches.length > 1;
26
+ if (isIndianStyle) {
27
+ cleanedNoSpace = cleanedNoSpace.replace(/,/g, "");
28
+ } else {
29
+ const dotCount = (cleanedNoSpace.match(/\./g) || []).length;
30
+ const commaCount = (cleanedNoSpace.match(/,/g) || []).length;
31
+ if (dotCount > 1 && commaCount === 0) {
32
+ cleanedNoSpace = cleanedNoSpace.replace(/\./g, "");
33
+ } else if (commaCount > 1 && dotCount === 0) {
34
+ cleanedNoSpace = cleanedNoSpace.replace(/,/g, "");
35
+ } else {
36
+ const lastComma = cleanedNoSpace.lastIndexOf(",");
37
+ const lastDot = cleanedNoSpace.lastIndexOf(".");
38
+ if (lastComma > lastDot) {
39
+ cleanedNoSpace = cleanedNoSpace.replace(/\./g, "").replace(",", ".");
40
+ } else if (lastDot > lastComma) {
41
+ cleanedNoSpace = cleanedNoSpace.replace(/,/g, "");
42
+ } else {
43
+ if (lastComma > lastDot) {
44
+ const beforeDecimal = cleanedNoSpace.slice(0, lastComma).replace(/,/g, "").replace(/\./g, "");
45
+ const afterDecimal = cleanedNoSpace.slice(lastComma + 1);
46
+ cleanedNoSpace = beforeDecimal + "." + afterDecimal;
47
+ } else if (lastDot > lastComma) {
48
+ const beforeDecimal = cleanedNoSpace.slice(0, lastDot).replace(/\./g, "").replace(/,/g, "");
49
+ const afterDecimal = cleanedNoSpace.slice(lastDot + 1);
50
+ cleanedNoSpace = beforeDecimal + "." + afterDecimal;
51
+ } else if (lastComma !== -1) {
52
+ cleanedNoSpace = cleanedNoSpace.replace(/,/g, "");
53
+ } else if (lastDot !== -1) {
54
+ cleanedNoSpace = cleanedNoSpace.replace(/\./g, "");
55
+ }
56
+ }
57
+ }
58
+ }
59
+ const num = parseFloat(cleanedNoSpace) || 0;
60
+ return isNegative ? -num : num;
61
+ };
62
+
63
+ export { parseCurrencyString };
@@ -1 +1,37 @@
1
- "use strict";var r=require("./chunk-UDA26MCU.cjs"),e=require("./chunk-PZQ6I4JJ.cjs");exports.assertIsBigInt=(s,i={})=>{if(r.isBigInt(s))return;const n=e.resolveErrorMessageAssertions({value:s,options:i,requiredValidType:"big int"});throw new TypeError(n)},exports.assertIsNumber=(r,s={})=>{const i=e.hasOwnProp(s,"includeNaN")?s.includeNaN:void 0;if(e.isNumber(r,{includeNaN:i}))return;const n=e.resolveErrorMessageAssertions({value:r,options:s,requiredValidType:"number"});throw new TypeError(n)};
1
+ /*!
2
+ * ====================================================
3
+ * Rzl Utils-JS.
4
+ * ----------------------------------------------------
5
+ * Version: 3.5.1.
6
+ * Author: Rizalvin Dwiky.
7
+ * Repository: https://github.com/rzl-zone/utils-js.
8
+ * ====================================================
9
+ */
10
+ 'use strict';
11
+
12
+ var chunkUDA26MCU_cjs = require('./chunk-UDA26MCU.cjs');
13
+ var chunkPZQ6I4JJ_cjs = require('./chunk-PZQ6I4JJ.cjs');
14
+
15
+ var assertIsBigInt = (value, options = {}) => {
16
+ if (chunkUDA26MCU_cjs.isBigInt(value)) return;
17
+ const errorMessage = chunkPZQ6I4JJ_cjs.resolveErrorMessageAssertions({
18
+ value,
19
+ options,
20
+ requiredValidType: "big int"
21
+ });
22
+ throw new TypeError(errorMessage);
23
+ };
24
+
25
+ var assertIsNumber = (value, options = {}) => {
26
+ const includeNaN = chunkPZQ6I4JJ_cjs.hasOwnProp(options, "includeNaN") ? options.includeNaN : void 0;
27
+ if (chunkPZQ6I4JJ_cjs.isNumber(value, { includeNaN })) return;
28
+ const errorMessage = chunkPZQ6I4JJ_cjs.resolveErrorMessageAssertions({
29
+ value,
30
+ options,
31
+ requiredValidType: "number"
32
+ });
33
+ throw new TypeError(errorMessage);
34
+ };
35
+
36
+ exports.assertIsBigInt = assertIsBigInt;
37
+ exports.assertIsNumber = assertIsNumber;
@@ -1 +1,16 @@
1
- import{isNonEmptyString as r}from"./chunk-CMW2TBOQ.js";var m=m=>r(m)?m.trim():"";export{m as normalizeString};
1
+ /*!
2
+ * ====================================================
3
+ * Rzl Utils-JS.
4
+ * ----------------------------------------------------
5
+ * Version: 3.5.1.
6
+ * Author: Rizalvin Dwiky.
7
+ * Repository: https://github.com/rzl-zone/utils-js.
8
+ * ====================================================
9
+ */
10
+ import { isNonEmptyString } from './chunk-CMW2TBOQ.js';
11
+
12
+ var normalizeString = (input) => {
13
+ return isNonEmptyString(input) ? input.trim() : "";
14
+ };
15
+
16
+ export { normalizeString };
@@ -1 +1,106 @@
1
- "use strict";var e=require("./chunk-T7PU2V7X.cjs"),r=require("./chunk-PZQ6I4JJ.cjs"),t=e=>e instanceof RegExp;function n(e){return e instanceof ArrayBuffer}function i(f,s,u,o=new WeakMap){if(f===s)return!0;if(f!=f&&s!=s)return!0;if(!r.isObjectOrArray(f)||!r.isObjectOrArray(s))return!1;if(o.get(f)===s)return!0;o.set(f,s);const a=(e,t,n,f,s)=>{if(u){const i=u(e,t,n,f,s,o);if(!r.isUndefined(i))return i}return i(e,t,u,o)};if(e.isDate(f)&&e.isDate(s))return f.getTime()===s.getTime();if(t(f)&&t(s))return f.source===s.source&&f.flags===s.flags;if(r.isError(f)&&r.isError(s))return f.name===s.name&&f.message===s.message;if(ArrayBuffer.isView(f)&&ArrayBuffer.isView(s)){const e=new Uint8Array(f.buffer,f.byteOffset,f.byteLength),r=new Uint8Array(s.buffer,s.byteOffset,s.byteLength);if(e.length!==r.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==r[t])return!1;return!0}if(n(f)&&n(s)){if(f.byteLength!==s.byteLength)return!1;const e=new Uint8Array(f),r=new Uint8Array(s);for(let t=0;t<e.length;t++)if(e[t]!==r[t])return!1;return!0}if(e.isMap(f)&&e.isMap(s)){if(f.size!==s.size)return!1;for(const[e,r]of f){if(!s.has(e))return!1;if(!i(r,s.get(e),u,o))return!1}return!0}if(r.isSet(f)&&r.isSet(s)){if(f.size!==s.size)return!1;for(const e of f){let r=!1;for(const t of s)if(i(e,t,u,o)){r=!0;break}if(!r)return!1}return!0}if(r.isArray(f)&&r.isArray(s)){if(f.length!==s.length)return!1;for(let e=0;e<f.length;e++)if(!a(f[e],s[e],e,f,s))return!1;return!0}if(Object.getPrototypeOf(f)!==Object.getPrototypeOf(s))return!1;const c=Reflect.ownKeys(f),g=Reflect.ownKeys(s);if(c.length!==g.length)return!1;for(const e of c){if(!a(f[e],s[e],e,f,s))return!1}return!0}exports.baseDeepEqual=i,exports.isArrayBuffer=n,exports.isEqual=function(e,r){return i(e,r,void 0,new WeakMap)},exports.isRegExp=t;
1
+ /*!
2
+ * ====================================================
3
+ * Rzl Utils-JS.
4
+ * ----------------------------------------------------
5
+ * Version: 3.5.1.
6
+ * Author: Rizalvin Dwiky.
7
+ * Repository: https://github.com/rzl-zone/utils-js.
8
+ * ====================================================
9
+ */
10
+ 'use strict';
11
+
12
+ var chunkT7PU2V7X_cjs = require('./chunk-T7PU2V7X.cjs');
13
+ var chunkPZQ6I4JJ_cjs = require('./chunk-PZQ6I4JJ.cjs');
14
+
15
+ var isRegExp = (value) => {
16
+ return value instanceof RegExp;
17
+ };
18
+
19
+ function isArrayBuffer(value) {
20
+ return value instanceof ArrayBuffer;
21
+ }
22
+
23
+ function baseDeepEqual(value, other, customizer, seen = /* @__PURE__ */ new WeakMap()) {
24
+ if (value === other) return true;
25
+ if (value !== value && other !== other) return true;
26
+ if (!chunkPZQ6I4JJ_cjs.isObjectOrArray(value) || !chunkPZQ6I4JJ_cjs.isObjectOrArray(other)) {
27
+ return false;
28
+ }
29
+ if (seen.get(value) === other) return true;
30
+ seen.set(value, other);
31
+ const callCustomizer = (v, o, key, valObj, othObj) => {
32
+ if (customizer) {
33
+ const result = customizer(v, o, key, valObj, othObj, seen);
34
+ if (!chunkPZQ6I4JJ_cjs.isUndefined(result)) return result;
35
+ }
36
+ return baseDeepEqual(v, o, customizer, seen);
37
+ };
38
+ if (chunkT7PU2V7X_cjs.isDate(value) && chunkT7PU2V7X_cjs.isDate(other)) return value.getTime() === other.getTime();
39
+ if (isRegExp(value) && isRegExp(other))
40
+ return value.source === other.source && value.flags === other.flags;
41
+ if (chunkPZQ6I4JJ_cjs.isError(value) && chunkPZQ6I4JJ_cjs.isError(other))
42
+ return value.name === other.name && value.message === other.message;
43
+ if (ArrayBuffer.isView(value) && ArrayBuffer.isView(other)) {
44
+ const v = new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
45
+ const o = new Uint8Array(other.buffer, other.byteOffset, other.byteLength);
46
+ if (v.length !== o.length) return false;
47
+ for (let i = 0; i < v.length; i++) if (v[i] !== o[i]) return false;
48
+ return true;
49
+ }
50
+ if (isArrayBuffer(value) && isArrayBuffer(other)) {
51
+ if (value.byteLength !== other.byteLength) return false;
52
+ const v = new Uint8Array(value), o = new Uint8Array(other);
53
+ for (let i = 0; i < v.length; i++) if (v[i] !== o[i]) return false;
54
+ return true;
55
+ }
56
+ if (chunkT7PU2V7X_cjs.isMap(value) && chunkT7PU2V7X_cjs.isMap(other)) {
57
+ if (value.size !== other.size) return false;
58
+ for (const [k, v] of value) {
59
+ if (!other.has(k)) return false;
60
+ if (!baseDeepEqual(v, other.get(k), customizer, seen)) return false;
61
+ }
62
+ return true;
63
+ }
64
+ if (chunkPZQ6I4JJ_cjs.isSet(value) && chunkPZQ6I4JJ_cjs.isSet(other)) {
65
+ if (value.size !== other.size) return false;
66
+ for (const v of value) {
67
+ let matched = false;
68
+ for (const o of other) {
69
+ if (baseDeepEqual(v, o, customizer, seen)) {
70
+ matched = true;
71
+ break;
72
+ }
73
+ }
74
+ if (!matched) return false;
75
+ }
76
+ return true;
77
+ }
78
+ if (chunkPZQ6I4JJ_cjs.isArray(value) && chunkPZQ6I4JJ_cjs.isArray(other)) {
79
+ if (value.length !== other.length) return false;
80
+ for (let i = 0; i < value.length; i++) {
81
+ if (!callCustomizer(value[i], other[i], i, value, other)) return false;
82
+ }
83
+ return true;
84
+ }
85
+ if (Object.getPrototypeOf(value) !== Object.getPrototypeOf(other)) {
86
+ return false;
87
+ }
88
+ const vKeys = Reflect.ownKeys(value);
89
+ const oKeys = Reflect.ownKeys(other);
90
+ if (vKeys.length !== oKeys.length) return false;
91
+ for (const key of vKeys) {
92
+ const vVal = value[key];
93
+ const oVal = other[key];
94
+ if (!callCustomizer(vVal, oVal, key, value, other)) return false;
95
+ }
96
+ return true;
97
+ }
98
+
99
+ function isEqual(value, other) {
100
+ return baseDeepEqual(value, other, void 0, /* @__PURE__ */ new WeakMap());
101
+ }
102
+
103
+ exports.baseDeepEqual = baseDeepEqual;
104
+ exports.isArrayBuffer = isArrayBuffer;
105
+ exports.isEqual = isEqual;
106
+ exports.isRegExp = isRegExp;
@@ -1 +1,95 @@
1
- import{isEmptyString as e}from"./chunk-W2WNBUDE.js";import{isNonEmptyString as r,isPlainObject as t,isString as i,isNumber as s,getPreciseType as a}from"./chunk-CMW2TBOQ.js";var n=(e,i={lowerCaseNextRest:!0,trim:!1})=>{if(!r(e))return"";t(i)||(i={});const s=!1!==i.lowerCaseNextRest;return!0===i.trim&&(e=e.trim()),e[0].toUpperCase()+(s?e.slice(1).toLowerCase():e.slice(1))},o=(e,i={collapseSpaces:!1,trim:!1})=>{if(!r(e))return"";let s=e;t(i)||(i={});const a=!0===i.collapseSpaces;if(!0===i.trim&&(s=s.trim()),a){const e=s.match(/^\s*/)?.[0]??"",r=s.match(/\s*$/)?.[0]??"";s=s.trim().replace(/\s+/g," "),s=`${e}${s}${r}`}return s.toLowerCase().split(" ").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")};function p(r){if(!i(r))return;if(e(r))return"";return r.replace(/<\/?[a-zA-Z][^<>]*\/?>/g," ").trim().replace(/\s+/g," ").trim()}var c=e=>{if(!r(e))return"";const t=(e=e.replace(/\s+/g," ").trim()).split(" ");return t.length>1?t[0][0]+t[1][0].toUpperCase():e.length>1?e.substring(0,2).toUpperCase():e[0].toUpperCase()},l=(e,r,t)=>{if(!s(e)||!i(t)||!i(r))throw new TypeError(`First parameter (\`index\`) must be of type \`number\`, second parameter (\`originalString\`) and third parameter (\`replaceTo\`) must be of type \`string\`, but received: "['index': \`${a(e)}\`, 'originalString': \`${a(r)}\`, 'replaceTo': \`${a(t)}\`]".`);if(e<0||e>=r.length)throw new RangeError("First parameter (`index`) is out of range from second parameter (`originalString`).");return r.slice(0,e)+t+r.slice(e+1)};export{n as capitalizeFirst,o as capitalizeWords,c as getInitialsName,l as replaceAt,p as stripHtmlTags};
1
+ /*!
2
+ * ====================================================
3
+ * Rzl Utils-JS.
4
+ * ----------------------------------------------------
5
+ * Version: 3.5.1.
6
+ * Author: Rizalvin Dwiky.
7
+ * Repository: https://github.com/rzl-zone/utils-js.
8
+ * ====================================================
9
+ */
10
+ import { isEmptyString } from './chunk-W2WNBUDE.js';
11
+ import { isNonEmptyString, isPlainObject, isString, isNumber, getPreciseType } from './chunk-CMW2TBOQ.js';
12
+
13
+ var capitalizeFirst = (string, options = {
14
+ lowerCaseNextRest: true,
15
+ trim: false
16
+ }) => {
17
+ if (!isNonEmptyString(string)) return "";
18
+ if (!isPlainObject(options)) {
19
+ options = {};
20
+ }
21
+ const lowerCaseNextRest = options.lowerCaseNextRest !== false;
22
+ const trim = options.trim === true;
23
+ if (trim) string = string.trim();
24
+ return string[0].toUpperCase() + (lowerCaseNextRest ? string.slice(1).toLowerCase() : string.slice(1));
25
+ };
26
+
27
+ var capitalizeWords = (value, options = {
28
+ collapseSpaces: false,
29
+ trim: false
30
+ }) => {
31
+ if (!isNonEmptyString(value)) return "";
32
+ let result = value;
33
+ if (!isPlainObject(options)) {
34
+ options = {};
35
+ }
36
+ const collapseSpaces = options.collapseSpaces === true;
37
+ const trim = options.trim === true;
38
+ if (trim) {
39
+ result = result.trim();
40
+ }
41
+ if (collapseSpaces) {
42
+ const leadingSpaces = result.match(/^\s*/)?.[0] ?? "";
43
+ const trailingSpaces = result.match(/\s*$/)?.[0] ?? "";
44
+ result = result.trim().replace(/\s+/g, " ");
45
+ result = `${leadingSpaces}${result}${trailingSpaces}`;
46
+ }
47
+ return result.toLowerCase().split(" ").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
48
+ };
49
+
50
+ function stripHtmlTags(input) {
51
+ if (!isString(input)) {
52
+ return void 0;
53
+ }
54
+ if (isEmptyString(input)) {
55
+ return "";
56
+ }
57
+ const stripped = input.replace(/<\/?[a-zA-Z][^<>]*\/?>/g, " ").trim();
58
+ const cleaned = stripped.replace(/\s+/g, " ").trim();
59
+ return cleaned;
60
+ }
61
+
62
+ var getInitialsName = (name) => {
63
+ if (!isNonEmptyString(name)) return "";
64
+ name = name.replace(/\s+/g, " ").trim();
65
+ const nameParts = name.split(" ");
66
+ if (nameParts.length > 1) {
67
+ return nameParts[0][0] + nameParts[1][0].toUpperCase();
68
+ }
69
+ return name.length > 1 ? name.substring(0, 2).toUpperCase() : (
70
+ // First two letters for single-word names
71
+ name[0].toUpperCase()
72
+ );
73
+ };
74
+
75
+ var replaceAt = (index, originalString, replaceTo) => {
76
+ if (!isNumber(index) || !isString(replaceTo) || !isString(originalString)) {
77
+ throw new TypeError(
78
+ `First parameter (\`index\`) must be of type \`number\`, second parameter (\`originalString\`) and third parameter (\`replaceTo\`) must be of type \`string\`, but received: "['index': \`${getPreciseType(
79
+ index
80
+ )}\`, 'originalString': \`${getPreciseType(
81
+ originalString
82
+ )}\`, 'replaceTo': \`${getPreciseType(replaceTo)}\`]".`
83
+ );
84
+ }
85
+ if (index < 0 || index >= originalString.length) {
86
+ throw new RangeError(
87
+ `First parameter (\`index\`) is out of range from second parameter (\`originalString\`).`
88
+ );
89
+ }
90
+ return originalString.slice(0, index) + // Extract before the index
91
+ replaceTo + // Insert replacement
92
+ originalString.slice(index + 1);
93
+ };
94
+
95
+ export { capitalizeFirst, capitalizeWords, getInitialsName, replaceAt, stripHtmlTags };