@vielzeug/toolkit 1.0.12 → 1.0.13

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 (98) hide show
  1. package/dist/array/chunk.cjs +1 -1
  2. package/dist/array/chunk.cjs.map +1 -1
  3. package/dist/array/chunk.js +15 -12
  4. package/dist/array/chunk.js.map +1 -1
  5. package/dist/array/group.cjs +1 -1
  6. package/dist/array/group.cjs.map +1 -1
  7. package/dist/array/group.js +9 -9
  8. package/dist/array/group.js.map +1 -1
  9. package/dist/array/list.cjs +1 -1
  10. package/dist/array/list.cjs.map +1 -1
  11. package/dist/array/list.js +28 -24
  12. package/dist/array/list.js.map +1 -1
  13. package/dist/array/pick.cjs.map +1 -1
  14. package/dist/array/pick.js.map +1 -1
  15. package/dist/date/timeDiff.cjs +1 -1
  16. package/dist/date/timeDiff.cjs.map +1 -1
  17. package/dist/date/timeDiff.js +10 -12
  18. package/dist/date/timeDiff.js.map +1 -1
  19. package/dist/function/curry.cjs +1 -1
  20. package/dist/function/curry.cjs.map +1 -1
  21. package/dist/function/curry.js +3 -3
  22. package/dist/function/curry.js.map +1 -1
  23. package/dist/function/debounce.cjs +1 -1
  24. package/dist/function/debounce.cjs.map +1 -1
  25. package/dist/function/debounce.js +22 -5
  26. package/dist/function/debounce.js.map +1 -1
  27. package/dist/function/memo.cjs +1 -1
  28. package/dist/function/memo.cjs.map +1 -1
  29. package/dist/function/memo.js +14 -13
  30. package/dist/function/memo.js.map +1 -1
  31. package/dist/function/retry.cjs +1 -1
  32. package/dist/function/retry.cjs.map +1 -1
  33. package/dist/function/retry.js +13 -13
  34. package/dist/function/retry.js.map +1 -1
  35. package/dist/function/sleep.cjs +1 -1
  36. package/dist/function/sleep.cjs.map +1 -1
  37. package/dist/function/sleep.js +8 -3
  38. package/dist/function/sleep.js.map +1 -1
  39. package/dist/function/throttle.cjs +1 -1
  40. package/dist/function/throttle.cjs.map +1 -1
  41. package/dist/function/throttle.js +33 -6
  42. package/dist/function/throttle.js.map +1 -1
  43. package/dist/index.d.ts +62 -51
  44. package/dist/math/average.cjs +1 -1
  45. package/dist/math/average.cjs.map +1 -1
  46. package/dist/math/average.js +18 -12
  47. package/dist/math/average.js.map +1 -1
  48. package/dist/math/median.cjs.map +1 -1
  49. package/dist/math/median.js.map +1 -1
  50. package/dist/math/range.cjs +1 -1
  51. package/dist/math/range.cjs.map +1 -1
  52. package/dist/math/range.js +14 -6
  53. package/dist/math/range.js.map +1 -1
  54. package/dist/math/sum.cjs +1 -1
  55. package/dist/math/sum.cjs.map +1 -1
  56. package/dist/math/sum.js +11 -18
  57. package/dist/math/sum.js.map +1 -1
  58. package/dist/object/clone.cjs +1 -1
  59. package/dist/object/clone.cjs.map +1 -1
  60. package/dist/object/clone.js +13 -3
  61. package/dist/object/clone.js.map +1 -1
  62. package/dist/object/merge.cjs +1 -1
  63. package/dist/object/merge.cjs.map +1 -1
  64. package/dist/object/merge.js +11 -15
  65. package/dist/object/merge.js.map +1 -1
  66. package/dist/object/seek.cjs +1 -1
  67. package/dist/object/seek.cjs.map +1 -1
  68. package/dist/object/seek.js +8 -6
  69. package/dist/object/seek.js.map +1 -1
  70. package/dist/random/uuid.cjs +1 -1
  71. package/dist/random/uuid.cjs.map +1 -1
  72. package/dist/random/uuid.js +6 -3
  73. package/dist/random/uuid.js.map +1 -1
  74. package/dist/string/camelCase.cjs +1 -1
  75. package/dist/string/camelCase.cjs.map +1 -1
  76. package/dist/string/camelCase.js +3 -3
  77. package/dist/string/camelCase.js.map +1 -1
  78. package/dist/string/similarity.cjs +1 -1
  79. package/dist/string/similarity.cjs.map +1 -1
  80. package/dist/string/similarity.js +24 -21
  81. package/dist/string/similarity.js.map +1 -1
  82. package/dist/string/truncate.cjs +1 -1
  83. package/dist/string/truncate.cjs.map +1 -1
  84. package/dist/string/truncate.js +14 -5
  85. package/dist/string/truncate.js.map +1 -1
  86. package/dist/typed/is.cjs +1 -1
  87. package/dist/typed/is.cjs.map +1 -1
  88. package/dist/typed/is.js +30 -31
  89. package/dist/typed/is.js.map +1 -1
  90. package/dist/typed/isEmpty.cjs +1 -1
  91. package/dist/typed/isEmpty.cjs.map +1 -1
  92. package/dist/typed/isEmpty.js +6 -6
  93. package/dist/typed/isEmpty.js.map +1 -1
  94. package/dist/typed/isEqual.cjs +1 -1
  95. package/dist/typed/isEqual.cjs.map +1 -1
  96. package/dist/typed/isEqual.js +22 -17
  97. package/dist/typed/isEqual.js.map +1 -1
  98. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"similarity.js","sources":["../../src/string/similarity.ts"],"sourcesContent":["import { assert } from '../function/assert';\n\n/**\n * Calculate the similarity between two strings using the Levenshtein distance algorithm.\n *\n * @example\n * ```ts\n * similarity('abc', 'abc') // 1\n * similarity('a', 'b') // 0\n * similarity('ab', 'ac') // 0.5\n * similarity('doe', 'John Doe') // 0.25\n * similarity('abc', 'axc') // 0.6666666666666667\n * similarity('kitten', 'sitting') // 0.5714285714285714\n * ```\n *\n * @param str1 - The first string.\n * @param str2 - The second string.\n *\n * @returns A number between 0 and 1 representing the similarity between the two strings.\n */\nexport function similarity(str1: unknown, str2: unknown): number {\n assert(\n ['string', 'number'].includes(typeof str1) && ['string', 'number'].includes(typeof str2),\n 'Invalid arguments',\n {\n args: { str1, str2 },\n type: TypeError,\n },\n );\n\n const a = String(str1).toLowerCase();\n const b = String(str2).toLowerCase();\n\n if (a === b) return 1;\n if (!a.length || !b.length) return 0;\n\n const aLength = a.length;\n const bLength = b.length;\n\n // Initialize matrix with first row and column\n const matrix: number[][] = Array.from({ length: aLength + 1 }, (_, i) => [i]);\n for (let j = 0; j <= bLength; j++) {\n matrix[0][j] = j;\n }\n\n // Calculate Levenshtein distance\n for (let i = 1; i <= aLength; i++) {\n for (let j = 1; j <= bLength; j++) {\n const cost = a[i - 1] === b[j - 1] ? 0 : 1;\n matrix[i][j] = Math.min(\n matrix[i - 1][j] + 1, // deletion\n matrix[i][j - 1] + 1, // insertion\n matrix[i - 1][j - 1] + cost, // substitution\n );\n }\n }\n\n const distance = matrix[aLength][bLength];\n\n return 1 - distance / Math.max(aLength, bLength);\n}\n"],"names":["similarity","str1","str2","assert","a","b","aLength","bLength","matrix","_","i","j","cost"],"mappings":";AAoBO,SAASA,EAAWC,GAAeC,GAAuB;AAC/D,EAAAC;AAAA,IACE,CAAC,UAAU,QAAQ,EAAE,SAAS,OAAOF,CAAI,KAAK,CAAC,UAAU,QAAQ,EAAE,SAAS,OAAOC,CAAI;AAAA,IACvF;AAAA,IACA;AAAA,MACE,MAAM,EAAE,MAAAD,GAAM,MAAAC,EAAA;AAAA,MACd,MAAM;AAAA,IAAA;AAAA,EACR;AAGF,QAAME,IAAI,OAAOH,CAAI,EAAE,YAAA,GACjBI,IAAI,OAAOH,CAAI,EAAE,YAAA;AAEvB,MAAIE,MAAMC,EAAG,QAAO;AACpB,MAAI,CAACD,EAAE,UAAU,CAACC,EAAE,OAAQ,QAAO;AAEnC,QAAMC,IAAUF,EAAE,QACZG,IAAUF,EAAE,QAGZG,IAAqB,MAAM,KAAK,EAAE,QAAQF,IAAU,EAAA,GAAK,CAACG,GAAGC,MAAM,CAACA,CAAC,CAAC;AAC5E,WAASC,IAAI,GAAGA,KAAKJ,GAASI;AAC5B,IAAAH,EAAO,CAAC,EAAEG,CAAC,IAAIA;AAIjB,WAASD,IAAI,GAAGA,KAAKJ,GAASI;AAC5B,aAASC,IAAI,GAAGA,KAAKJ,GAASI,KAAK;AACjC,YAAMC,IAAOR,EAAEM,IAAI,CAAC,MAAML,EAAEM,IAAI,CAAC,IAAI,IAAI;AACzC,MAAAH,EAAOE,CAAC,EAAEC,CAAC,IAAI,KAAK;AAAA,QAClBH,EAAOE,IAAI,CAAC,EAAEC,CAAC,IAAI;AAAA;AAAA,QACnBH,EAAOE,CAAC,EAAEC,IAAI,CAAC,IAAI;AAAA;AAAA,QACnBH,EAAOE,IAAI,CAAC,EAAEC,IAAI,CAAC,IAAIC;AAAA;AAAA,MAAA;AAAA,IAE3B;AAKF,SAAO,IAFUJ,EAAOF,CAAO,EAAEC,CAAO,IAElB,KAAK,IAAID,GAASC,CAAO;AACjD;"}
1
+ {"version":3,"file":"similarity.js","sources":["../../src/string/similarity.ts"],"sourcesContent":["import { assert } from '../function/assert';\n\n/**\n * Calculate the similarity between two strings using the Levenshtein distance algorithm.\n *\n * @example\n * ```ts\n * similarity('abc', 'abc') // 1\n * similarity('a', 'b') // 0\n * similarity('ab', 'ac') // 0.5\n * similarity('doe', 'John Doe') // 0.25\n * similarity('abc', 'axc') // 0.6666666666666667\n * similarity('kitten', 'sitting') // 0.5714285714285714\n * ```\n *\n * @param str1 - The first string.\n * @param str2 - The second string.\n *\n * @returns A number between 0 and 1 representing the similarity between the two strings.\n */\nexport function similarity(str1: unknown, str2: unknown): number {\n assert(\n ['string', 'number'].includes(typeof str1) && ['string', 'number'].includes(typeof str2),\n 'Invalid arguments',\n {\n args: { str1, str2 },\n type: TypeError,\n },\n );\n\n const a = String(str1).toLowerCase();\n const b = String(str2).toLowerCase();\n\n if (a === b) return 1;\n if (a.length === 0) return b.length === 0 ? 1 : 0;\n if (b.length === 0) return 0;\n\n // Swap to ensure we use the smaller string for columns (O(min(A,B)) space)\n const [shorter, longer] = a.length < b.length ? [a, b] : [b, a];\n const shorterLength = shorter.length;\n const longerLength = longer.length;\n\n let prevRow = Array.from({ length: shorterLength + 1 }, (_, i) => i);\n let currRow = new Array(shorterLength + 1);\n\n for (let i = 1; i <= longerLength; i++) {\n currRow[0] = i;\n for (let j = 1; j <= shorterLength; j++) {\n const cost = longer[i - 1] === shorter[j - 1] ? 0 : 1;\n currRow[j] = Math.min(\n currRow[j - 1] + 1, // insertion\n prevRow[j] + 1, // deletion\n prevRow[j - 1] + cost, // substitution\n );\n }\n // Swap rows for the next iteration (avoid allocation)\n [prevRow, currRow] = [currRow, prevRow];\n }\n\n // After the loop, a result is in prevRow because of the swap\n const distance = prevRow[shorterLength];\n\n return 1 - distance / Math.max(a.length, b.length);\n}\n"],"names":["similarity","str1","str2","assert","a","b","shorter","longer","shorterLength","longerLength","prevRow","_","i","currRow","j","cost"],"mappings":";AAoBO,SAASA,EAAWC,GAAeC,GAAuB;AAC/D,EAAAC;AAAA,IACE,CAAC,UAAU,QAAQ,EAAE,SAAS,OAAOF,CAAI,KAAK,CAAC,UAAU,QAAQ,EAAE,SAAS,OAAOC,CAAI;AAAA,IACvF;AAAA,IACA;AAAA,MACE,MAAM,EAAE,MAAAD,GAAM,MAAAC,EAAA;AAAA,MACd,MAAM;AAAA,IAAA;AAAA,EACR;AAGF,QAAME,IAAI,OAAOH,CAAI,EAAE,YAAA,GACjBI,IAAI,OAAOH,CAAI,EAAE,YAAA;AAEvB,MAAIE,MAAMC,EAAG,QAAO;AACpB,MAAID,EAAE,WAAW,UAAUC,EAAE,WAAW,IAAI,IAAI;AAChD,MAAIA,EAAE,WAAW,EAAG,QAAO;AAG3B,QAAM,CAACC,GAASC,CAAM,IAAIH,EAAE,SAASC,EAAE,SAAS,CAACD,GAAGC,CAAC,IAAI,CAACA,GAAGD,CAAC,GACxDI,IAAgBF,EAAQ,QACxBG,IAAeF,EAAO;AAE5B,MAAIG,IAAU,MAAM,KAAK,EAAE,QAAQF,IAAgB,KAAK,CAACG,GAAGC,MAAMA,CAAC,GAC/DC,IAAU,IAAI,MAAML,IAAgB,CAAC;AAEzC,WAASI,IAAI,GAAGA,KAAKH,GAAcG,KAAK;AACtC,IAAAC,EAAQ,CAAC,IAAID;AACb,aAASE,IAAI,GAAGA,KAAKN,GAAeM,KAAK;AACvC,YAAMC,IAAOR,EAAOK,IAAI,CAAC,MAAMN,EAAQQ,IAAI,CAAC,IAAI,IAAI;AACpD,MAAAD,EAAQC,CAAC,IAAI,KAAK;AAAA,QAChBD,EAAQC,IAAI,CAAC,IAAI;AAAA;AAAA,QACjBJ,EAAQI,CAAC,IAAI;AAAA;AAAA,QACbJ,EAAQI,IAAI,CAAC,IAAIC;AAAA;AAAA,MAAA;AAAA,IAErB;AAEA,KAACL,GAASG,CAAO,IAAI,CAACA,GAASH,CAAO;AAAA,EACxC;AAKA,SAAO,IAFUA,EAAQF,CAAa,IAEhB,KAAK,IAAIJ,EAAE,QAAQC,EAAE,MAAM;AACnD;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function f(e,t=25,r=!1,u="…"){if(e.length<=t)return e;const n=r?e.substring(0,t).lastIndexOf(" "):t,c=n>0?n:t;return`${e.substring(0,c).trim()}${u}`}exports.truncate=f;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../function/assert.cjs");function o(t,e=25,s=!1,u="…"){if(n.assert(typeof t=="string","First argument must be a string",{args:{str:t},type:TypeError}),n.assert(typeof e=="number"&&e>=0&&Number.isFinite(e),"Limit must be a non-negative finite number",{args:{limit:e},type:TypeError}),t.length<=e)return t;const r=s?t.substring(0,e).lastIndexOf(" "):e,a=r>0?r:e;return`${t.substring(0,a).trim()}${u}`}exports.truncate=o;
2
2
  //# sourceMappingURL=truncate.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"truncate.cjs","sources":["../../src/string/truncate.ts"],"sourcesContent":["/**\n * Truncates a string if it is longer than the given maximum string length. The last characters of the truncated string are replaced with the ellipsis sign \"…\".\n *\n * @example\n * ```ts\n * const text = 'Hello World';\n * truncate(text, 5); // 'Hello…'\n * truncate(text, 3, true); // 'Hello…'\n * truncate(text, 5, true, '...'); // 'Hello...'\n * ```\n *\n * @param str - The string to truncate.\n * @param limit - The maximum string length.\n * @param completeWords - If true, the string is truncated to the nearest word, instead of character.\n * @param ellipsis - The characters to end the truncated string with.\n *\n * @returns The truncated string.\n */\nexport function truncate(str: string, limit = 25, completeWords = false, ellipsis = '…'): string {\n if (str.length <= limit) return str;\n\n const _limit = completeWords ? str.substring(0, limit).lastIndexOf(' ') : limit;\n const effectiveLimit = _limit > 0 ? _limit : limit;\n\n return `${str.substring(0, effectiveLimit).trim()}${ellipsis}`;\n}\n"],"names":["truncate","str","limit","completeWords","ellipsis","_limit","effectiveLimit"],"mappings":"gFAkBO,SAASA,EAASC,EAAaC,EAAQ,GAAIC,EAAgB,GAAOC,EAAW,IAAa,CAC/F,GAAIH,EAAI,QAAUC,EAAO,OAAOD,EAEhC,MAAMI,EAASF,EAAgBF,EAAI,UAAU,EAAGC,CAAK,EAAE,YAAY,GAAG,EAAIA,EACpEI,EAAiBD,EAAS,EAAIA,EAASH,EAE7C,MAAO,GAAGD,EAAI,UAAU,EAAGK,CAAc,EAAE,KAAA,CAAM,GAAGF,CAAQ,EAC9D"}
1
+ {"version":3,"file":"truncate.cjs","sources":["../../src/string/truncate.ts"],"sourcesContent":["import { assert } from '../function/assert';\n\n/**\n * Truncates a string if it is longer than the given maximum string length. The last characters of the truncated string are replaced with the ellipsis sign \"…\".\n *\n * @example\n * ```ts\n * const text = 'Hello World';\n * truncate(text, 5); // 'Hello…'\n * truncate(text, 3, true); // 'Hello…'\n * truncate(text, 5, true, '...'); // 'Hello...'\n * ```\n *\n * @param str - The string to truncate.\n * @param limit - The maximum string length.\n * @param completeWords - If true, the string is truncated to the nearest word, instead of character.\n * @param ellipsis - The characters to end the truncated string with.\n *\n * @returns The truncated string.\n *\n * @throws {TypeError} If str is not a string or limit is not a positive number.\n */\nexport function truncate(str: string, limit = 25, completeWords = false, ellipsis = '…'): string {\n assert(typeof str === 'string', 'First argument must be a string', {\n args: { str },\n type: TypeError,\n });\n assert(\n typeof limit === 'number' && limit >= 0 && Number.isFinite(limit),\n 'Limit must be a non-negative finite number',\n { args: { limit }, type: TypeError },\n );\n\n if (str.length <= limit) {\n return str;\n }\n\n const _limit = completeWords ? str.substring(0, limit).lastIndexOf(' ') : limit;\n const effectiveLimit = _limit > 0 ? _limit : limit;\n\n return `${str.substring(0, effectiveLimit).trim()}${ellipsis}`;\n}\n"],"names":["truncate","str","limit","completeWords","ellipsis","assert","_limit","effectiveLimit"],"mappings":"0HAsBO,SAASA,EAASC,EAAaC,EAAQ,GAAIC,EAAgB,GAAOC,EAAW,IAAa,CAW/F,GAVAC,EAAAA,OAAO,OAAOJ,GAAQ,SAAU,kCAAmC,CACjE,KAAM,CAAE,IAAAA,CAAA,EACR,KAAM,SAAA,CACP,EACDI,EAAAA,OACE,OAAOH,GAAU,UAAYA,GAAS,GAAK,OAAO,SAASA,CAAK,EAChE,6CACA,CAAE,KAAM,CAAE,MAAAA,CAAA,EAAS,KAAM,SAAA,CAAU,EAGjCD,EAAI,QAAUC,EAChB,OAAOD,EAGT,MAAMK,EAASH,EAAgBF,EAAI,UAAU,EAAGC,CAAK,EAAE,YAAY,GAAG,EAAIA,EACpEK,EAAiBD,EAAS,EAAIA,EAASJ,EAE7C,MAAO,GAAGD,EAAI,UAAU,EAAGM,CAAc,EAAE,KAAA,CAAM,GAAGH,CAAQ,EAC9D"}
@@ -1,9 +1,18 @@
1
- function c(n, e = 25, f = !1, r = "") {
2
- if (n.length <= e) return n;
3
- const t = f ? n.substring(0, e).lastIndexOf(" ") : e, u = t > 0 ? t : e;
4
- return `${n.substring(0, u).trim()}${r}`;
1
+ import { assert as t } from "../function/assert.js";
2
+ function f(r, e = 25, s = !1, u = "…") {
3
+ if (t(typeof r == "string", "First argument must be a string", {
4
+ args: { str: r },
5
+ type: TypeError
6
+ }), t(
7
+ typeof e == "number" && e >= 0 && Number.isFinite(e),
8
+ "Limit must be a non-negative finite number",
9
+ { args: { limit: e }, type: TypeError }
10
+ ), r.length <= e)
11
+ return r;
12
+ const n = s ? r.substring(0, e).lastIndexOf(" ") : e, o = n > 0 ? n : e;
13
+ return `${r.substring(0, o).trim()}${u}`;
5
14
  }
6
15
  export {
7
- c as truncate
16
+ f as truncate
8
17
  };
9
18
  //# sourceMappingURL=truncate.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"truncate.js","sources":["../../src/string/truncate.ts"],"sourcesContent":["/**\n * Truncates a string if it is longer than the given maximum string length. The last characters of the truncated string are replaced with the ellipsis sign \"…\".\n *\n * @example\n * ```ts\n * const text = 'Hello World';\n * truncate(text, 5); // 'Hello…'\n * truncate(text, 3, true); // 'Hello…'\n * truncate(text, 5, true, '...'); // 'Hello...'\n * ```\n *\n * @param str - The string to truncate.\n * @param limit - The maximum string length.\n * @param completeWords - If true, the string is truncated to the nearest word, instead of character.\n * @param ellipsis - The characters to end the truncated string with.\n *\n * @returns The truncated string.\n */\nexport function truncate(str: string, limit = 25, completeWords = false, ellipsis = '…'): string {\n if (str.length <= limit) return str;\n\n const _limit = completeWords ? str.substring(0, limit).lastIndexOf(' ') : limit;\n const effectiveLimit = _limit > 0 ? _limit : limit;\n\n return `${str.substring(0, effectiveLimit).trim()}${ellipsis}`;\n}\n"],"names":["truncate","str","limit","completeWords","ellipsis","_limit","effectiveLimit"],"mappings":"AAkBO,SAASA,EAASC,GAAaC,IAAQ,IAAIC,IAAgB,IAAOC,IAAW,KAAa;AAC/F,MAAIH,EAAI,UAAUC,EAAO,QAAOD;AAEhC,QAAMI,IAASF,IAAgBF,EAAI,UAAU,GAAGC,CAAK,EAAE,YAAY,GAAG,IAAIA,GACpEI,IAAiBD,IAAS,IAAIA,IAASH;AAE7C,SAAO,GAAGD,EAAI,UAAU,GAAGK,CAAc,EAAE,KAAA,CAAM,GAAGF,CAAQ;AAC9D;"}
1
+ {"version":3,"file":"truncate.js","sources":["../../src/string/truncate.ts"],"sourcesContent":["import { assert } from '../function/assert';\n\n/**\n * Truncates a string if it is longer than the given maximum string length. The last characters of the truncated string are replaced with the ellipsis sign \"…\".\n *\n * @example\n * ```ts\n * const text = 'Hello World';\n * truncate(text, 5); // 'Hello…'\n * truncate(text, 3, true); // 'Hello…'\n * truncate(text, 5, true, '...'); // 'Hello...'\n * ```\n *\n * @param str - The string to truncate.\n * @param limit - The maximum string length.\n * @param completeWords - If true, the string is truncated to the nearest word, instead of character.\n * @param ellipsis - The characters to end the truncated string with.\n *\n * @returns The truncated string.\n *\n * @throws {TypeError} If str is not a string or limit is not a positive number.\n */\nexport function truncate(str: string, limit = 25, completeWords = false, ellipsis = '…'): string {\n assert(typeof str === 'string', 'First argument must be a string', {\n args: { str },\n type: TypeError,\n });\n assert(\n typeof limit === 'number' && limit >= 0 && Number.isFinite(limit),\n 'Limit must be a non-negative finite number',\n { args: { limit }, type: TypeError },\n );\n\n if (str.length <= limit) {\n return str;\n }\n\n const _limit = completeWords ? str.substring(0, limit).lastIndexOf(' ') : limit;\n const effectiveLimit = _limit > 0 ? _limit : limit;\n\n return `${str.substring(0, effectiveLimit).trim()}${ellipsis}`;\n}\n"],"names":["truncate","str","limit","completeWords","ellipsis","assert","_limit","effectiveLimit"],"mappings":";AAsBO,SAASA,EAASC,GAAaC,IAAQ,IAAIC,IAAgB,IAAOC,IAAW,KAAa;AAW/F,MAVAC,EAAO,OAAOJ,KAAQ,UAAU,mCAAmC;AAAA,IACjE,MAAM,EAAE,KAAAA,EAAA;AAAA,IACR,MAAM;AAAA,EAAA,CACP,GACDI;AAAA,IACE,OAAOH,KAAU,YAAYA,KAAS,KAAK,OAAO,SAASA,CAAK;AAAA,IAChE;AAAA,IACA,EAAE,MAAM,EAAE,OAAAA,EAAA,GAAS,MAAM,UAAA;AAAA,EAAU,GAGjCD,EAAI,UAAUC;AAChB,WAAOD;AAGT,QAAMK,IAASH,IAAgBF,EAAI,UAAU,GAAGC,CAAK,EAAE,YAAY,GAAG,IAAIA,GACpEK,IAAiBD,IAAS,IAAIA,IAASJ;AAE7C,SAAO,GAAGD,EAAI,UAAU,GAAGM,CAAc,EAAE,KAAA,CAAM,GAAGH,CAAQ;AAC9D;"}
package/dist/typed/is.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./ge.cjs"),n=require("./gt.cjs"),o=require("./isDefined.cjs"),c=require("./isEmpty.cjs"),r=require("./isEqual.cjs"),u=require("./isEven.cjs"),q=require("./isMatch.cjs"),l=require("./isNegative.cjs"),d=require("./isNil.cjs"),g=require("./isOdd.cjs"),a=require("./isPositive.cjs"),v=require("./isRegex.cjs"),p=require("./isWithin.cjs"),f=require("./isZero.cjs"),m=require("./le.cjs"),E=require("./lt.cjs"),h=require("./typeOf.cjs");function y(i,s){if(!i)throw new Error("Type must be provided");return{defined:o.isDefined,empty:c.isEmpty,eq:e=>r.isEqual(...e),even:u.isEven,ge:e=>t.ge(...e),gt:e=>n.gt(...e),le:e=>m.le(...e),lt:e=>E.lt(...e),match:e=>q.isMatch(...e),ne:e=>!r.isEqual(...e),negative:l.isNegative,nil:d.isNil,odd:g.isOdd,positive:a.isPositive,regex:v.isRegex,within:e=>p.isWithin(...e),zero:f.isZero}[i]?.(s)??h.typeOf(s)===i}exports.is=y;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../function/assert.cjs"),n=require("./ge.cjs"),o=require("./gt.cjs"),c=require("./isDefined.cjs"),u=require("./isEmpty.cjs"),r=require("./isEqual.cjs"),q=require("./isEven.cjs"),a=require("./isMatch.cjs"),l=require("./isNegative.cjs"),d=require("./isNil.cjs"),g=require("./isOdd.cjs"),v=require("./isPositive.cjs"),p=require("./isRegex.cjs"),m=require("./isWithin.cjs"),E=require("./isZero.cjs"),f=require("./le.cjs"),h=require("./lt.cjs"),y=require("./typeOf.cjs");function O(i,s){return t.assert(!!i,"Type must be provided",{args:{type:i},type:Error}),{defined:c.isDefined,empty:u.isEmpty,eq:e=>r.isEqual(...e),even:q.isEven,ge:e=>n.ge(...e),gt:e=>o.gt(...e),le:e=>f.le(...e),lt:e=>h.lt(...e),match:e=>a.isMatch(...e),ne:e=>!r.isEqual(...e),negative:l.isNegative,nil:d.isNil,odd:g.isOdd,positive:v.isPositive,regex:p.isRegex,within:e=>m.isWithin(...e),zero:E.isZero}[i]?.(s)??y.typeOf(s)===i}exports.is=O;
2
2
  //# sourceMappingURL=is.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"is.cjs","sources":["../../src/typed/is.ts"],"sourcesContent":["import { ge } from './ge';\nimport { gt } from './gt';\nimport { isDefined } from './isDefined';\nimport { isEmpty } from './isEmpty';\nimport { isEqual } from './isEqual';\nimport { isEven } from './isEven';\nimport { isMatch } from './isMatch';\nimport { isNegative } from './isNegative';\nimport { isNil } from './isNil';\nimport { isOdd } from './isOdd';\nimport { isPositive } from './isPositive';\nimport { isRegex } from './isRegex';\nimport { isWithin } from './isWithin';\nimport { isZero } from './isZero';\nimport { le } from './le';\nimport { lt } from './lt';\nimport { type ArgType, typeOf } from './typeOf';\n\ntype isType =\n | ArgType\n | 'defined'\n | 'empty'\n | 'eq'\n | 'even'\n | 'ge'\n | 'gt'\n | 'le'\n | 'lt'\n | 'match'\n | 'ne'\n | 'negative'\n | 'nil'\n | 'odd'\n | 'positive'\n | 'regex'\n | 'within'\n | 'zero';\n\n/**\n * @description\n * Checks if the value type of argument.\n *\n * @example\n * ```ts\n * is('array', []);\n * is('boolean', true);\n * is('date', new Date());\n * is('defined', 123);\n * is('empty', []);\n * is('even', 2);\n * is('function', () => {});\n * is('match', { a: 1, b: 2 }, { a: 1 });\n * is('nan', Number.NaN);\n * is('negative', -123);\n * is('nil', null);\n * is('null', null);\n * is('number', 123);\n * is('object', {});\n * is('odd', 3);\n * is('positive', 123);\n * is('string', 'hello');\n * is('symbol', Symbol('test'));\n * is('regex', /abc/);\n * is('string', 'hello world');\n * is('undefined', undefined);\n * is('within', 1, 2, 3);\n * is('zero', 0);\n * is('eq', [1, 2, 3], [1, 2, 3]);\n * is('ne', [1, 2, 3], [1, 2]);\n * is('ge', 5, 5);\n * is('gt', 5, 3);\n * is('le', 5, 5);\n * is('lt', 3, 5);\n * ```\n *\n * @param type - The type to check against.\n * @param args - The argument to be checked.\n *\n * @returns `true` if the value is of the specified type, else `false`.\n */\nexport function is(type: 'within', ...args: Parameters<typeof isWithin>): boolean;\nexport function is(type: 'eq', ...args: Parameters<typeof isEqual>): boolean;\nexport function is(type: 'ne', ...args: Parameters<typeof isEqual>): boolean;\nexport function is(type: 'gt', ...args: Parameters<typeof gt>): boolean;\nexport function is(type: 'ge', ...args: Parameters<typeof ge>): boolean;\nexport function is(type: 'lt', ...args: Parameters<typeof lt>): boolean;\nexport function is(type: 'le', ...args: Parameters<typeof le>): boolean;\nexport function is(type: 'match', ...args: Parameters<typeof isMatch>): boolean;\nexport function is(type: 'empty', ...args: Parameters<typeof isEmpty>): boolean;\nexport function is(type: 'array', arg: unknown): arg is Array<unknown>;\nexport function is(type: 'string', arg: unknown): arg is string;\nexport function is(type: 'number', arg: unknown): arg is number;\nexport function is(type: 'object', arg: unknown): arg is object;\nexport function is(type: 'nil', arg: unknown): arg is null | undefined;\nexport function is(type: 'primitive', arg: unknown): arg is string | number | boolean;\nexport function is(type: isType, arg: unknown): boolean;\nexport function is(type: string, arg: unknown): boolean {\n if (!type) {\n throw new Error('Type must be provided');\n }\n\n const compare = {\n defined: isDefined,\n empty: isEmpty,\n eq: (args: Parameters<typeof isEqual>) => isEqual(...args),\n even: isEven,\n ge: (args: Parameters<typeof ge>) => ge(...args),\n gt: (args: Parameters<typeof gt>) => gt(...args),\n le: (args: Parameters<typeof le>) => le(...args),\n lt: (args: Parameters<typeof lt>) => lt(...args),\n match: (args: Parameters<typeof isMatch>) => isMatch(...args),\n ne: (args: Parameters<typeof isEqual>) => !isEqual(...args),\n negative: isNegative,\n nil: isNil,\n odd: isOdd,\n positive: isPositive,\n regex: isRegex,\n within: (args: Parameters<typeof isWithin>) => isWithin(...args),\n zero: isZero,\n };\n\n return compare[type as keyof typeof compare]?.(arg) ?? typeOf(arg) === type;\n}\n"],"names":["is","type","arg","isDefined","isEmpty","args","isEqual","isEven","ge","gt","le","lt","isMatch","isNegative","isNil","isOdd","isPositive","isRegex","isWithin","isZero","typeOf"],"mappings":"+gBAgGO,SAASA,EAAGC,EAAcC,EAAuB,CACtD,GAAI,CAACD,EACH,MAAM,IAAI,MAAM,uBAAuB,EAuBzC,MApBgB,CACd,QAASE,EAAAA,UACT,MAAOC,EAAAA,QACP,GAAKC,GAAqCC,EAAAA,QAAQ,GAAGD,CAAI,EACzD,KAAME,EAAAA,OACN,GAAKF,GAAgCG,EAAAA,GAAG,GAAGH,CAAI,EAC/C,GAAKA,GAAgCI,EAAAA,GAAG,GAAGJ,CAAI,EAC/C,GAAKA,GAAgCK,EAAAA,GAAG,GAAGL,CAAI,EAC/C,GAAKA,GAAgCM,EAAAA,GAAG,GAAGN,CAAI,EAC/C,MAAQA,GAAqCO,EAAAA,QAAQ,GAAGP,CAAI,EAC5D,GAAKA,GAAqC,CAACC,EAAAA,QAAQ,GAAGD,CAAI,EAC1D,SAAUQ,EAAAA,WACV,IAAKC,EAAAA,MACL,IAAKC,EAAAA,MACL,SAAUC,EAAAA,WACV,MAAOC,EAAAA,QACP,OAASZ,GAAsCa,EAAAA,SAAS,GAAGb,CAAI,EAC/D,KAAMc,EAAAA,MAAA,EAGOlB,CAA4B,IAAIC,CAAG,GAAKkB,EAAAA,OAAOlB,CAAG,IAAMD,CACzE"}
1
+ {"version":3,"file":"is.cjs","sources":["../../src/typed/is.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { ge } from './ge';\nimport { gt } from './gt';\nimport { isDefined } from './isDefined';\nimport { isEmpty } from './isEmpty';\nimport { isEqual } from './isEqual';\nimport { isEven } from './isEven';\nimport { isMatch } from './isMatch';\nimport { isNegative } from './isNegative';\nimport { isNil } from './isNil';\nimport { isOdd } from './isOdd';\nimport { isPositive } from './isPositive';\nimport { isRegex } from './isRegex';\nimport { isWithin } from './isWithin';\nimport { isZero } from './isZero';\nimport { le } from './le';\nimport { lt } from './lt';\nimport { type ArgType, typeOf } from './typeOf';\n\ntype isType =\n | ArgType\n | 'defined'\n | 'empty'\n | 'eq'\n | 'even'\n | 'ge'\n | 'gt'\n | 'le'\n | 'lt'\n | 'match'\n | 'ne'\n | 'negative'\n | 'nil'\n | 'odd'\n | 'positive'\n | 'regex'\n | 'within'\n | 'zero';\n\n/**\n * @description\n * Checks if the value type of argument.\n *\n * @example\n * ```ts\n * is('array', []);\n * is('boolean', true);\n * is('date', new Date());\n * is('defined', 123);\n * is('empty', []);\n * is('even', 2);\n * is('function', () => {});\n * is('match', { a: 1, b: 2 }, { a: 1 });\n * is('nan', Number.NaN);\n * is('negative', -123);\n * is('nil', null);\n * is('null', null);\n * is('number', 123);\n * is('object', {});\n * is('odd', 3);\n * is('positive', 123);\n * is('string', 'hello');\n * is('symbol', Symbol('test'));\n * is('regex', /abc/);\n * is('string', 'hello world');\n * is('undefined', undefined);\n * is('within', 1, 2, 3);\n * is('zero', 0);\n * is('eq', [1, 2, 3], [1, 2, 3]);\n * is('ne', [1, 2, 3], [1, 2]);\n * is('ge', 5, 5);\n * is('gt', 5, 3);\n * is('le', 5, 5);\n * is('lt', 3, 5);\n * ```\n *\n * @param type - The type to check against.\n * @param args - The argument to be checked.\n *\n * @returns `true` if the value is of the specified type, else `false`.\n */\nexport function is(type: 'within', ...args: Parameters<typeof isWithin>): boolean;\nexport function is(type: 'eq', ...args: Parameters<typeof isEqual>): boolean;\nexport function is(type: 'ne', ...args: Parameters<typeof isEqual>): boolean;\nexport function is(type: 'gt', ...args: Parameters<typeof gt>): boolean;\nexport function is(type: 'ge', ...args: Parameters<typeof ge>): boolean;\nexport function is(type: 'lt', ...args: Parameters<typeof lt>): boolean;\nexport function is(type: 'le', ...args: Parameters<typeof le>): boolean;\nexport function is(type: 'match', ...args: Parameters<typeof isMatch>): boolean;\nexport function is(type: 'empty', ...args: Parameters<typeof isEmpty>): boolean;\nexport function is(type: 'array', arg: unknown): arg is Array<unknown>;\nexport function is(type: 'string', arg: unknown): arg is string;\nexport function is(type: 'number', arg: unknown): arg is number;\nexport function is(type: 'object', arg: unknown): arg is object;\nexport function is(type: 'nil', arg: unknown): arg is null | undefined;\nexport function is(type: 'primitive', arg: unknown): arg is string | number | boolean;\nexport function is(type: isType, arg: unknown): boolean;\nexport function is(type: string, arg: unknown): boolean {\n assert(Boolean(type), 'Type must be provided', { args: { type }, type: Error });\n\n const compare = {\n defined: isDefined,\n empty: isEmpty,\n eq: (args: Parameters<typeof isEqual>) => isEqual(...args),\n even: isEven,\n ge: (args: Parameters<typeof ge>) => ge(...args),\n gt: (args: Parameters<typeof gt>) => gt(...args),\n le: (args: Parameters<typeof le>) => le(...args),\n lt: (args: Parameters<typeof lt>) => lt(...args),\n match: (args: Parameters<typeof isMatch>) => isMatch(...args),\n ne: (args: Parameters<typeof isEqual>) => !isEqual(...args),\n negative: isNegative,\n nil: isNil,\n odd: isOdd,\n positive: isPositive,\n regex: isRegex,\n within: (args: Parameters<typeof isWithin>) => isWithin(...args),\n zero: isZero,\n };\n\n return compare[type as keyof typeof compare]?.(arg) ?? typeOf(arg) === type;\n}\n"],"names":["is","type","arg","assert","isDefined","isEmpty","args","isEqual","isEven","ge","gt","le","lt","isMatch","isNegative","isNil","isOdd","isPositive","isRegex","isWithin","isZero","typeOf"],"mappings":"mjBAiGO,SAASA,EAAGC,EAAcC,EAAuB,CACtDC,OAAAA,EAAAA,OAAO,EAAQF,EAAO,wBAAyB,CAAE,KAAM,CAAE,KAAAA,CAAA,EAAQ,KAAM,MAAO,EAE9D,CACd,QAASG,EAAAA,UACT,MAAOC,EAAAA,QACP,GAAKC,GAAqCC,EAAAA,QAAQ,GAAGD,CAAI,EACzD,KAAME,EAAAA,OACN,GAAKF,GAAgCG,EAAAA,GAAG,GAAGH,CAAI,EAC/C,GAAKA,GAAgCI,EAAAA,GAAG,GAAGJ,CAAI,EAC/C,GAAKA,GAAgCK,EAAAA,GAAG,GAAGL,CAAI,EAC/C,GAAKA,GAAgCM,EAAAA,GAAG,GAAGN,CAAI,EAC/C,MAAQA,GAAqCO,EAAAA,QAAQ,GAAGP,CAAI,EAC5D,GAAKA,GAAqC,CAACC,EAAAA,QAAQ,GAAGD,CAAI,EAC1D,SAAUQ,EAAAA,WACV,IAAKC,EAAAA,MACL,IAAKC,EAAAA,MACL,SAAUC,EAAAA,WACV,MAAOC,EAAAA,QACP,OAASZ,GAAsCa,EAAAA,SAAS,GAAGb,CAAI,EAC/D,KAAMc,EAAAA,MAAA,EAGOnB,CAA4B,IAAIC,CAAG,GAAKmB,EAAAA,OAAOnB,CAAG,IAAMD,CACzE"}
package/dist/typed/is.js CHANGED
@@ -1,44 +1,43 @@
1
- import { ge as t } from "./ge.js";
2
- import { gt as e } from "./gt.js";
3
- import { isDefined as p } from "./isDefined.js";
4
- import { isEmpty as f } from "./isEmpty.js";
1
+ import { assert as t } from "../function/assert.js";
2
+ import { ge as e } from "./ge.js";
3
+ import { gt as p } from "./gt.js";
4
+ import { isDefined as f } from "./isDefined.js";
5
+ import { isEmpty as s } from "./isEmpty.js";
5
6
  import { isEqual as m } from "./isEqual.js";
6
- import { isEven as s } from "./isEven.js";
7
- import { isMatch as n } from "./isMatch.js";
7
+ import { isEven as n } from "./isEven.js";
8
+ import { isMatch as a } from "./isMatch.js";
8
9
  import { isNegative as d } from "./isNegative.js";
9
10
  import { isNil as g } from "./isNil.js";
10
11
  import { isOdd as l } from "./isOdd.js";
11
12
  import { isPositive as v } from "./isPositive.js";
12
- import { isRegex as a } from "./isRegex.js";
13
- import { isWithin as c } from "./isWithin.js";
14
- import { isZero as h } from "./isZero.js";
15
- import { le as u } from "./le.js";
16
- import { lt as E } from "./lt.js";
17
- import { typeOf as w } from "./typeOf.js";
18
- function C(o, r) {
19
- if (!o)
20
- throw new Error("Type must be provided");
21
- return {
22
- defined: p,
23
- empty: f,
24
- eq: (i) => m(...i),
25
- even: s,
26
- ge: (i) => t(...i),
27
- gt: (i) => e(...i),
28
- le: (i) => u(...i),
29
- lt: (i) => E(...i),
30
- match: (i) => n(...i),
31
- ne: (i) => !m(...i),
13
+ import { isRegex as c } from "./isRegex.js";
14
+ import { isWithin as h } from "./isWithin.js";
15
+ import { isZero as u } from "./isZero.js";
16
+ import { le as E } from "./le.js";
17
+ import { lt as x } from "./lt.js";
18
+ import { typeOf as q } from "./typeOf.js";
19
+ function G(r, i) {
20
+ return t(!!r, "Type must be provided", { args: { type: r }, type: Error }), {
21
+ defined: f,
22
+ empty: s,
23
+ eq: (o) => m(...o),
24
+ even: n,
25
+ ge: (o) => e(...o),
26
+ gt: (o) => p(...o),
27
+ le: (o) => E(...o),
28
+ lt: (o) => x(...o),
29
+ match: (o) => a(...o),
30
+ ne: (o) => !m(...o),
32
31
  negative: d,
33
32
  nil: g,
34
33
  odd: l,
35
34
  positive: v,
36
- regex: a,
37
- within: (i) => c(...i),
38
- zero: h
39
- }[o]?.(r) ?? w(r) === o;
35
+ regex: c,
36
+ within: (o) => h(...o),
37
+ zero: u
38
+ }[r]?.(i) ?? q(i) === r;
40
39
  }
41
40
  export {
42
- C as is
41
+ G as is
43
42
  };
44
43
  //# sourceMappingURL=is.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"is.js","sources":["../../src/typed/is.ts"],"sourcesContent":["import { ge } from './ge';\nimport { gt } from './gt';\nimport { isDefined } from './isDefined';\nimport { isEmpty } from './isEmpty';\nimport { isEqual } from './isEqual';\nimport { isEven } from './isEven';\nimport { isMatch } from './isMatch';\nimport { isNegative } from './isNegative';\nimport { isNil } from './isNil';\nimport { isOdd } from './isOdd';\nimport { isPositive } from './isPositive';\nimport { isRegex } from './isRegex';\nimport { isWithin } from './isWithin';\nimport { isZero } from './isZero';\nimport { le } from './le';\nimport { lt } from './lt';\nimport { type ArgType, typeOf } from './typeOf';\n\ntype isType =\n | ArgType\n | 'defined'\n | 'empty'\n | 'eq'\n | 'even'\n | 'ge'\n | 'gt'\n | 'le'\n | 'lt'\n | 'match'\n | 'ne'\n | 'negative'\n | 'nil'\n | 'odd'\n | 'positive'\n | 'regex'\n | 'within'\n | 'zero';\n\n/**\n * @description\n * Checks if the value type of argument.\n *\n * @example\n * ```ts\n * is('array', []);\n * is('boolean', true);\n * is('date', new Date());\n * is('defined', 123);\n * is('empty', []);\n * is('even', 2);\n * is('function', () => {});\n * is('match', { a: 1, b: 2 }, { a: 1 });\n * is('nan', Number.NaN);\n * is('negative', -123);\n * is('nil', null);\n * is('null', null);\n * is('number', 123);\n * is('object', {});\n * is('odd', 3);\n * is('positive', 123);\n * is('string', 'hello');\n * is('symbol', Symbol('test'));\n * is('regex', /abc/);\n * is('string', 'hello world');\n * is('undefined', undefined);\n * is('within', 1, 2, 3);\n * is('zero', 0);\n * is('eq', [1, 2, 3], [1, 2, 3]);\n * is('ne', [1, 2, 3], [1, 2]);\n * is('ge', 5, 5);\n * is('gt', 5, 3);\n * is('le', 5, 5);\n * is('lt', 3, 5);\n * ```\n *\n * @param type - The type to check against.\n * @param args - The argument to be checked.\n *\n * @returns `true` if the value is of the specified type, else `false`.\n */\nexport function is(type: 'within', ...args: Parameters<typeof isWithin>): boolean;\nexport function is(type: 'eq', ...args: Parameters<typeof isEqual>): boolean;\nexport function is(type: 'ne', ...args: Parameters<typeof isEqual>): boolean;\nexport function is(type: 'gt', ...args: Parameters<typeof gt>): boolean;\nexport function is(type: 'ge', ...args: Parameters<typeof ge>): boolean;\nexport function is(type: 'lt', ...args: Parameters<typeof lt>): boolean;\nexport function is(type: 'le', ...args: Parameters<typeof le>): boolean;\nexport function is(type: 'match', ...args: Parameters<typeof isMatch>): boolean;\nexport function is(type: 'empty', ...args: Parameters<typeof isEmpty>): boolean;\nexport function is(type: 'array', arg: unknown): arg is Array<unknown>;\nexport function is(type: 'string', arg: unknown): arg is string;\nexport function is(type: 'number', arg: unknown): arg is number;\nexport function is(type: 'object', arg: unknown): arg is object;\nexport function is(type: 'nil', arg: unknown): arg is null | undefined;\nexport function is(type: 'primitive', arg: unknown): arg is string | number | boolean;\nexport function is(type: isType, arg: unknown): boolean;\nexport function is(type: string, arg: unknown): boolean {\n if (!type) {\n throw new Error('Type must be provided');\n }\n\n const compare = {\n defined: isDefined,\n empty: isEmpty,\n eq: (args: Parameters<typeof isEqual>) => isEqual(...args),\n even: isEven,\n ge: (args: Parameters<typeof ge>) => ge(...args),\n gt: (args: Parameters<typeof gt>) => gt(...args),\n le: (args: Parameters<typeof le>) => le(...args),\n lt: (args: Parameters<typeof lt>) => lt(...args),\n match: (args: Parameters<typeof isMatch>) => isMatch(...args),\n ne: (args: Parameters<typeof isEqual>) => !isEqual(...args),\n negative: isNegative,\n nil: isNil,\n odd: isOdd,\n positive: isPositive,\n regex: isRegex,\n within: (args: Parameters<typeof isWithin>) => isWithin(...args),\n zero: isZero,\n };\n\n return compare[type as keyof typeof compare]?.(arg) ?? typeOf(arg) === type;\n}\n"],"names":["is","type","arg","isDefined","isEmpty","args","isEqual","isEven","ge","gt","le","lt","isMatch","isNegative","isNil","isOdd","isPositive","isRegex","isWithin","isZero","typeOf"],"mappings":";;;;;;;;;;;;;;;;;AAgGO,SAASA,EAAGC,GAAcC,GAAuB;AACtD,MAAI,CAACD;AACH,UAAM,IAAI,MAAM,uBAAuB;AAuBzC,SApBgB;AAAA,IACd,SAASE;AAAA,IACT,OAAOC;AAAA,IACP,IAAI,CAACC,MAAqCC,EAAQ,GAAGD,CAAI;AAAA,IACzD,MAAME;AAAA,IACN,IAAI,CAACF,MAAgCG,EAAG,GAAGH,CAAI;AAAA,IAC/C,IAAI,CAACA,MAAgCI,EAAG,GAAGJ,CAAI;AAAA,IAC/C,IAAI,CAACA,MAAgCK,EAAG,GAAGL,CAAI;AAAA,IAC/C,IAAI,CAACA,MAAgCM,EAAG,GAAGN,CAAI;AAAA,IAC/C,OAAO,CAACA,MAAqCO,EAAQ,GAAGP,CAAI;AAAA,IAC5D,IAAI,CAACA,MAAqC,CAACC,EAAQ,GAAGD,CAAI;AAAA,IAC1D,UAAUQ;AAAA,IACV,KAAKC;AAAA,IACL,KAAKC;AAAA,IACL,UAAUC;AAAA,IACV,OAAOC;AAAA,IACP,QAAQ,CAACZ,MAAsCa,EAAS,GAAGb,CAAI;AAAA,IAC/D,MAAMc;AAAA,EAAA,EAGOlB,CAA4B,IAAIC,CAAG,KAAKkB,EAAOlB,CAAG,MAAMD;AACzE;"}
1
+ {"version":3,"file":"is.js","sources":["../../src/typed/is.ts"],"sourcesContent":["import { assert } from '../function/assert';\nimport { ge } from './ge';\nimport { gt } from './gt';\nimport { isDefined } from './isDefined';\nimport { isEmpty } from './isEmpty';\nimport { isEqual } from './isEqual';\nimport { isEven } from './isEven';\nimport { isMatch } from './isMatch';\nimport { isNegative } from './isNegative';\nimport { isNil } from './isNil';\nimport { isOdd } from './isOdd';\nimport { isPositive } from './isPositive';\nimport { isRegex } from './isRegex';\nimport { isWithin } from './isWithin';\nimport { isZero } from './isZero';\nimport { le } from './le';\nimport { lt } from './lt';\nimport { type ArgType, typeOf } from './typeOf';\n\ntype isType =\n | ArgType\n | 'defined'\n | 'empty'\n | 'eq'\n | 'even'\n | 'ge'\n | 'gt'\n | 'le'\n | 'lt'\n | 'match'\n | 'ne'\n | 'negative'\n | 'nil'\n | 'odd'\n | 'positive'\n | 'regex'\n | 'within'\n | 'zero';\n\n/**\n * @description\n * Checks if the value type of argument.\n *\n * @example\n * ```ts\n * is('array', []);\n * is('boolean', true);\n * is('date', new Date());\n * is('defined', 123);\n * is('empty', []);\n * is('even', 2);\n * is('function', () => {});\n * is('match', { a: 1, b: 2 }, { a: 1 });\n * is('nan', Number.NaN);\n * is('negative', -123);\n * is('nil', null);\n * is('null', null);\n * is('number', 123);\n * is('object', {});\n * is('odd', 3);\n * is('positive', 123);\n * is('string', 'hello');\n * is('symbol', Symbol('test'));\n * is('regex', /abc/);\n * is('string', 'hello world');\n * is('undefined', undefined);\n * is('within', 1, 2, 3);\n * is('zero', 0);\n * is('eq', [1, 2, 3], [1, 2, 3]);\n * is('ne', [1, 2, 3], [1, 2]);\n * is('ge', 5, 5);\n * is('gt', 5, 3);\n * is('le', 5, 5);\n * is('lt', 3, 5);\n * ```\n *\n * @param type - The type to check against.\n * @param args - The argument to be checked.\n *\n * @returns `true` if the value is of the specified type, else `false`.\n */\nexport function is(type: 'within', ...args: Parameters<typeof isWithin>): boolean;\nexport function is(type: 'eq', ...args: Parameters<typeof isEqual>): boolean;\nexport function is(type: 'ne', ...args: Parameters<typeof isEqual>): boolean;\nexport function is(type: 'gt', ...args: Parameters<typeof gt>): boolean;\nexport function is(type: 'ge', ...args: Parameters<typeof ge>): boolean;\nexport function is(type: 'lt', ...args: Parameters<typeof lt>): boolean;\nexport function is(type: 'le', ...args: Parameters<typeof le>): boolean;\nexport function is(type: 'match', ...args: Parameters<typeof isMatch>): boolean;\nexport function is(type: 'empty', ...args: Parameters<typeof isEmpty>): boolean;\nexport function is(type: 'array', arg: unknown): arg is Array<unknown>;\nexport function is(type: 'string', arg: unknown): arg is string;\nexport function is(type: 'number', arg: unknown): arg is number;\nexport function is(type: 'object', arg: unknown): arg is object;\nexport function is(type: 'nil', arg: unknown): arg is null | undefined;\nexport function is(type: 'primitive', arg: unknown): arg is string | number | boolean;\nexport function is(type: isType, arg: unknown): boolean;\nexport function is(type: string, arg: unknown): boolean {\n assert(Boolean(type), 'Type must be provided', { args: { type }, type: Error });\n\n const compare = {\n defined: isDefined,\n empty: isEmpty,\n eq: (args: Parameters<typeof isEqual>) => isEqual(...args),\n even: isEven,\n ge: (args: Parameters<typeof ge>) => ge(...args),\n gt: (args: Parameters<typeof gt>) => gt(...args),\n le: (args: Parameters<typeof le>) => le(...args),\n lt: (args: Parameters<typeof lt>) => lt(...args),\n match: (args: Parameters<typeof isMatch>) => isMatch(...args),\n ne: (args: Parameters<typeof isEqual>) => !isEqual(...args),\n negative: isNegative,\n nil: isNil,\n odd: isOdd,\n positive: isPositive,\n regex: isRegex,\n within: (args: Parameters<typeof isWithin>) => isWithin(...args),\n zero: isZero,\n };\n\n return compare[type as keyof typeof compare]?.(arg) ?? typeOf(arg) === type;\n}\n"],"names":["is","type","arg","assert","isDefined","isEmpty","args","isEqual","isEven","ge","gt","le","lt","isMatch","isNegative","isNil","isOdd","isPositive","isRegex","isWithin","isZero","typeOf"],"mappings":";;;;;;;;;;;;;;;;;;AAiGO,SAASA,EAAGC,GAAcC,GAAuB;AACtD,SAAAC,EAAO,EAAQF,GAAO,yBAAyB,EAAE,MAAM,EAAE,MAAAA,EAAA,GAAQ,MAAM,OAAO,GAE9D;AAAA,IACd,SAASG;AAAA,IACT,OAAOC;AAAA,IACP,IAAI,CAACC,MAAqCC,EAAQ,GAAGD,CAAI;AAAA,IACzD,MAAME;AAAA,IACN,IAAI,CAACF,MAAgCG,EAAG,GAAGH,CAAI;AAAA,IAC/C,IAAI,CAACA,MAAgCI,EAAG,GAAGJ,CAAI;AAAA,IAC/C,IAAI,CAACA,MAAgCK,EAAG,GAAGL,CAAI;AAAA,IAC/C,IAAI,CAACA,MAAgCM,EAAG,GAAGN,CAAI;AAAA,IAC/C,OAAO,CAACA,MAAqCO,EAAQ,GAAGP,CAAI;AAAA,IAC5D,IAAI,CAACA,MAAqC,CAACC,EAAQ,GAAGD,CAAI;AAAA,IAC1D,UAAUQ;AAAA,IACV,KAAKC;AAAA,IACL,KAAKC;AAAA,IACL,UAAUC;AAAA,IACV,OAAOC;AAAA,IACP,QAAQ,CAACZ,MAAsCa,EAAS,GAAGb,CAAI;AAAA,IAC/D,MAAMc;AAAA,EAAA,EAGOnB,CAA4B,IAAIC,CAAG,KAAKmB,EAAOnB,CAAG,MAAMD;AACzE;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./isArray.cjs"),i=require("./isNil.cjs"),s=require("./isObject.cjs");function n(e){return i.isNil(e)||e===""||t.isArray(e)&&e.length===0||s.isObject(e)&&Object.keys(e).length===0}const c="Expected an empty value";exports.IS_EMPTY_ERROR_MSG=c;exports.isEmpty=n;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./isArray.cjs"),i=require("./isNil.cjs"),n=require("./isObject.cjs");function s(e){return i.isNil(e)||e===""?!0:t.isArray(e)?e.length===0:e instanceof Map||e instanceof Set?e.size===0:n.isObject(e)?Object.keys(e).length===0:!1}const r="Expected an empty value";exports.IS_EMPTY_ERROR_MSG=r;exports.isEmpty=s;
2
2
  //# sourceMappingURL=isEmpty.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"isEmpty.cjs","sources":["../../src/typed/isEmpty.ts"],"sourcesContent":["import { isArray } from './isArray';\nimport { isNil } from './isNil';\nimport { isObject } from './isObject';\n\n/**\n * Checks if the given argument is empty.\n *\n * @example\n * ```ts\n * isEmpty(null); // true\n * isEmpty(undefined); // true\n * isEmpty([]); // true\n * isEmpty({}); // true\n * isEmpty(''); // true\n * isEmpty(0); // false\n * isEmpty(123); // false\n * isEmpty('abc'); // false\n * isEmpty([1, 2, 3]); // false\n * isEmpty({ a: 1, b: 2 }); // false\n * ```\n *\n * @param arg - The argument to be checked.\n *\n * @returns `true` if all arguments are `null`, `undefined`, `{}`, `[]`, or empty strings. Otherwise, it returns `false`.\n */\n// biome-ignore lint/suspicious/noExplicitAny: -\nexport function isEmpty(arg: any): boolean {\n return (\n isNil(arg) || arg === '' || (isArray(arg) && arg.length === 0) || (isObject(arg) && Object.keys(arg).length === 0)\n );\n}\n\nexport const IS_EMPTY_ERROR_MSG = 'Expected an empty value';\n"],"names":["isEmpty","arg","isNil","isArray","isObject","IS_EMPTY_ERROR_MSG"],"mappings":"sKA0BO,SAASA,EAAQC,EAAmB,CACzC,OACEC,EAAAA,MAAMD,CAAG,GAAKA,IAAQ,IAAOE,EAAAA,QAAQF,CAAG,GAAKA,EAAI,SAAW,GAAOG,EAAAA,SAASH,CAAG,GAAK,OAAO,KAAKA,CAAG,EAAE,SAAW,CAEpH,CAEO,MAAMI,EAAqB"}
1
+ {"version":3,"file":"isEmpty.cjs","sources":["../../src/typed/isEmpty.ts"],"sourcesContent":["import { isArray } from './isArray';\nimport { isNil } from './isNil';\nimport { isObject } from './isObject';\n\n/**\n * Checks if the given argument is empty.\n *\n * @example\n * ```ts\n * isEmpty(null); // true\n * isEmpty(undefined); // true\n * isEmpty([]); // true\n * isEmpty({}); // true\n * isEmpty(''); // true\n * isEmpty(0); // false\n * isEmpty(123); // false\n * isEmpty('abc'); // false\n * isEmpty([1, 2, 3]); // false\n * isEmpty({ a: 1, b: 2 }); // false\n * ```\n *\n * @param arg - The argument to be checked.\n *\n * @returns `true` if all arguments are `null`, `undefined`, `{}`, `[]`, or empty strings. Otherwise, it returns `false`.\n */\n// biome-ignore lint/suspicious/noExplicitAny: -\nexport function isEmpty(arg: any): boolean {\n if (isNil(arg) || arg === '') return true;\n if (isArray(arg)) return arg.length === 0;\n if (arg instanceof Map || arg instanceof Set) return arg.size === 0;\n if (isObject(arg)) return Object.keys(arg).length === 0;\n return false;\n}\n\nexport const IS_EMPTY_ERROR_MSG = 'Expected an empty value';\n"],"names":["isEmpty","arg","isNil","isArray","isObject","IS_EMPTY_ERROR_MSG"],"mappings":"sKA0BO,SAASA,EAAQC,EAAmB,CACzC,OAAIC,EAAAA,MAAMD,CAAG,GAAKA,IAAQ,GAAW,GACjCE,EAAAA,QAAQF,CAAG,EAAUA,EAAI,SAAW,EACpCA,aAAe,KAAOA,aAAe,IAAYA,EAAI,OAAS,EAC9DG,EAAAA,SAASH,CAAG,EAAU,OAAO,KAAKA,CAAG,EAAE,SAAW,EAC/C,EACT,CAEO,MAAMI,EAAqB"}
@@ -1,12 +1,12 @@
1
1
  import { isArray as e } from "./isArray.js";
2
2
  import { isNil as i } from "./isNil.js";
3
- import { isObject as o } from "./isObject.js";
4
- function r(t) {
5
- return i(t) || t === "" || e(t) && t.length === 0 || o(t) && Object.keys(t).length === 0;
3
+ import { isObject as n } from "./isObject.js";
4
+ function s(t) {
5
+ return i(t) || t === "" ? !0 : e(t) ? t.length === 0 : t instanceof Map || t instanceof Set ? t.size === 0 : n(t) ? Object.keys(t).length === 0 : !1;
6
6
  }
7
- const s = "Expected an empty value";
7
+ const m = "Expected an empty value";
8
8
  export {
9
- s as IS_EMPTY_ERROR_MSG,
10
- r as isEmpty
9
+ m as IS_EMPTY_ERROR_MSG,
10
+ s as isEmpty
11
11
  };
12
12
  //# sourceMappingURL=isEmpty.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"isEmpty.js","sources":["../../src/typed/isEmpty.ts"],"sourcesContent":["import { isArray } from './isArray';\nimport { isNil } from './isNil';\nimport { isObject } from './isObject';\n\n/**\n * Checks if the given argument is empty.\n *\n * @example\n * ```ts\n * isEmpty(null); // true\n * isEmpty(undefined); // true\n * isEmpty([]); // true\n * isEmpty({}); // true\n * isEmpty(''); // true\n * isEmpty(0); // false\n * isEmpty(123); // false\n * isEmpty('abc'); // false\n * isEmpty([1, 2, 3]); // false\n * isEmpty({ a: 1, b: 2 }); // false\n * ```\n *\n * @param arg - The argument to be checked.\n *\n * @returns `true` if all arguments are `null`, `undefined`, `{}`, `[]`, or empty strings. Otherwise, it returns `false`.\n */\n// biome-ignore lint/suspicious/noExplicitAny: -\nexport function isEmpty(arg: any): boolean {\n return (\n isNil(arg) || arg === '' || (isArray(arg) && arg.length === 0) || (isObject(arg) && Object.keys(arg).length === 0)\n );\n}\n\nexport const IS_EMPTY_ERROR_MSG = 'Expected an empty value';\n"],"names":["isEmpty","arg","isNil","isArray","isObject","IS_EMPTY_ERROR_MSG"],"mappings":";;;AA0BO,SAASA,EAAQC,GAAmB;AACzC,SACEC,EAAMD,CAAG,KAAKA,MAAQ,MAAOE,EAAQF,CAAG,KAAKA,EAAI,WAAW,KAAOG,EAASH,CAAG,KAAK,OAAO,KAAKA,CAAG,EAAE,WAAW;AAEpH;AAEO,MAAMI,IAAqB;"}
1
+ {"version":3,"file":"isEmpty.js","sources":["../../src/typed/isEmpty.ts"],"sourcesContent":["import { isArray } from './isArray';\nimport { isNil } from './isNil';\nimport { isObject } from './isObject';\n\n/**\n * Checks if the given argument is empty.\n *\n * @example\n * ```ts\n * isEmpty(null); // true\n * isEmpty(undefined); // true\n * isEmpty([]); // true\n * isEmpty({}); // true\n * isEmpty(''); // true\n * isEmpty(0); // false\n * isEmpty(123); // false\n * isEmpty('abc'); // false\n * isEmpty([1, 2, 3]); // false\n * isEmpty({ a: 1, b: 2 }); // false\n * ```\n *\n * @param arg - The argument to be checked.\n *\n * @returns `true` if all arguments are `null`, `undefined`, `{}`, `[]`, or empty strings. Otherwise, it returns `false`.\n */\n// biome-ignore lint/suspicious/noExplicitAny: -\nexport function isEmpty(arg: any): boolean {\n if (isNil(arg) || arg === '') return true;\n if (isArray(arg)) return arg.length === 0;\n if (arg instanceof Map || arg instanceof Set) return arg.size === 0;\n if (isObject(arg)) return Object.keys(arg).length === 0;\n return false;\n}\n\nexport const IS_EMPTY_ERROR_MSG = 'Expected an empty value';\n"],"names":["isEmpty","arg","isNil","isArray","isObject","IS_EMPTY_ERROR_MSG"],"mappings":";;;AA0BO,SAASA,EAAQC,GAAmB;AACzC,SAAIC,EAAMD,CAAG,KAAKA,MAAQ,KAAW,KACjCE,EAAQF,CAAG,IAAUA,EAAI,WAAW,IACpCA,aAAe,OAAOA,aAAe,MAAYA,EAAI,SAAS,IAC9DG,EAASH,CAAG,IAAU,OAAO,KAAKA,CAAG,EAAE,WAAW,IAC/C;AACT;AAEO,MAAMI,IAAqB;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function n(e,t){if(e===t)return!0;if(e==null||t==null||typeof e!=typeof t||typeof e!="object"||typeof t!="object")return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}if(Array.isArray(e)!==Array.isArray(t))return!1;if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();const f=Object.keys(e),s=Object.keys(t);if(f.length!==s.length)return!1;for(const r of f)if(!Object.hasOwn(t,r)||!n(e[r],t[r]))return!1;return!0}const i="Expected two values to be equal";exports.IS_EQUAL_ERROR_MSG=i;exports.isEqual=n;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function l(e,r){return f(e,r,new WeakMap)}function f(e,r,n){if(e===r)return!0;if(e==null||r==null||typeof e!=typeof r||typeof e!="object"||typeof r!="object")return!1;if(n.has(e))return n.get(e)===r;if(n.set(e,r),Array.isArray(e)&&Array.isArray(r)){if(e.length!==r.length)return!1;for(let t=0;t<e.length;t++)if(!f(e[t],r[t],n))return!1;return!0}if(Array.isArray(e)!==Array.isArray(r))return!1;if(e instanceof Date&&r instanceof Date)return e.getTime()===r.getTime();const u=Object.keys(e),s=Object.keys(r);if(u.length!==s.length)return!1;for(const t of u)if(!Object.hasOwn(r,t)||!f(e[t],r[t],n))return!1;return!0}const o="Expected two values to be equal";exports.IS_EQUAL_ERROR_MSG=o;exports.isEqual=l;
2
2
  //# sourceMappingURL=isEqual.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"isEqual.cjs","sources":["../../src/typed/isEqual.ts"],"sourcesContent":["/**\n * Deeply compares two values for equality, including objects, arrays, and primitives.\n * Detects circular references and optimizes performance.\n *\n * @example\n * ```ts\n * isEqual([1, 2, 3], [1, 2, 3]); // true\n * isEqual([1, 2], [1, 2, 3]); // false\n * isEqual({ a: 1, b: 2 }, { a: 1, b: 2 }); // true\n * isEqual({ a: { b: 2 } }, { a: { b: 2 } }); // true\n * isEqual({ a: 1 }, { a: 2 }); // false\n * isEqual({ a: 1 }, { b: 1 }); // false\n * isEqual(new Date('2023-01-01'), new Date('2023-01-01')); // true\n * isEqual(new Date('2023-01-01'), new Date('2023-01-02')); // false\n * isEqual(new Date('2023-01-01'), 1); // false\n * ```\n *\n * @param a - First value to compare.\n * @param b - Second value to compare.\n * @returns Whether the values are deeply equal.\n */\n// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: -\nexport function isEqual(a: unknown, b: unknown): boolean {\n // Check for strict equality (handles primitives and references)\n if (a === b) return true;\n\n // If either is null or not an object, they're not equal\n if (a == null || b == null || typeof a !== typeof b || typeof a !== 'object' || typeof b !== 'object') return false;\n\n // Array comparison\n if (Array.isArray(a) && Array.isArray(b)) {\n if (a.length !== b.length) return false;\n for (let idx = 0; idx < a.length; idx++) {\n if (!isEqual(a[idx], b[idx])) return false;\n }\n return true;\n }\n\n // Ensure both are arrays or neither is\n if (Array.isArray(a) !== Array.isArray(b)) return false;\n\n // Date comparison\n if (a instanceof Date && b instanceof Date) {\n return a.getTime() === b.getTime();\n }\n\n // Object comparison\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n\n if (keysA.length !== keysB.length) return false;\n\n for (const key of keysA) {\n if (!Object.hasOwn(b, key) || !isEqual((a as Record<string, unknown>)[key], (b as Record<string, unknown>)[key]))\n return false;\n }\n\n return true;\n}\n\nexport const IS_EQUAL_ERROR_MSG = 'Expected two values to be equal';\n"],"names":["isEqual","a","b","idx","keysA","keysB","key","IS_EQUAL_ERROR_MSG"],"mappings":"gFAsBO,SAASA,EAAQC,EAAYC,EAAqB,CAEvD,GAAID,IAAMC,EAAG,MAAO,GAGpB,GAAID,GAAK,MAAQC,GAAK,MAAQ,OAAOD,GAAM,OAAOC,GAAK,OAAOD,GAAM,UAAY,OAAOC,GAAM,SAAU,MAAO,GAG9G,GAAI,MAAM,QAAQD,CAAC,GAAK,MAAM,QAAQC,CAAC,EAAG,CACxC,GAAID,EAAE,SAAWC,EAAE,OAAQ,MAAO,GAClC,QAASC,EAAM,EAAGA,EAAMF,EAAE,OAAQE,IAChC,GAAI,CAACH,EAAQC,EAAEE,CAAG,EAAGD,EAAEC,CAAG,CAAC,EAAG,MAAO,GAEvC,MAAO,EACT,CAGA,GAAI,MAAM,QAAQF,CAAC,IAAM,MAAM,QAAQC,CAAC,EAAG,MAAO,GAGlD,GAAID,aAAa,MAAQC,aAAa,KACpC,OAAOD,EAAE,YAAcC,EAAE,QAAA,EAI3B,MAAME,EAAQ,OAAO,KAAKH,CAAC,EACrBI,EAAQ,OAAO,KAAKH,CAAC,EAE3B,GAAIE,EAAM,SAAWC,EAAM,OAAQ,MAAO,GAE1C,UAAWC,KAAOF,EAChB,GAAI,CAAC,OAAO,OAAOF,EAAGI,CAAG,GAAK,CAACN,EAASC,EAA8BK,CAAG,EAAIJ,EAA8BI,CAAG,CAAC,EAC7G,MAAO,GAGX,MAAO,EACT,CAEO,MAAMC,EAAqB"}
1
+ {"version":3,"file":"isEqual.cjs","sources":["../../src/typed/isEqual.ts"],"sourcesContent":["/**\n * Deeply compares two values for equality, including objects, arrays, and primitives.\n * Detects circular references and optimizes performance.\n *\n * @example\n * ```ts\n * isEqual([1, 2, 3], [1, 2, 3]); // true\n * isEqual([1, 2], [1, 2, 3]); // false\n * isEqual({ a: 1, b: 2 }, { a: 1, b: 2 }); // true\n * isEqual({ a: { b: 2 } }, { a: { b: 2 } }); // true\n * isEqual({ a: 1 }, { a: 2 }); // false\n * isEqual({ a: 1 }, { b: 1 }); // false\n * isEqual(new Date('2023-01-01'), new Date('2023-01-01')); // true\n * isEqual(new Date('2023-01-01'), new Date('2023-01-02')); // false\n * isEqual(new Date('2023-01-01'), 1); // false\n * ```\n *\n * @param a - First value to compare.\n * @param b - Second value to compare.\n * @returns Whether the values are deeply equal.\n */\nexport function isEqual(a: unknown, b: unknown): boolean {\n return safeIsEqual(a, b, new WeakMap());\n}\n\n// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: -\nfunction safeIsEqual(a: unknown, b: unknown, visited: WeakMap<object, object>): boolean {\n // Check for strict equality (handles primitives and references)\n if (a === b) return true;\n\n // If either is null or not an object, they're not equal\n if (a == null || b == null || typeof a !== typeof b || typeof a !== 'object' || typeof b !== 'object') return false;\n\n // Check for circular references\n // We only track 'a' because if 'a' is cyclical, 'b' must also be cyclic to be equal\n if (visited.has(a as object)) {\n return visited.get(a as object) === b;\n }\n visited.set(a as object, b as object);\n\n // Array comparison\n if (Array.isArray(a) && Array.isArray(b)) {\n if (a.length !== b.length) return false;\n for (let idx = 0; idx < a.length; idx++) {\n if (!safeIsEqual(a[idx], b[idx], visited)) return false;\n }\n return true;\n }\n\n // Ensure both are arrays or neither is\n if (Array.isArray(a) !== Array.isArray(b)) return false;\n\n // Date comparison\n if (a instanceof Date && b instanceof Date) {\n return a.getTime() === b.getTime();\n }\n\n // Object comparison\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n\n if (keysA.length !== keysB.length) return false;\n\n for (const key of keysA) {\n if (\n !Object.hasOwn(b, key) ||\n !safeIsEqual((a as Record<string, unknown>)[key], (b as Record<string, unknown>)[key], visited)\n )\n return false;\n }\n\n return true;\n}\n\nexport const IS_EQUAL_ERROR_MSG = 'Expected two values to be equal';\n"],"names":["isEqual","a","b","safeIsEqual","visited","idx","keysA","keysB","key","IS_EQUAL_ERROR_MSG"],"mappings":"gFAqBO,SAASA,EAAQC,EAAYC,EAAqB,CACvD,OAAOC,EAAYF,EAAGC,EAAG,IAAI,OAAS,CACxC,CAGA,SAASC,EAAYF,EAAYC,EAAYE,EAA2C,CAEtF,GAAIH,IAAMC,EAAG,MAAO,GAGpB,GAAID,GAAK,MAAQC,GAAK,MAAQ,OAAOD,GAAM,OAAOC,GAAK,OAAOD,GAAM,UAAY,OAAOC,GAAM,SAAU,MAAO,GAI9G,GAAIE,EAAQ,IAAIH,CAAW,EACzB,OAAOG,EAAQ,IAAIH,CAAW,IAAMC,EAKtC,GAHAE,EAAQ,IAAIH,EAAaC,CAAW,EAGhC,MAAM,QAAQD,CAAC,GAAK,MAAM,QAAQC,CAAC,EAAG,CACxC,GAAID,EAAE,SAAWC,EAAE,OAAQ,MAAO,GAClC,QAASG,EAAM,EAAGA,EAAMJ,EAAE,OAAQI,IAChC,GAAI,CAACF,EAAYF,EAAEI,CAAG,EAAGH,EAAEG,CAAG,EAAGD,CAAO,EAAG,MAAO,GAEpD,MAAO,EACT,CAGA,GAAI,MAAM,QAAQH,CAAC,IAAM,MAAM,QAAQC,CAAC,EAAG,MAAO,GAGlD,GAAID,aAAa,MAAQC,aAAa,KACpC,OAAOD,EAAE,YAAcC,EAAE,QAAA,EAI3B,MAAMI,EAAQ,OAAO,KAAKL,CAAC,EACrBM,EAAQ,OAAO,KAAKL,CAAC,EAE3B,GAAII,EAAM,SAAWC,EAAM,OAAQ,MAAO,GAE1C,UAAWC,KAAOF,EAChB,GACE,CAAC,OAAO,OAAOJ,EAAGM,CAAG,GACrB,CAACL,EAAaF,EAA8BO,CAAG,EAAIN,EAA8BM,CAAG,EAAGJ,CAAO,EAE9F,MAAO,GAGX,MAAO,EACT,CAEO,MAAMK,EAAqB"}
@@ -1,25 +1,30 @@
1
- function f(e, t) {
2
- if (e === t) return !0;
3
- if (e == null || t == null || typeof e != typeof t || typeof e != "object" || typeof t != "object") return !1;
4
- if (Array.isArray(e) && Array.isArray(t)) {
5
- if (e.length !== t.length) return !1;
6
- for (let r = 0; r < e.length; r++)
7
- if (!f(e[r], t[r])) return !1;
1
+ function l(e, r) {
2
+ return f(e, r, /* @__PURE__ */ new WeakMap());
3
+ }
4
+ function f(e, r, n) {
5
+ if (e === r) return !0;
6
+ if (e == null || r == null || typeof e != typeof r || typeof e != "object" || typeof r != "object") return !1;
7
+ if (n.has(e))
8
+ return n.get(e) === r;
9
+ if (n.set(e, r), Array.isArray(e) && Array.isArray(r)) {
10
+ if (e.length !== r.length) return !1;
11
+ for (let t = 0; t < e.length; t++)
12
+ if (!f(e[t], r[t], n)) return !1;
8
13
  return !0;
9
14
  }
10
- if (Array.isArray(e) !== Array.isArray(t)) return !1;
11
- if (e instanceof Date && t instanceof Date)
12
- return e.getTime() === t.getTime();
13
- const n = Object.keys(e), s = Object.keys(t);
14
- if (n.length !== s.length) return !1;
15
- for (const r of n)
16
- if (!Object.hasOwn(t, r) || !f(e[r], t[r]))
15
+ if (Array.isArray(e) !== Array.isArray(r)) return !1;
16
+ if (e instanceof Date && r instanceof Date)
17
+ return e.getTime() === r.getTime();
18
+ const s = Object.keys(e), u = Object.keys(r);
19
+ if (s.length !== u.length) return !1;
20
+ for (const t of s)
21
+ if (!Object.hasOwn(r, t) || !f(e[t], r[t], n))
17
22
  return !1;
18
23
  return !0;
19
24
  }
20
- const i = "Expected two values to be equal";
25
+ const o = "Expected two values to be equal";
21
26
  export {
22
- i as IS_EQUAL_ERROR_MSG,
23
- f as isEqual
27
+ o as IS_EQUAL_ERROR_MSG,
28
+ l as isEqual
24
29
  };
25
30
  //# sourceMappingURL=isEqual.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"isEqual.js","sources":["../../src/typed/isEqual.ts"],"sourcesContent":["/**\n * Deeply compares two values for equality, including objects, arrays, and primitives.\n * Detects circular references and optimizes performance.\n *\n * @example\n * ```ts\n * isEqual([1, 2, 3], [1, 2, 3]); // true\n * isEqual([1, 2], [1, 2, 3]); // false\n * isEqual({ a: 1, b: 2 }, { a: 1, b: 2 }); // true\n * isEqual({ a: { b: 2 } }, { a: { b: 2 } }); // true\n * isEqual({ a: 1 }, { a: 2 }); // false\n * isEqual({ a: 1 }, { b: 1 }); // false\n * isEqual(new Date('2023-01-01'), new Date('2023-01-01')); // true\n * isEqual(new Date('2023-01-01'), new Date('2023-01-02')); // false\n * isEqual(new Date('2023-01-01'), 1); // false\n * ```\n *\n * @param a - First value to compare.\n * @param b - Second value to compare.\n * @returns Whether the values are deeply equal.\n */\n// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: -\nexport function isEqual(a: unknown, b: unknown): boolean {\n // Check for strict equality (handles primitives and references)\n if (a === b) return true;\n\n // If either is null or not an object, they're not equal\n if (a == null || b == null || typeof a !== typeof b || typeof a !== 'object' || typeof b !== 'object') return false;\n\n // Array comparison\n if (Array.isArray(a) && Array.isArray(b)) {\n if (a.length !== b.length) return false;\n for (let idx = 0; idx < a.length; idx++) {\n if (!isEqual(a[idx], b[idx])) return false;\n }\n return true;\n }\n\n // Ensure both are arrays or neither is\n if (Array.isArray(a) !== Array.isArray(b)) return false;\n\n // Date comparison\n if (a instanceof Date && b instanceof Date) {\n return a.getTime() === b.getTime();\n }\n\n // Object comparison\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n\n if (keysA.length !== keysB.length) return false;\n\n for (const key of keysA) {\n if (!Object.hasOwn(b, key) || !isEqual((a as Record<string, unknown>)[key], (b as Record<string, unknown>)[key]))\n return false;\n }\n\n return true;\n}\n\nexport const IS_EQUAL_ERROR_MSG = 'Expected two values to be equal';\n"],"names":["isEqual","a","b","idx","keysA","keysB","key","IS_EQUAL_ERROR_MSG"],"mappings":"AAsBO,SAASA,EAAQC,GAAYC,GAAqB;AAEvD,MAAID,MAAMC,EAAG,QAAO;AAGpB,MAAID,KAAK,QAAQC,KAAK,QAAQ,OAAOD,KAAM,OAAOC,KAAK,OAAOD,KAAM,YAAY,OAAOC,KAAM,SAAU,QAAO;AAG9G,MAAI,MAAM,QAAQD,CAAC,KAAK,MAAM,QAAQC,CAAC,GAAG;AACxC,QAAID,EAAE,WAAWC,EAAE,OAAQ,QAAO;AAClC,aAASC,IAAM,GAAGA,IAAMF,EAAE,QAAQE;AAChC,UAAI,CAACH,EAAQC,EAAEE,CAAG,GAAGD,EAAEC,CAAG,CAAC,EAAG,QAAO;AAEvC,WAAO;AAAA,EACT;AAGA,MAAI,MAAM,QAAQF,CAAC,MAAM,MAAM,QAAQC,CAAC,EAAG,QAAO;AAGlD,MAAID,aAAa,QAAQC,aAAa;AACpC,WAAOD,EAAE,cAAcC,EAAE,QAAA;AAI3B,QAAME,IAAQ,OAAO,KAAKH,CAAC,GACrBI,IAAQ,OAAO,KAAKH,CAAC;AAE3B,MAAIE,EAAM,WAAWC,EAAM,OAAQ,QAAO;AAE1C,aAAWC,KAAOF;AAChB,QAAI,CAAC,OAAO,OAAOF,GAAGI,CAAG,KAAK,CAACN,EAASC,EAA8BK,CAAG,GAAIJ,EAA8BI,CAAG,CAAC;AAC7G,aAAO;AAGX,SAAO;AACT;AAEO,MAAMC,IAAqB;"}
1
+ {"version":3,"file":"isEqual.js","sources":["../../src/typed/isEqual.ts"],"sourcesContent":["/**\n * Deeply compares two values for equality, including objects, arrays, and primitives.\n * Detects circular references and optimizes performance.\n *\n * @example\n * ```ts\n * isEqual([1, 2, 3], [1, 2, 3]); // true\n * isEqual([1, 2], [1, 2, 3]); // false\n * isEqual({ a: 1, b: 2 }, { a: 1, b: 2 }); // true\n * isEqual({ a: { b: 2 } }, { a: { b: 2 } }); // true\n * isEqual({ a: 1 }, { a: 2 }); // false\n * isEqual({ a: 1 }, { b: 1 }); // false\n * isEqual(new Date('2023-01-01'), new Date('2023-01-01')); // true\n * isEqual(new Date('2023-01-01'), new Date('2023-01-02')); // false\n * isEqual(new Date('2023-01-01'), 1); // false\n * ```\n *\n * @param a - First value to compare.\n * @param b - Second value to compare.\n * @returns Whether the values are deeply equal.\n */\nexport function isEqual(a: unknown, b: unknown): boolean {\n return safeIsEqual(a, b, new WeakMap());\n}\n\n// biome-ignore lint/complexity/noExcessiveCognitiveComplexity: -\nfunction safeIsEqual(a: unknown, b: unknown, visited: WeakMap<object, object>): boolean {\n // Check for strict equality (handles primitives and references)\n if (a === b) return true;\n\n // If either is null or not an object, they're not equal\n if (a == null || b == null || typeof a !== typeof b || typeof a !== 'object' || typeof b !== 'object') return false;\n\n // Check for circular references\n // We only track 'a' because if 'a' is cyclical, 'b' must also be cyclic to be equal\n if (visited.has(a as object)) {\n return visited.get(a as object) === b;\n }\n visited.set(a as object, b as object);\n\n // Array comparison\n if (Array.isArray(a) && Array.isArray(b)) {\n if (a.length !== b.length) return false;\n for (let idx = 0; idx < a.length; idx++) {\n if (!safeIsEqual(a[idx], b[idx], visited)) return false;\n }\n return true;\n }\n\n // Ensure both are arrays or neither is\n if (Array.isArray(a) !== Array.isArray(b)) return false;\n\n // Date comparison\n if (a instanceof Date && b instanceof Date) {\n return a.getTime() === b.getTime();\n }\n\n // Object comparison\n const keysA = Object.keys(a);\n const keysB = Object.keys(b);\n\n if (keysA.length !== keysB.length) return false;\n\n for (const key of keysA) {\n if (\n !Object.hasOwn(b, key) ||\n !safeIsEqual((a as Record<string, unknown>)[key], (b as Record<string, unknown>)[key], visited)\n )\n return false;\n }\n\n return true;\n}\n\nexport const IS_EQUAL_ERROR_MSG = 'Expected two values to be equal';\n"],"names":["isEqual","a","b","safeIsEqual","visited","idx","keysA","keysB","key","IS_EQUAL_ERROR_MSG"],"mappings":"AAqBO,SAASA,EAAQC,GAAYC,GAAqB;AACvD,SAAOC,EAAYF,GAAGC,GAAG,oBAAI,SAAS;AACxC;AAGA,SAASC,EAAYF,GAAYC,GAAYE,GAA2C;AAEtF,MAAIH,MAAMC,EAAG,QAAO;AAGpB,MAAID,KAAK,QAAQC,KAAK,QAAQ,OAAOD,KAAM,OAAOC,KAAK,OAAOD,KAAM,YAAY,OAAOC,KAAM,SAAU,QAAO;AAI9G,MAAIE,EAAQ,IAAIH,CAAW;AACzB,WAAOG,EAAQ,IAAIH,CAAW,MAAMC;AAKtC,MAHAE,EAAQ,IAAIH,GAAaC,CAAW,GAGhC,MAAM,QAAQD,CAAC,KAAK,MAAM,QAAQC,CAAC,GAAG;AACxC,QAAID,EAAE,WAAWC,EAAE,OAAQ,QAAO;AAClC,aAASG,IAAM,GAAGA,IAAMJ,EAAE,QAAQI;AAChC,UAAI,CAACF,EAAYF,EAAEI,CAAG,GAAGH,EAAEG,CAAG,GAAGD,CAAO,EAAG,QAAO;AAEpD,WAAO;AAAA,EACT;AAGA,MAAI,MAAM,QAAQH,CAAC,MAAM,MAAM,QAAQC,CAAC,EAAG,QAAO;AAGlD,MAAID,aAAa,QAAQC,aAAa;AACpC,WAAOD,EAAE,cAAcC,EAAE,QAAA;AAI3B,QAAMI,IAAQ,OAAO,KAAKL,CAAC,GACrBM,IAAQ,OAAO,KAAKL,CAAC;AAE3B,MAAII,EAAM,WAAWC,EAAM,OAAQ,QAAO;AAE1C,aAAWC,KAAOF;AAChB,QACE,CAAC,OAAO,OAAOJ,GAAGM,CAAG,KACrB,CAACL,EAAaF,EAA8BO,CAAG,GAAIN,EAA8BM,CAAG,GAAGJ,CAAO;AAE9F,aAAO;AAGX,SAAO;AACT;AAEO,MAAMK,IAAqB;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vielzeug/toolkit",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"