@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,542 @@
1
- import{isNonEmptyValue as e,isTypedArray as r}from"./chunk-5IGC6PBH.js";import{filterNilArray as t}from"./chunk-OI5XKNZO.js";import{isEmptyString as o}from"./chunk-W2WNBUDE.js";import{assertIsString as n}from"./chunk-SBKGWRS5.js";import{isRegExp as i,isEqual as m}from"./chunk-NBZWMBO6.js";import{isEmptyObject as s,isEmptyArray as a}from"./chunk-6JFCSH7J.js";import{assertIsArray as p}from"./chunk-CKTLUNWX.js";import{safeStableStringify as u,isDate as c,isMap as f}from"./chunk-PET42Z7W.js";import{isBigInt as y}from"./chunk-QNKGP5DY.js";import{assertIsPlainObject as l,hasOwnProp as v,assertIsBoolean as b,isArray as d,isNull as E,getPreciseType as g,isNaN as O,isString as j,isNumber as h,isBoolean as A,isNil as S,isNumberObject as T,isBooleanObject as $,isStringObject as N,isSymbol as k,isFunction as w,isObjectOrArray as R,isError as I,isSet as P,isObject as B,isNonEmptyString as C,isPlainObject as D,isUndefined as W,isInfinityNumber as M,isBuffer as J}from"./chunk-CMW2TBOQ.js";function K(e,r={}){l(r,{message:({currentType:e,validType:r})=>`Second parameter (\`options\`) must be of type \`${r}\`, but received: \`${e}\`.`});const o=!v(r,"removeInvalidValueNumber")||r.removeInvalidValueNumber;if(b(o,{message:({currentType:e,validType:r})=>`Parameter \`removeInvalidValueNumber\` property of the \`options\` (second parameter) must be of type \`${r}\`, but received: \`${e}\`.`}),d(e)){const r=Array.from(e,e=>{if(y(e))return Number(e);const r=String(e).trim().match(/-?\d+(\.\d+)?/);return r?Number(r[0]):E(e)?null:void 0});return o?t(r):r}}function U(e,r){if(!1!==r&&"stringOrNumber"!==r&&"primitives"!==r&&"all"!==r)throw new TypeError(`Second parameter \`forceToString\` must be of type \`false\` or \`string\` with value one of "stringOrNumber" | "primitives" | "all", but received: \`${g(r)}\`, with value: \`${u(r)}\`.`);if(O(e))return"primitives"===r||"all"===r?"NaN":NaN;if(j(e)||h(e))return"stringOrNumber"===r||"primitives"===r||"all"===r?String(e):e;if(A(e)||y(e)||S(e))return"primitives"===r||"all"===r?String(e):e;if(T(e)||$(e)||N(e))return"all"===r?e.valueOf().toString():e;if(k(e))return"all"===r?e.toString():e;if(w(e))return"all"===r?e.toString():e;if(d(e))return e.map(e=>U(e,r));if(R(e)){if(c(e))return"all"===r?e.toISOString():e;if(i(e))return"all"===r?e.toString():e;if(I(e)||e instanceof Promise)return"all"===r?e.toString():e;if(P(e))return"all"===r?[...e].map(e=>U(e,r)):e;if(f(e))return"all"===r?[...e.entries()].map(([e,t])=>[U(e,r),U(t,r)]):e;const t={};if(B(e))for(const o of Object.keys(e))t[o]=U(e[o],r);return t}return e}var G=(e,r={})=>{p(e,{message:({currentType:e,validType:r})=>`First parameter (\`inputArray\`) must be of type \`${r}\` (array literal or instance), but received: \`${e}\`.`}),l(r,{message:({currentType:e,validType:r})=>`Second parameter (\`options\`) must be of type \`${r}\`, but received: \`${e}\`.`});const t=!!v(r,"flatten")&&r.flatten,o=!!v(r,"forceToString")&&r.forceToString;if(!1!==o&&"stringOrNumber"!==o&&"primitives"!==o&&"all"!==o)throw new TypeError(`Parameter \`forceToString\` property of the \`options\` (second parameter) must be of type \`false\` or \`string\` with value one of "stringOrNumber" | "primitives" | "all", but received: \`${g(o)}\`, with value: \`${u(o)}\`.`);b(t,{message:({currentType:e,validType:r})=>`Parameter \`flatten\` property of the \`options\` (second parameter) must be of type \`${r}\`, but received: \`${e}\`.`});const n=e=>{const r=[];return e.reduce((e,t)=>{const i=d(t)?n(t):U(t,o);return r.some(e=>m(e,i))||(r.push(i),e.push(i)),e},[])},i=e=>d(e)?e.flatMap(i):P(e)?[...e].flatMap(i):f(e)?[...e.values()].flatMap(i):[e];return n(t?i(e):e)},L=r=>!S(r)&&(j(r)?C(r):A(r)?r:h(r,{includeNaN:!0})?0!==r:d(r)||B(r)?e(r):Boolean(r)),V=e=>!S(e)&&(j(e)?C(e):A(e)?e:h(e,{includeNaN:!0})?0!==e:d(e)?e.some(V):!!B(e)&&Object.values(e).some(V)),Z=(e,r={})=>{if(S(e))return!1;D(r)||(r={});const t=!!v(r,"caseInsensitive")&&r.caseInsensitive,o=!v(r,"trimString")||r.trimString,n=!!v(r,"includeIndeterminate")&&r.includeIndeterminate;if(!A(t)||!A(o)||!A(n))throw new TypeError(`Parameters \`caseInsensitive\`, \`trimString\` and \`includeIndeterminate\` property of the \`options\` (second parameter) expected to be a \`boolean\` type, but received: ['caseInsensitive': \`${g(t)}\`, 'trimString': \`${g(o)}\`, 'includeIndeterminate': \`${g(n)}\`].`);if(j(e)){let r=e;o&&(r=r.trim()),t&&(r=r.toLowerCase());const i=["true","on","yes","1"];return n&&i.push("indeterminate"),i.includes(r)}return h(e)?1===e:!!A(e)&&e},x=e=>!S(e)&&(j(e)?!o(e):A(e)?e:h(e,{includeNaN:!0})?0!==e:d(e)?e.length>0:Boolean(e)),F=e=>{const r={undefined:void 0,null:null,nan:NaN,true:!0,false:!1,yes:!0,no:!1};if(j(e)){const t=e.trim().toLowerCase();if(Object.prototype.hasOwnProperty.call(r,t))return r[t];const o=t.replace(/,/g,""),n=Number(o);return!O(n)&&C(o)?n:e.trim()}return e},H=(e,r)=>{if(!R(e))return e;const[t,...o]=r;if(d(e))for(const t of e)R(t)&&H(t,r);else a(o)?D(e)&&delete e[t]:D(e)&&R(e[t])&&H(e[t],o);return e},Q=(e,r)=>{if(!D(e))return e;const[t,...o]=r;return 0===o.length?D(e)&&delete e[t]:D(e[t])&&Q(e[t],o),e};function X(e,r,t=!0){if(s(e,{checkSymbols:!0}))return{};if(p(r,{message:({currentType:e,validType:t})=>`Second parameter (\`keysToDelete\`) must be of type \`${t}\` with value of { key: string, deep?: boolean } plain-object, but received: \`${e}\`, with value: \`${u(r)}\`.`}),!r.every(e=>D(e)&&"key"in e))throw new TypeError(`Each element in Second Parameter (\`keysToDelete\`) must be of type \`plain-object\` with at least a "key" property (optionally "deep"), but received: \`${u(r)}\`.`);let o=t?(e=>{try{if(w(structuredClone))return structuredClone(e)}catch{}return JSON.parse(JSON.stringify(e))})(e):e;for(const{key:e,deep:t}of r){if(n(e,{message:({currentType:e,validType:r})=>`Parameter \`key\` at Second Parameter (\`keysToDelete\`) must be of type \`${r}\`, but received: \`${e}\`.`}),!W(t)&&!A(t))throw new TypeError(`Parameter \`deep\` at Second Parameter (\`keysToDelete\`) ➔ (key: "${e}", deep: ${t}) must be of type \`boolean\` or \`undefined\`, but received: \`${g(t)}\`.`);const r=e.split(".");o=t?H(o,r):Q(o,r)}return o}function Y(e,t={}){l(t,{message:({currentType:e,validType:r})=>`Second parameter (\`options\`) must be of type \`${r}\`, but received: \`${e}\`.`});return function e(t,o){if(S(t)||i(t))return;const{removeEmptyArrays:n,removeEmptyObjects:m,isRoot:p}=o;if(!A(m)||!A(n))throw new TypeError(`Parameters \`removeEmptyObjects\` and \`removeEmptyArrays\` property of the \`options\` (second parameter) must be of type \`boolean\`, but received: ['removeEmptyObjects': \`${g(m)}\`, 'removeEmptyArrays': \`${g(n)}\`].`);if(h(t)||A(t)||C(t)){const e=Number(t);return M(e)||O(e)?void 0:e}if(T(t)||N(t)||$(t)){const e=Number(t.valueOf());return M(e)||O(e)?void 0:e}if(c(t,{skipInvalidDate:!0}))try{return O(t.getTime())?0:t.getTime()}catch{return 0}if(J(t)){const r=Array.from(t).map(r=>e(r,{removeEmptyObjects:m,removeEmptyArrays:n,isRoot:!1})).filter(e=>!W(e));if(n&&a(r))return;return r}if(r(t)){if(t instanceof BigInt64Array||t instanceof BigUint64Array){const r=Array.from(t).map(r=>e(r,{removeEmptyObjects:m,removeEmptyArrays:n,isRoot:!1})).filter(e=>!W(e));if(n&&a(r))return;return r}{const r=Array.from(t).map(r=>e(r,{removeEmptyObjects:m,removeEmptyArrays:n,isRoot:!1})).filter(e=>!W(e));if(n&&a(r))return;return r}}if(P(t)){const r=Array.from(t).map(r=>e(r,{removeEmptyObjects:m,removeEmptyArrays:n,isRoot:!1})).filter(e=>!W(e));if(n&&a(r))return;return r}if(f(t)){let r=Array.from(t.entries()).map(([r,t])=>{const o=e(r,{removeEmptyObjects:m,removeEmptyArrays:n,isRoot:!1}),i=e(t,{removeEmptyObjects:m,removeEmptyArrays:n,isRoot:!1});return W(o)||W(i)?void 0:[o,i]}).filter(e=>!W(e));if(n&&(r=r.filter(e=>!a(e))),n&&a(r))return;return r}if(d(t)){const r=t.map(r=>e(r,{removeEmptyObjects:m,removeEmptyArrays:n,isRoot:!1})).filter(e=>!W(e));if(n&&a(r))return;return r}if(B(t)){const r={};for(const[o,i]of Object.entries(t)){const t=e(i,{removeEmptyObjects:m,removeEmptyArrays:n,isRoot:!1});W(t)||(r[o]=t)}return m&&s(r)?p?{}:void 0:r}}(e,{removeEmptyObjects:!!v(t,"removeEmptyObjects")&&t.removeEmptyObjects,removeEmptyArrays:!!v(t,"removeEmptyArrays")&&t.removeEmptyArrays,isRoot:!0})}function q(e,t={}){l(t,{message:({currentType:e,validType:r})=>`Second parameter (\`options\`) must be of type \`${r}\`, but received: \`${e}\`.`});return function e(t,o){if(S(t)||M(t))return;const{removeEmptyArrays:n,removeEmptyObjects:m,isRoot:s}=o;if(!A(m)||!A(n))throw new TypeError(`Parameters \`removeEmptyObjects\` and \`removeEmptyArrays\` property of the \`options\` (second parameter) must be of type \`boolean\`, but received: ['removeEmptyObjects': \`${g(m)}\`, 'removeEmptyArrays': \`${g(n)}\`].`);if(h(t)||j(t)||A(t))return String(t);if(T(t)){const e=t.valueOf();return M(e)||O(e)?void 0:e.toString()}if(N(t))return t.valueOf();if($(t))return t.valueOf().toString();if(c(t,{skipInvalidDate:!0}))try{return t.toISOString()}catch{return t.toString()}if(i(t))return t.toString();if(J(t))return Array.from(t).map(e=>String(e)).filter(e=>!W(e));if(r(t)){if(t instanceof BigInt64Array||t instanceof BigUint64Array){const r=Array.from(t).map(r=>e(r,{removeEmptyObjects:m,removeEmptyArrays:n,isRoot:!1})).map(e=>String(e)).filter(e=>!W(e));if(n&&a(r))return;return r}{const r=Array.from(t).map(r=>e(r,{removeEmptyObjects:m,removeEmptyArrays:n,isRoot:!1})).map(e=>String(e)).filter(e=>!W(e));if(n&&a(r))return;return r}}if(P(t)){const r=Array.from(t).map(r=>e(r,{removeEmptyObjects:m,removeEmptyArrays:n,isRoot:!1})).filter(e=>!W(e));if(n&&a(r))return;return r}if(f(t)){const r=Array.from(t.entries()).map(([r,t])=>[e(r,{removeEmptyObjects:m,removeEmptyArrays:n,isRoot:!1}),e(t,{removeEmptyObjects:m,removeEmptyArrays:n,isRoot:!1})]).filter(([e,r])=>!W(e)&&!W(r));if(n&&a(r))return;return r}if(d(t)){let r=t.map(r=>e(r,{removeEmptyObjects:m,removeEmptyArrays:n,isRoot:!1})).filter(e=>!W(e));if(n&&(r=r.filter(e=>!(d(e)&&0===e.length))),n&&a(r))return;return r}if(B(t)){const r={};for(const[o,i]of Object.entries(t)){const t=e(i,{removeEmptyObjects:m,removeEmptyArrays:n,isRoot:!1});W(t)?d(i)&&!n&&(r[o]=[]):r[o]=t}return m&&0===Object.keys(r).length?s?{}:void 0:r}}(e,{removeEmptyObjects:!!v(t,"removeEmptyObjects")&&t.removeEmptyObjects,removeEmptyArrays:!!v(t,"removeEmptyArrays")&&t.removeEmptyArrays,isRoot:!0})}export{F as convertType,G as dedupeArray,X as removeObjectPaths,L as toBooleanContent,V as toBooleanContentDeep,Z as toBooleanExplicit,x as toBooleanLoose,K as toNumberArrayUnRecursive,Y as toNumberDeep,q as toStringDeep,U as toStringDeepForce};
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 { isNonEmptyValue, isTypedArray } from './chunk-5IGC6PBH.js';
11
+ import { filterNilArray } from './chunk-OI5XKNZO.js';
12
+ import { isEmptyString } from './chunk-W2WNBUDE.js';
13
+ import { assertIsString } from './chunk-SBKGWRS5.js';
14
+ import { isRegExp, isEqual } from './chunk-NBZWMBO6.js';
15
+ import { isEmptyObject, isEmptyArray } from './chunk-6JFCSH7J.js';
16
+ import { assertIsArray } from './chunk-CKTLUNWX.js';
17
+ import { safeStableStringify, isDate, isMap } from './chunk-PET42Z7W.js';
18
+ import { isBigInt } from './chunk-QNKGP5DY.js';
19
+ import { assertIsPlainObject, hasOwnProp, assertIsBoolean, isArray, isNull, getPreciseType, isNaN, isString, isNumber, isBoolean, isNil, isNumberObject, isBooleanObject, isStringObject, isSymbol, isFunction, isObjectOrArray, isError, isSet, isObject, isNonEmptyString, isPlainObject, isUndefined, isInfinityNumber, isBuffer } from './chunk-CMW2TBOQ.js';
20
+
21
+ function toNumberArrayUnRecursive(array, options = {}) {
22
+ assertIsPlainObject(options, {
23
+ message: ({ currentType, validType }) => `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
24
+ });
25
+ const riv = hasOwnProp(options, "removeInvalidValueNumber") ? options.removeInvalidValueNumber : true;
26
+ assertIsBoolean(riv, {
27
+ message: ({ currentType, validType }) => `Parameter \`removeInvalidValueNumber\` property of the \`options\` (second parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`
28
+ });
29
+ if (isArray(array)) {
30
+ const result = Array.from(array, (x) => {
31
+ if (isBigInt(x)) return Number(x);
32
+ const str = String(x).trim();
33
+ const match = str.match(/-?\d+(\.\d+)?/);
34
+ return match ? Number(match[0]) : isNull(x) ? null : void 0;
35
+ });
36
+ return riv ? filterNilArray(result) : result;
37
+ }
38
+ return void 0;
39
+ }
40
+
41
+ function toStringDeepForce(value, forceToString) {
42
+ if (!(forceToString === false || forceToString === "stringOrNumber" || forceToString === "primitives" || forceToString === "all")) {
43
+ throw new TypeError(
44
+ `Second parameter \`forceToString\` must be of type \`false\` or \`string\` with value one of "stringOrNumber" | "primitives" | "all", but received: \`${getPreciseType(
45
+ forceToString
46
+ )}\`, with value: \`${safeStableStringify(forceToString)}\`.`
47
+ );
48
+ }
49
+ if (isNaN(value)) {
50
+ return forceToString === "primitives" || forceToString === "all" ? "NaN" : NaN;
51
+ }
52
+ if (isString(value) || isNumber(value)) {
53
+ return forceToString === "stringOrNumber" || forceToString === "primitives" || forceToString === "all" ? String(value) : value;
54
+ }
55
+ if (isBoolean(value) || isBigInt(value) || isNil(value)) {
56
+ return forceToString === "primitives" || forceToString === "all" ? String(value) : value;
57
+ }
58
+ if (isNumberObject(value) || isBooleanObject(value) || isStringObject(value)) {
59
+ return forceToString === "all" ? value.valueOf().toString() : value;
60
+ }
61
+ if (isSymbol(value)) {
62
+ return forceToString === "all" ? value.toString() : value;
63
+ }
64
+ if (isFunction(value)) {
65
+ return forceToString === "all" ? value.toString() : value;
66
+ }
67
+ if (isArray(value)) {
68
+ return value.map((v) => toStringDeepForce(v, forceToString));
69
+ }
70
+ if (isObjectOrArray(value)) {
71
+ if (isDate(value)) {
72
+ return forceToString === "all" ? value.toISOString() : value;
73
+ }
74
+ if (isRegExp(value)) {
75
+ return forceToString === "all" ? value.toString() : value;
76
+ }
77
+ if (isError(value) || value instanceof Promise) {
78
+ return forceToString === "all" ? value.toString() : value;
79
+ }
80
+ if (isSet(value)) {
81
+ return forceToString === "all" ? [...value].map((v) => toStringDeepForce(v, forceToString)) : value;
82
+ }
83
+ if (isMap(value)) {
84
+ return forceToString === "all" ? [...value.entries()].map(([k, v]) => [
85
+ toStringDeepForce(k, forceToString),
86
+ toStringDeepForce(v, forceToString)
87
+ ]) : value;
88
+ }
89
+ const result = {};
90
+ if (isObject(value)) {
91
+ for (const key of Object.keys(value)) {
92
+ result[key] = toStringDeepForce(value[key], forceToString);
93
+ }
94
+ }
95
+ return result;
96
+ }
97
+ return value;
98
+ }
99
+
100
+ var dedupeArray = (inputArray, options = {}) => {
101
+ assertIsArray(inputArray, {
102
+ message: ({ currentType, validType }) => `First parameter (\`inputArray\`) must be of type \`${validType}\` (array literal or instance), but received: \`${currentType}\`.`
103
+ });
104
+ assertIsPlainObject(options, {
105
+ message: ({ currentType, validType }) => `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
106
+ });
107
+ const flatten = hasOwnProp(options, "flatten") ? options.flatten : false;
108
+ const forceToString = hasOwnProp(options, "forceToString") ? options.forceToString : false;
109
+ if (!(forceToString === false || forceToString === "stringOrNumber" || forceToString === "primitives" || forceToString === "all")) {
110
+ throw new TypeError(
111
+ `Parameter \`forceToString\` property of the \`options\` (second parameter) must be of type \`false\` or \`string\` with value one of "stringOrNumber" | "primitives" | "all", but received: \`${getPreciseType(
112
+ forceToString
113
+ )}\`, with value: \`${safeStableStringify(forceToString)}\`.`
114
+ );
115
+ }
116
+ assertIsBoolean(flatten, {
117
+ message: ({ currentType, validType }) => `Parameter \`flatten\` property of the \`options\` (second parameter) must be of type \`${validType}\`, but received: \`${currentType}\`.`
118
+ });
119
+ const process = (arr) => {
120
+ const seen = [];
121
+ return arr.reduce((acc, item) => {
122
+ const value = isArray(item) ? process(item) : toStringDeepForce(item, forceToString);
123
+ if (!seen.some((s) => isEqual(s, value))) {
124
+ seen.push(value);
125
+ acc.push(value);
126
+ }
127
+ return acc;
128
+ }, []);
129
+ };
130
+ const deepFlatten = (value) => {
131
+ if (isArray(value)) {
132
+ return value.flatMap(deepFlatten);
133
+ }
134
+ if (isSet(value)) {
135
+ return [...value].flatMap(deepFlatten);
136
+ }
137
+ if (isMap(value)) {
138
+ return [...value.values()].flatMap(deepFlatten);
139
+ }
140
+ return [value];
141
+ };
142
+ return flatten ? process(deepFlatten(inputArray)) : process(inputArray);
143
+ };
144
+
145
+ var toBooleanContent = (value) => {
146
+ if (isNil(value)) return false;
147
+ if (isString(value)) return isNonEmptyString(value);
148
+ if (isBoolean(value)) return value;
149
+ if (isNumber(value, { includeNaN: true })) return value !== 0;
150
+ if (isArray(value) || isObject(value)) return isNonEmptyValue(value);
151
+ return Boolean(value);
152
+ };
153
+
154
+ var toBooleanContentDeep = (value) => {
155
+ if (isNil(value)) return false;
156
+ if (isString(value)) return isNonEmptyString(value);
157
+ if (isBoolean(value)) return value;
158
+ if (isNumber(value, { includeNaN: true })) return value !== 0;
159
+ if (isArray(value)) return value.some(toBooleanContentDeep);
160
+ if (isObject(value)) return Object.values(value).some(toBooleanContentDeep);
161
+ return false;
162
+ };
163
+
164
+ var toBooleanExplicit = (value, options = {}) => {
165
+ if (isNil(value)) return false;
166
+ if (!isPlainObject(options)) options = {};
167
+ const ci = hasOwnProp(options, "caseInsensitive") ? options.caseInsensitive : false;
168
+ const ts = hasOwnProp(options, "trimString") ? options.trimString : true;
169
+ const incInd = hasOwnProp(options, "includeIndeterminate") ? options.includeIndeterminate : false;
170
+ if (!isBoolean(ci) || !isBoolean(ts) || !isBoolean(incInd)) {
171
+ throw new TypeError(
172
+ `Parameters \`caseInsensitive\`, \`trimString\` and \`includeIndeterminate\` property of the \`options\` (second parameter) expected to be a \`boolean\` type, but received: ['caseInsensitive': \`${getPreciseType(
173
+ ci
174
+ )}\`, 'trimString': \`${getPreciseType(
175
+ ts
176
+ )}\`, 'includeIndeterminate': \`${getPreciseType(incInd)}\`].`
177
+ );
178
+ }
179
+ if (isString(value)) {
180
+ let normalized = value;
181
+ if (ts) normalized = normalized.trim();
182
+ if (ci) normalized = normalized.toLowerCase();
183
+ const validTrueStrings = ["true", "on", "yes", "1"];
184
+ if (incInd) validTrueStrings.push("indeterminate");
185
+ return validTrueStrings.includes(normalized);
186
+ }
187
+ if (isNumber(value)) return value === 1;
188
+ if (isBoolean(value)) return value;
189
+ return false;
190
+ };
191
+
192
+ var toBooleanLoose = (value) => {
193
+ if (isNil(value)) return false;
194
+ if (isString(value)) return !isEmptyString(value);
195
+ if (isBoolean(value)) return value;
196
+ if (isNumber(value, { includeNaN: true })) return value !== 0;
197
+ if (isArray(value)) return value.length > 0;
198
+ return Boolean(value);
199
+ };
200
+
201
+ var convertType = (value) => {
202
+ const predefinedValues = {
203
+ undefined: void 0,
204
+ null: null,
205
+ nan: NaN,
206
+ true: true,
207
+ false: false,
208
+ yes: true,
209
+ no: false
210
+ };
211
+ if (isString(value)) {
212
+ const normalized = value.trim().toLowerCase();
213
+ if (Object.prototype.hasOwnProperty.call(predefinedValues, normalized)) {
214
+ return predefinedValues[normalized];
215
+ }
216
+ const numericString = normalized.replace(/,/g, "");
217
+ const numberString = Number(numericString);
218
+ if (!isNaN(numberString) && isNonEmptyString(numericString)) {
219
+ return numberString;
220
+ }
221
+ return value.trim();
222
+ }
223
+ return value;
224
+ };
225
+
226
+ var deepCloneSafe = (obj) => {
227
+ try {
228
+ if (isFunction(structuredClone)) {
229
+ return structuredClone(obj);
230
+ }
231
+ } catch {
232
+ }
233
+ return JSON.parse(JSON.stringify(obj));
234
+ };
235
+
236
+ var deleteNestedKey = (obj, path) => {
237
+ if (!isObjectOrArray(obj)) return obj;
238
+ const [currentKey, ...rest] = path;
239
+ if (isArray(obj)) {
240
+ for (const item of obj) {
241
+ if (isObjectOrArray(item)) deleteNestedKey(item, path);
242
+ }
243
+ } else if (isEmptyArray(rest)) {
244
+ if (isPlainObject(obj)) delete obj[currentKey];
245
+ } else if (isPlainObject(obj) && isObjectOrArray(obj[currentKey])) {
246
+ deleteNestedKey(obj[currentKey], rest);
247
+ }
248
+ return obj;
249
+ };
250
+
251
+ var deleteExactPathOnce = (obj, path) => {
252
+ if (!isPlainObject(obj)) return obj;
253
+ const [currentKey, ...rest] = path;
254
+ if (rest.length === 0) {
255
+ if (isPlainObject(obj)) delete obj[currentKey];
256
+ } else if (isPlainObject(obj[currentKey])) {
257
+ deleteExactPathOnce(obj[currentKey], rest);
258
+ }
259
+ return obj;
260
+ };
261
+
262
+ function removeObjectPaths(object, keysToDelete, deepClone = true) {
263
+ if (isEmptyObject(object, { checkSymbols: true }))
264
+ return {};
265
+ assertIsArray(keysToDelete, {
266
+ message: ({ currentType, validType }) => `Second parameter (\`keysToDelete\`) must be of type \`${validType}\` with value of { key: string, deep?: boolean } plain-object, but received: \`${currentType}\`, with value: \`${safeStableStringify(
267
+ keysToDelete
268
+ )}\`.`
269
+ });
270
+ if (!keysToDelete.every((k) => isPlainObject(k) && "key" in k)) {
271
+ throw new TypeError(
272
+ `Each element in Second Parameter (\`keysToDelete\`) must be of type \`plain-object\` with at least a "key" property (optionally "deep"), but received: \`${safeStableStringify(
273
+ keysToDelete
274
+ )}\`.`
275
+ );
276
+ }
277
+ let result = deepClone ? deepCloneSafe(object) : object;
278
+ for (const { key, deep } of keysToDelete) {
279
+ assertIsString(key, {
280
+ message: ({ currentType, validType }) => `Parameter \`key\` at Second Parameter (\`keysToDelete\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
281
+ });
282
+ if (!isUndefined(deep) && !isBoolean(deep)) {
283
+ throw new TypeError(
284
+ `Parameter \`deep\` at Second Parameter (\`keysToDelete\`) \u2794 (key: "${key}", deep: ${deep}) must be of type \`boolean\` or \`undefined\`, but received: \`${getPreciseType(
285
+ deep
286
+ )}\`.`
287
+ );
288
+ }
289
+ const path = key.split(".");
290
+ result = deep ? deleteNestedKey(result, path) : deleteExactPathOnce(result, path);
291
+ }
292
+ return result;
293
+ }
294
+
295
+ function toNumberDeep(input, options = {}) {
296
+ assertIsPlainObject(options, {
297
+ message: ({ currentType, validType }) => `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
298
+ });
299
+ const removeEmptyObjects = hasOwnProp(options, "removeEmptyObjects") ? options.removeEmptyObjects : false;
300
+ const removeEmptyArrays = hasOwnProp(options, "removeEmptyArrays") ? options.removeEmptyArrays : false;
301
+ function _internal(input2, options2) {
302
+ if (isNil(input2) || isRegExp(input2)) return void 0;
303
+ const { removeEmptyArrays: removeEmptyArrays2, removeEmptyObjects: removeEmptyObjects2, isRoot } = options2;
304
+ if (!isBoolean(removeEmptyObjects2) || !isBoolean(removeEmptyArrays2)) {
305
+ throw new TypeError(
306
+ `Parameters \`removeEmptyObjects\` and \`removeEmptyArrays\` property of the \`options\` (second parameter) must be of type \`boolean\`, but received: ['removeEmptyObjects': \`${getPreciseType(
307
+ removeEmptyObjects2
308
+ )}\`, 'removeEmptyArrays': \`${getPreciseType(removeEmptyArrays2)}\`].`
309
+ );
310
+ }
311
+ if (isNumber(input2) || isBoolean(input2) || isNonEmptyString(input2)) {
312
+ const num = Number(input2);
313
+ return isInfinityNumber(num) || isNaN(num) ? void 0 : num;
314
+ }
315
+ if (isNumberObject(input2) || isStringObject(input2) || isBooleanObject(input2)) {
316
+ const valOf = Number(input2.valueOf());
317
+ return isInfinityNumber(valOf) || isNaN(valOf) ? void 0 : valOf;
318
+ }
319
+ if (isDate(input2, { skipInvalidDate: true })) {
320
+ try {
321
+ return !isNaN(input2.getTime()) ? input2.getTime() : 0;
322
+ } catch {
323
+ return 0;
324
+ }
325
+ }
326
+ if (isBuffer(input2)) {
327
+ const arr = Array.from(input2).map(
328
+ (n) => _internal(n, {
329
+ removeEmptyObjects: removeEmptyObjects2,
330
+ removeEmptyArrays: removeEmptyArrays2,
331
+ isRoot: false
332
+ })
333
+ ).filter((item) => !isUndefined(item));
334
+ if (removeEmptyArrays2 && isEmptyArray(arr)) return void 0;
335
+ return arr;
336
+ }
337
+ if (isTypedArray(input2)) {
338
+ if (input2 instanceof BigInt64Array || input2 instanceof BigUint64Array) {
339
+ const newArray = Array.from(input2).map(
340
+ (item) => _internal(item, {
341
+ removeEmptyObjects: removeEmptyObjects2,
342
+ removeEmptyArrays: removeEmptyArrays2,
343
+ isRoot: false
344
+ })
345
+ ).filter((item) => !isUndefined(item));
346
+ if (removeEmptyArrays2 && isEmptyArray(newArray)) return void 0;
347
+ return newArray;
348
+ } else {
349
+ const newArray = Array.from(input2).map(
350
+ (item) => _internal(item, {
351
+ removeEmptyObjects: removeEmptyObjects2,
352
+ removeEmptyArrays: removeEmptyArrays2,
353
+ isRoot: false
354
+ })
355
+ ).filter((item) => !isUndefined(item));
356
+ if (removeEmptyArrays2 && isEmptyArray(newArray)) return void 0;
357
+ return newArray;
358
+ }
359
+ }
360
+ if (isSet(input2)) {
361
+ const newArray = Array.from(input2).map(
362
+ (item) => _internal(item, {
363
+ removeEmptyObjects: removeEmptyObjects2,
364
+ removeEmptyArrays: removeEmptyArrays2,
365
+ isRoot: false
366
+ })
367
+ ).filter((item) => !isUndefined(item));
368
+ if (removeEmptyArrays2 && isEmptyArray(newArray)) return void 0;
369
+ return newArray;
370
+ }
371
+ if (isMap(input2)) {
372
+ let newArray = Array.from(input2.entries()).map(([k, v]) => {
373
+ const key = _internal(k, {
374
+ removeEmptyObjects: removeEmptyObjects2,
375
+ removeEmptyArrays: removeEmptyArrays2,
376
+ isRoot: false
377
+ });
378
+ const value = _internal(v, {
379
+ removeEmptyObjects: removeEmptyObjects2,
380
+ removeEmptyArrays: removeEmptyArrays2,
381
+ isRoot: false
382
+ });
383
+ return !isUndefined(key) && !isUndefined(value) ? [key, value] : void 0;
384
+ }).filter((item) => !isUndefined(item));
385
+ if (removeEmptyArrays2) {
386
+ newArray = newArray.filter((v) => !isEmptyArray(v));
387
+ }
388
+ if (removeEmptyArrays2 && isEmptyArray(newArray)) return void 0;
389
+ return newArray;
390
+ }
391
+ if (isArray(input2)) {
392
+ const newArray = input2.map(
393
+ (item) => _internal(item, {
394
+ removeEmptyObjects: removeEmptyObjects2,
395
+ removeEmptyArrays: removeEmptyArrays2,
396
+ isRoot: false
397
+ })
398
+ ).filter((item) => !isUndefined(item));
399
+ if (removeEmptyArrays2 && isEmptyArray(newArray)) return void 0;
400
+ return newArray;
401
+ }
402
+ if (isObject(input2)) {
403
+ const newObject = {};
404
+ for (const [key, value] of Object.entries(input2)) {
405
+ const convertedValue = _internal(value, {
406
+ removeEmptyObjects: removeEmptyObjects2,
407
+ removeEmptyArrays: removeEmptyArrays2,
408
+ isRoot: false
409
+ });
410
+ if (!isUndefined(convertedValue)) {
411
+ newObject[key] = convertedValue;
412
+ }
413
+ }
414
+ if (removeEmptyObjects2 && isEmptyObject(newObject)) {
415
+ return isRoot ? {} : void 0;
416
+ }
417
+ return newObject;
418
+ }
419
+ return void 0;
420
+ }
421
+ return _internal(input, {
422
+ removeEmptyObjects,
423
+ removeEmptyArrays,
424
+ isRoot: true
425
+ });
426
+ }
427
+
428
+ function toStringDeep(input, options = {}) {
429
+ assertIsPlainObject(options, {
430
+ message: ({ currentType, validType }) => `Second parameter (\`options\`) must be of type \`${validType}\`, but received: \`${currentType}\`.`
431
+ });
432
+ const removeEmptyObjects = hasOwnProp(options, "removeEmptyObjects") ? options.removeEmptyObjects : false;
433
+ const removeEmptyArrays = hasOwnProp(options, "removeEmptyArrays") ? options.removeEmptyArrays : false;
434
+ function _internal(input2, options2) {
435
+ if (isNil(input2) || isInfinityNumber(input2)) return void 0;
436
+ const { removeEmptyArrays: removeEmptyArrays2, removeEmptyObjects: removeEmptyObjects2, isRoot } = options2;
437
+ if (!isBoolean(removeEmptyObjects2) || !isBoolean(removeEmptyArrays2)) {
438
+ throw new TypeError(
439
+ `Parameters \`removeEmptyObjects\` and \`removeEmptyArrays\` property of the \`options\` (second parameter) must be of type \`boolean\`, but received: ['removeEmptyObjects': \`${getPreciseType(
440
+ removeEmptyObjects2
441
+ )}\`, 'removeEmptyArrays': \`${getPreciseType(removeEmptyArrays2)}\`].`
442
+ );
443
+ }
444
+ if (isNumber(input2) || isString(input2) || isBoolean(input2)) return String(input2);
445
+ if (isNumberObject(input2)) {
446
+ const valOf = input2.valueOf();
447
+ return isInfinityNumber(valOf) || isNaN(valOf) ? void 0 : valOf.toString();
448
+ }
449
+ if (isStringObject(input2)) return input2.valueOf();
450
+ if (isBooleanObject(input2)) return input2.valueOf().toString();
451
+ if (isDate(input2, { skipInvalidDate: true })) {
452
+ try {
453
+ return input2.toISOString();
454
+ } catch {
455
+ return input2.toString();
456
+ }
457
+ }
458
+ if (isRegExp(input2)) return input2.toString();
459
+ if (isBuffer(input2)) {
460
+ return Array.from(input2).map((v) => String(v)).filter((v) => !isUndefined(v));
461
+ }
462
+ if (isTypedArray(input2)) {
463
+ if (input2 instanceof BigInt64Array || input2 instanceof BigUint64Array) {
464
+ const newArray = Array.from(input2).map(
465
+ (item) => _internal(item, {
466
+ removeEmptyObjects: removeEmptyObjects2,
467
+ removeEmptyArrays: removeEmptyArrays2,
468
+ isRoot: false
469
+ })
470
+ ).map((v) => String(v)).filter((item) => !isUndefined(item));
471
+ if (removeEmptyArrays2 && isEmptyArray(newArray)) return void 0;
472
+ return newArray;
473
+ } else {
474
+ const newArray = Array.from(input2).map(
475
+ (item) => _internal(item, {
476
+ removeEmptyObjects: removeEmptyObjects2,
477
+ removeEmptyArrays: removeEmptyArrays2,
478
+ isRoot: false
479
+ })
480
+ ).map((v) => String(v)).filter((item) => !isUndefined(item));
481
+ if (removeEmptyArrays2 && isEmptyArray(newArray)) return void 0;
482
+ return newArray;
483
+ }
484
+ }
485
+ if (isSet(input2)) {
486
+ const arr = Array.from(input2).map(
487
+ (v) => _internal(v, { removeEmptyObjects: removeEmptyObjects2, removeEmptyArrays: removeEmptyArrays2, isRoot: false })
488
+ ).filter((v) => !isUndefined(v));
489
+ if (removeEmptyArrays2 && isEmptyArray(arr)) return void 0;
490
+ return arr;
491
+ }
492
+ if (isMap(input2)) {
493
+ const arr = Array.from(input2.entries()).map(([k, v]) => [
494
+ _internal(k, { removeEmptyObjects: removeEmptyObjects2, removeEmptyArrays: removeEmptyArrays2, isRoot: false }),
495
+ _internal(v, { removeEmptyObjects: removeEmptyObjects2, removeEmptyArrays: removeEmptyArrays2, isRoot: false })
496
+ ]).filter(([k, v]) => !isUndefined(k) && !isUndefined(v));
497
+ if (removeEmptyArrays2 && isEmptyArray(arr)) return void 0;
498
+ return arr;
499
+ }
500
+ if (isArray(input2)) {
501
+ let newArray = input2.map(
502
+ (item) => _internal(item, {
503
+ removeEmptyObjects: removeEmptyObjects2,
504
+ removeEmptyArrays: removeEmptyArrays2,
505
+ isRoot: false
506
+ })
507
+ ).filter((item) => !isUndefined(item));
508
+ if (removeEmptyArrays2) {
509
+ newArray = newArray.filter((v) => !(isArray(v) && v.length === 0));
510
+ }
511
+ if (removeEmptyArrays2 && isEmptyArray(newArray)) return void 0;
512
+ return newArray;
513
+ }
514
+ if (isObject(input2)) {
515
+ const newObject = {};
516
+ for (const [key, value] of Object.entries(input2)) {
517
+ const convertedValue = _internal(value, {
518
+ removeEmptyObjects: removeEmptyObjects2,
519
+ removeEmptyArrays: removeEmptyArrays2,
520
+ isRoot: false
521
+ });
522
+ if (!isUndefined(convertedValue)) {
523
+ newObject[key] = convertedValue;
524
+ } else if (isArray(value) && !removeEmptyArrays2) {
525
+ newObject[key] = [];
526
+ }
527
+ }
528
+ if (removeEmptyObjects2 && Object.keys(newObject).length === 0) {
529
+ return isRoot ? {} : void 0;
530
+ }
531
+ return newObject;
532
+ }
533
+ return void 0;
534
+ }
535
+ return _internal(input, {
536
+ removeEmptyObjects,
537
+ removeEmptyArrays,
538
+ isRoot: true
539
+ });
540
+ }
541
+
542
+ export { convertType, dedupeArray, removeObjectPaths, toBooleanContent, toBooleanContentDeep, toBooleanExplicit, toBooleanLoose, toNumberArrayUnRecursive, toNumberDeep, toStringDeep, toStringDeepForce };