@stryke/helpers 0.10.19 → 0.10.20

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 (196) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/_virtual/_rolldown/runtime.cjs +19 -0
  3. package/dist/_virtual/_rolldown/runtime.mjs +18 -0
  4. package/dist/arg-identity.cjs +9 -1
  5. package/dist/arg-identity.mjs +4 -1
  6. package/dist/arg-identity.mjs.map +1 -1
  7. package/dist/arg-identity.test.cjs +12 -0
  8. package/dist/arg-identity.test.d.cts +1 -0
  9. package/dist/arg-identity.test.d.mts +1 -0
  10. package/dist/arg-identity.test.mjs +14 -0
  11. package/dist/arg-identity.test.mjs.map +1 -0
  12. package/dist/deep-clone.cjs +9 -1
  13. package/dist/deep-clone.mjs +3 -1
  14. package/dist/deep-clone.mjs.map +1 -1
  15. package/dist/deep-clone.test.cjs +12 -0
  16. package/dist/deep-clone.test.d.cts +1 -0
  17. package/dist/deep-clone.test.d.mts +1 -0
  18. package/dist/deep-clone.test.mjs +14 -0
  19. package/dist/deep-clone.test.mjs.map +1 -0
  20. package/dist/deep-merge.cjs +9 -1
  21. package/dist/deep-merge.mjs +3 -1
  22. package/dist/deep-merge.mjs.map +1 -1
  23. package/dist/deep-merge.test.cjs +12 -0
  24. package/dist/deep-merge.test.d.cts +1 -0
  25. package/dist/deep-merge.test.d.mts +1 -0
  26. package/dist/deep-merge.test.mjs +14 -0
  27. package/dist/deep-merge.test.mjs.map +1 -0
  28. package/dist/filter-empty.cjs +9 -1
  29. package/dist/filter-empty.mjs +3 -1
  30. package/dist/filter-empty.mjs.map +1 -1
  31. package/dist/filter-empty.test.cjs +12 -0
  32. package/dist/filter-empty.test.d.cts +1 -0
  33. package/dist/filter-empty.test.d.mts +1 -0
  34. package/dist/filter-empty.test.mjs +14 -0
  35. package/dist/filter-empty.test.mjs.map +1 -0
  36. package/dist/flatten-object.cjs +9 -1
  37. package/dist/flatten-object.mjs +3 -1
  38. package/dist/flatten-object.mjs.map +1 -1
  39. package/dist/flatten-object.test.cjs +12 -0
  40. package/dist/flatten-object.test.d.cts +1 -0
  41. package/dist/flatten-object.test.d.mts +1 -0
  42. package/dist/flatten-object.test.mjs +14 -0
  43. package/dist/flatten-object.test.mjs.map +1 -0
  44. package/dist/get-field.cjs +9 -1
  45. package/dist/get-field.mjs +3 -1
  46. package/dist/get-field.mjs.map +1 -1
  47. package/dist/get-field.test.cjs +12 -0
  48. package/dist/get-field.test.d.cts +1 -0
  49. package/dist/get-field.test.d.mts +1 -0
  50. package/dist/get-field.test.mjs +14 -0
  51. package/dist/get-field.test.mjs.map +1 -0
  52. package/dist/get-ordered-by.cjs +9 -1
  53. package/dist/get-ordered-by.mjs +4 -1
  54. package/dist/get-ordered-by.mjs.map +1 -1
  55. package/dist/get-ordered-by.test.cjs +12 -0
  56. package/dist/get-ordered-by.test.d.cts +1 -0
  57. package/dist/get-ordered-by.test.d.mts +1 -0
  58. package/dist/get-ordered-by.test.mjs +14 -0
  59. package/dist/get-ordered-by.test.mjs.map +1 -0
  60. package/dist/get-unique.cjs +12 -1
  61. package/dist/get-unique.mjs +7 -1
  62. package/dist/get-unique.mjs.map +1 -1
  63. package/dist/get-unique.test.cjs +12 -0
  64. package/dist/get-unique.test.d.cts +1 -0
  65. package/dist/get-unique.test.d.mts +1 -0
  66. package/dist/get-unique.test.mjs +14 -0
  67. package/dist/get-unique.test.mjs.map +1 -0
  68. package/dist/identity.cjs +9 -1
  69. package/dist/identity.mjs +4 -1
  70. package/dist/identity.mjs.map +1 -1
  71. package/dist/identity.test.cjs +12 -0
  72. package/dist/identity.test.d.cts +1 -0
  73. package/dist/identity.test.d.mts +1 -0
  74. package/dist/identity.test.mjs +14 -0
  75. package/dist/identity.test.mjs.map +1 -0
  76. package/dist/index.cjs +41 -0
  77. package/dist/index.mjs +37 -1
  78. package/dist/index.mjs.map +1 -0
  79. package/dist/index.test.cjs +12 -0
  80. package/dist/index.test.d.cts +1 -0
  81. package/dist/index.test.d.mts +1 -0
  82. package/dist/index.test.mjs +14 -0
  83. package/dist/index.test.mjs.map +1 -0
  84. package/dist/is-equal.cjs +9 -1
  85. package/dist/is-equal.mjs +3 -1
  86. package/dist/is-equal.mjs.map +1 -1
  87. package/dist/is-equal.test.cjs +12 -0
  88. package/dist/is-equal.test.d.cts +1 -0
  89. package/dist/is-equal.test.d.mts +1 -0
  90. package/dist/is-equal.test.mjs +14 -0
  91. package/dist/is-equal.test.mjs.map +1 -0
  92. package/dist/lru-cache.cjs +9 -1
  93. package/dist/lru-cache.mjs +4 -1
  94. package/dist/lru-cache.mjs.map +1 -1
  95. package/dist/lru-cache.test.cjs +12 -0
  96. package/dist/lru-cache.test.d.cts +1 -0
  97. package/dist/lru-cache.test.d.mts +1 -0
  98. package/dist/lru-cache.test.mjs +14 -0
  99. package/dist/lru-cache.test.mjs.map +1 -0
  100. package/dist/match-sorter.cjs +12 -0
  101. package/dist/match-sorter.mjs +7 -1
  102. package/dist/match-sorter.mjs.map +1 -1
  103. package/dist/match-sorter.test.cjs +12 -0
  104. package/dist/match-sorter.test.d.cts +1 -0
  105. package/dist/match-sorter.test.d.mts +1 -0
  106. package/dist/match-sorter.test.mjs +14 -0
  107. package/dist/match-sorter.test.mjs.map +1 -0
  108. package/dist/memoize.cjs +9 -1
  109. package/dist/memoize.mjs +4 -1
  110. package/dist/memoize.mjs.map +1 -1
  111. package/dist/memoize.test.cjs +12 -0
  112. package/dist/memoize.test.d.cts +1 -0
  113. package/dist/memoize.test.d.mts +1 -0
  114. package/dist/memoize.test.mjs +14 -0
  115. package/dist/memoize.test.mjs.map +1 -0
  116. package/dist/noop.cjs +12 -1
  117. package/dist/noop.mjs +7 -1
  118. package/dist/noop.mjs.map +1 -1
  119. package/dist/noop.test.cjs +12 -0
  120. package/dist/noop.test.d.cts +1 -0
  121. package/dist/noop.test.d.mts +1 -0
  122. package/dist/noop.test.mjs +14 -0
  123. package/dist/noop.test.mjs.map +1 -0
  124. package/dist/omit.cjs +9 -1
  125. package/dist/omit.mjs +4 -1
  126. package/dist/omit.mjs.map +1 -1
  127. package/dist/omit.test.cjs +12 -0
  128. package/dist/omit.test.d.cts +1 -0
  129. package/dist/omit.test.d.mts +1 -0
  130. package/dist/omit.test.mjs +14 -0
  131. package/dist/omit.test.mjs.map +1 -0
  132. package/dist/pick.cjs +9 -1
  133. package/dist/pick.mjs +4 -1
  134. package/dist/pick.mjs.map +1 -1
  135. package/dist/pick.test.cjs +12 -0
  136. package/dist/pick.test.d.cts +1 -0
  137. package/dist/pick.test.d.mts +1 -0
  138. package/dist/pick.test.mjs +14 -0
  139. package/dist/pick.test.mjs.map +1 -0
  140. package/dist/remove-accents.cjs +12 -1
  141. package/dist/remove-accents.mjs +7 -1
  142. package/dist/remove-accents.mjs.map +1 -1
  143. package/dist/remove-accents.test.cjs +12 -0
  144. package/dist/remove-accents.test.d.cts +1 -0
  145. package/dist/remove-accents.test.d.mts +1 -0
  146. package/dist/remove-accents.test.mjs +14 -0
  147. package/dist/remove-accents.test.mjs.map +1 -0
  148. package/dist/remove-empty-items.cjs +9 -1
  149. package/dist/remove-empty-items.mjs +4 -1
  150. package/dist/remove-empty-items.mjs.map +1 -1
  151. package/dist/remove-empty-items.test.cjs +12 -0
  152. package/dist/remove-empty-items.test.d.cts +1 -0
  153. package/dist/remove-empty-items.test.d.mts +1 -0
  154. package/dist/remove-empty-items.test.mjs +14 -0
  155. package/dist/remove-empty-items.test.mjs.map +1 -0
  156. package/dist/set-field.cjs +9 -1
  157. package/dist/set-field.mjs +3 -1
  158. package/dist/set-field.mjs.map +1 -1
  159. package/dist/set-field.test.cjs +12 -0
  160. package/dist/set-field.test.d.cts +1 -0
  161. package/dist/set-field.test.d.mts +1 -0
  162. package/dist/set-field.test.mjs +14 -0
  163. package/dist/set-field.test.mjs.map +1 -0
  164. package/dist/to-deep-key.cjs +12 -1
  165. package/dist/to-deep-key.mjs +6 -1
  166. package/dist/to-deep-key.mjs.map +1 -1
  167. package/dist/to-deep-key.test.cjs +12 -0
  168. package/dist/to-deep-key.test.d.cts +1 -0
  169. package/dist/to-deep-key.test.d.mts +1 -0
  170. package/dist/to-deep-key.test.mjs +14 -0
  171. package/dist/to-deep-key.test.mjs.map +1 -0
  172. package/dist/to-path.cjs +9 -1
  173. package/dist/to-path.mjs +4 -1
  174. package/dist/to-path.mjs.map +1 -1
  175. package/dist/to-path.test.cjs +12 -0
  176. package/dist/to-path.test.d.cts +1 -0
  177. package/dist/to-path.test.d.mts +1 -0
  178. package/dist/to-path.test.mjs +14 -0
  179. package/dist/to-path.test.mjs.map +1 -0
  180. package/dist/unflatten-object.cjs +9 -1
  181. package/dist/unflatten-object.mjs +3 -1
  182. package/dist/unflatten-object.mjs.map +1 -1
  183. package/dist/unflatten-object.test.cjs +12 -0
  184. package/dist/unflatten-object.test.d.cts +1 -0
  185. package/dist/unflatten-object.test.d.mts +1 -0
  186. package/dist/unflatten-object.test.mjs +14 -0
  187. package/dist/unflatten-object.test.mjs.map +1 -0
  188. package/dist/union.cjs +9 -1
  189. package/dist/union.mjs +3 -1
  190. package/dist/union.mjs.map +1 -1
  191. package/dist/union.test.cjs +12 -0
  192. package/dist/union.test.d.cts +1 -0
  193. package/dist/union.test.d.mts +1 -0
  194. package/dist/union.test.mjs +14 -0
  195. package/dist/union.test.mjs.map +1 -0
  196. package/package.json +101 -5
@@ -1 +1 @@
1
- {"version":3,"file":"is-equal.mjs","names":[],"sources":["../src/is-equal.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isSet } from \"@stryke/type-checks/is-set\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\n\nconst hasMap = typeof Map === \"function\";\nconst hasSet = typeof Set === \"function\";\nconst hasArrayBuffer =\n typeof ArrayBuffer === \"function\" && ArrayBuffer.isView !== undefined;\n\nfunction equal(a: any, b: any) {\n if (a === b) {\n return true;\n }\n\n if (a && b && typeof a === \"object\" && typeof b === \"object\") {\n if (a.constructor !== b.constructor) {\n return false;\n }\n\n let length;\n if (Array.isArray(a)) {\n length = a.length;\n\n if (length != b.length) return false;\n for (let i = length; i-- !== 0; ) if (!equal(a[i], b[i])) return false;\n return true;\n }\n\n let it;\n if (hasMap && a instanceof Map && b instanceof Map) {\n if (a.size !== b.size) return false;\n it = a.entries();\n let i;\n while (!(i = it.next()).done) if (!b.has(i.value[0])) return false;\n it = a.entries();\n while (!(i = it.next()).done) {\n if (!equal(i.value[1], b.get(i.value[0]))) return false;\n }\n return true;\n }\n\n if (hasSet && a instanceof Set && b instanceof Set) {\n if (a.size !== b.size) return false;\n it = a.entries();\n let i;\n while (!(i = it.next()).done) if (!b.has(i.value[0])) return false;\n return true;\n }\n\n if (\n Array.isArray(a) &&\n Array.isArray(b) &&\n hasArrayBuffer &&\n ArrayBuffer.isView(a) &&\n ArrayBuffer.isView(b)\n ) {\n length = a.length;\n\n if (length != b.length) return false;\n for (let i = length; i-- !== 0; ) if (a[i] !== b[i]) return false;\n return true;\n }\n\n if (a.constructor === RegExp) {\n return a.source === b.source && a.flags === b.flags;\n }\n\n if (\n a.valueOf !== Object.prototype.valueOf &&\n typeof a.valueOf === \"function\" &&\n typeof b.valueOf === \"function\"\n ) {\n // eslint-disable-next-line ts/no-unsafe-call\n return a.valueOf() === b.valueOf();\n }\n if (\n a.toString !== Object.prototype.toString &&\n typeof a.toString === \"function\" &&\n typeof b.toString === \"function\"\n ) {\n // eslint-disable-next-line ts/no-unsafe-call\n return a.toString() === b.toString();\n }\n\n const keys = Object.keys(a);\n length = keys.length;\n if (length !== Object.keys(b).length) {\n return false;\n }\n\n for (let i = length; i-- !== 0; ) {\n if (\n !isSet(i) ||\n !isSetString(keys[i]) ||\n !Object.prototype.hasOwnProperty.call(b, keys[i] as any)\n ) {\n return false;\n }\n }\n\n for (let i = length; i-- !== 0; ) {\n if (\n Array.isArray(keys) &&\n (keys[i] === \"_owner\" || keys[i] === \"__v\" || keys[i] === \"__o\") &&\n a.$$typeof\n ) {\n continue;\n }\n\n if (\n !isSet(i) ||\n !isSetString(keys[i]) ||\n !equal(a[keys[i] as any], b[keys[i] as any])\n ) {\n return false;\n }\n }\n\n return true;\n }\n\n // eslint-disable-next-line no-self-compare\n return a !== a && b !== b;\n}\n\n/**\n * Checks if two values are equal, including support for `Date`, `RegExp`, and deep object comparison.\n *\n * @example\n * ```ts\n * isEqual(1, 1); // true\n * isEqual({ a: 1 }, { a: 1 }); // true\n * isEqual(/abc/g, /abc/g); // true\n * isEqual(new Date('2020-01-01'), new Date('2020-01-01')); // true\n * isEqual([1, 2, 3], [1, 2, 3]); // true\n * isEqual({ a: 1, b: { c: 2 } }, { a: 1, b: { c: 2 } }); // true\n * ```\n *\n * @param a - The first value to compare.\n * @param b - The second value to compare.\n * @returns `true` if the values are equal, otherwise `false`.\n */\nexport function isEqual(a: any, b: any): boolean {\n try {\n return equal(a, b);\n } catch (error) {\n if (/stack|recursion/i.test((error as any)?.message || \"\")) {\n // eslint-disable-next-line no-console\n console.warn(\"isEqual cannot handle circular refs\");\n\n return false;\n }\n\n throw error;\n }\n}\n"],"mappings":";;;;AAqBA,MAAM,SAAS,OAAO,QAAQ;AAC9B,MAAM,SAAS,OAAO,QAAQ;AAC9B,MAAM,iBACJ,OAAO,gBAAgB,cAAc,YAAY,WAAW;AAE9D,SAAS,MAAM,GAAQ,GAAQ;AAC7B,KAAI,MAAM,EACR,QAAO;AAGT,KAAI,KAAK,KAAK,OAAO,MAAM,YAAY,OAAO,MAAM,UAAU;AAC5D,MAAI,EAAE,gBA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;AAGhD,MACE,EAAE,YAAY,OAAO,UAAU,WAC/B,OAAO,EAAE,YAAY,cACrB,OAAO,EAAE,YAAY,WAGrB,QAAO,EAAE,SAAS,KAAK,EAAE,SAAS;AAEpC,MACE,EAAE,aAAa,OAAO,UAAU,YAChC,OAAO,EAAE,aAAa,cACtB,OAAO,EAAE,aAAa,WAGtB,QAAO,EAAE,UAAU,KAAK,EAAE,UAAU;EAGtC,MAAM,OAAO,OAAO,KAAK,EAAE;AAC3B,WAAS,KAAK;AACd,MAAI,WAAW,OAAO,KAAK,EAAE,CAAC,OAC5B,QAAO;AAGT,OAAK,IAAI,IAAI,QAAQ,QAAQ,GAC3B,KACE,CAAC,MAAM,EAAE,IACT,CAAC,YAAY,KAAK,GAAG,IACrB,CAAC,OAAO,UAAU,eAAe,KAAK,GAAG,KAAK,GAAU,CAExD,QAAO;AAIX,OAAK,IAAI,IAAI,QAAQ,QAAQ,IAAK;AAChC,OACE,MAAM,QAAQ,KAAK,KAClB,KAAK,OAAO,YAAY,KAAK,OAAO,SAAS,KAAK,OAAO,UAC1D,EAAE,SAEF;AAGF,OACE,CAAC,MAAM,EAAE,IACT,CAAC,YAAY,KAAK,GAAG,IACrB,CAAC,MAAM,EAAE,KAAK,KAAY,EAAE,KAAK,IAAW,CAE5C,QAAO;;AAIX,SAAO;;AAIT,QAAO,MAAM,KAAK,MAAM;;;;;;;;;;;;;;;;;;;AAoB1B,SAAgB,QAAQ,GAAQ,GAAiB;AAC/C,KAAI;AACF,SAAO,MAAM,GAAG,EAAE;UACX,OAAO;AACd,MAAI,mBAAmB,KAAM,OAAe,WAAW,GAAG,EAAE;AAE1D,WAAQ,KAAK,sCAAsC;AAEnD,UAAO;;AAGT,QAAM"}
1
+ {"version":3,"file":"is-equal.mjs","names":[],"sources":["../src/is-equal.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isSet } from \"@stryke/type-checks/is-set\";\nimport { isSetString } from \"@stryke/type-checks/is-set-string\";\n\nconst hasMap = typeof Map === \"function\";\nconst hasSet = typeof Set === \"function\";\nconst hasArrayBuffer =\n typeof ArrayBuffer === \"function\" && ArrayBuffer.isView !== undefined;\n\nfunction equal(a: any, b: any) {\n if (a === b) {\n return true;\n }\n\n if (a && b && typeof a === \"object\" && typeof b === \"object\") {\n if (a.constructor !== b.constructor) {\n return false;\n }\n\n let length;\n if (Array.isArray(a)) {\n length = a.length;\n\n if (length != b.length) return false;\n for (let i = length; i-- !== 0; ) if (!equal(a[i], b[i])) return false;\n return true;\n }\n\n let it;\n if (hasMap && a instanceof Map && b instanceof Map) {\n if (a.size !== b.size) return false;\n it = a.entries();\n let i;\n while (!(i = it.next()).done) if (!b.has(i.value[0])) return false;\n it = a.entries();\n while (!(i = it.next()).done) {\n if (!equal(i.value[1], b.get(i.value[0]))) return false;\n }\n return true;\n }\n\n if (hasSet && a instanceof Set && b instanceof Set) {\n if (a.size !== b.size) return false;\n it = a.entries();\n let i;\n while (!(i = it.next()).done) if (!b.has(i.value[0])) return false;\n return true;\n }\n\n if (\n Array.isArray(a) &&\n Array.isArray(b) &&\n hasArrayBuffer &&\n ArrayBuffer.isView(a) &&\n ArrayBuffer.isView(b)\n ) {\n length = a.length;\n\n if (length != b.length) return false;\n for (let i = length; i-- !== 0; ) if (a[i] !== b[i]) return false;\n return true;\n }\n\n if (a.constructor === RegExp) {\n return a.source === b.source && a.flags === b.flags;\n }\n\n if (\n a.valueOf !== Object.prototype.valueOf &&\n typeof a.valueOf === \"function\" &&\n typeof b.valueOf === \"function\"\n ) {\n // eslint-disable-next-line ts/no-unsafe-call\n return a.valueOf() === b.valueOf();\n }\n if (\n a.toString !== Object.prototype.toString &&\n typeof a.toString === \"function\" &&\n typeof b.toString === \"function\"\n ) {\n // eslint-disable-next-line ts/no-unsafe-call\n return a.toString() === b.toString();\n }\n\n const keys = Object.keys(a);\n length = keys.length;\n if (length !== Object.keys(b).length) {\n return false;\n }\n\n for (let i = length; i-- !== 0; ) {\n if (\n !isSet(i) ||\n !isSetString(keys[i]) ||\n !Object.prototype.hasOwnProperty.call(b, keys[i] as any)\n ) {\n return false;\n }\n }\n\n for (let i = length; i-- !== 0; ) {\n if (\n Array.isArray(keys) &&\n (keys[i] === \"_owner\" || keys[i] === \"__v\" || keys[i] === \"__o\") &&\n a.$$typeof\n ) {\n continue;\n }\n\n if (\n !isSet(i) ||\n !isSetString(keys[i]) ||\n !equal(a[keys[i] as any], b[keys[i] as any])\n ) {\n return false;\n }\n }\n\n return true;\n }\n\n // eslint-disable-next-line no-self-compare\n return a !== a && b !== b;\n}\n\n/**\n * Checks if two values are equal, including support for `Date`, `RegExp`, and deep object comparison.\n *\n * @example\n * ```ts\n * isEqual(1, 1); // true\n * isEqual({ a: 1 }, { a: 1 }); // true\n * isEqual(/abc/g, /abc/g); // true\n * isEqual(new Date('2020-01-01'), new Date('2020-01-01')); // true\n * isEqual([1, 2, 3], [1, 2, 3]); // true\n * isEqual({ a: 1, b: { c: 2 } }, { a: 1, b: { c: 2 } }); // true\n * ```\n *\n * @param a - The first value to compare.\n * @param b - The second value to compare.\n * @returns `true` if the values are equal, otherwise `false`.\n */\nexport function isEqual(a: any, b: any): boolean {\n try {\n return equal(a, b);\n } catch (error) {\n if (/stack|recursion/i.test((error as any)?.message || \"\")) {\n // eslint-disable-next-line no-console\n console.warn(\"isEqual cannot handle circular refs\");\n\n return false;\n }\n\n throw error;\n }\n}\n"],"mappings":";;;;;;AAqBA,MAAM,SAAS,OAAO,QAAQ;AAC9B,MAAM,SAAS,OAAO,QAAQ;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CAAsC;AAEnD,UAAO;;AAGT,QAAM"}
@@ -0,0 +1,12 @@
1
+ const require_is_equal = require('./is-equal.cjs');
2
+ let vitest = require("vitest");
3
+
4
+ //#region src/is-equal.test.ts
5
+ (0, vitest.describe)("is-equal.ts exports", () => {
6
+ (0, vitest.it)("loads module exports", () => {
7
+ (0, vitest.expect)(require_is_equal.is_equal_exports).toBeDefined();
8
+ (0, vitest.expect)(typeof require_is_equal.is_equal_exports).toBe("object");
9
+ });
10
+ });
11
+
12
+ //#endregion
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,14 @@
1
+ import { is_equal_exports } from "./is-equal.mjs";
2
+ import { describe, expect, it } from "vitest";
3
+
4
+ //#region src/is-equal.test.ts
5
+ describe("is-equal.ts exports", () => {
6
+ it("loads module exports", () => {
7
+ expect(is_equal_exports).toBeDefined();
8
+ expect(typeof is_equal_exports).toBe("object");
9
+ });
10
+ });
11
+
12
+ //#endregion
13
+ export { };
14
+ //# sourceMappingURL=is-equal.test.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-equal.test.mjs","names":["moduleExports"],"sources":["../src/is-equal.test.ts"],"sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport * as moduleExports from \"./is-equal.ts\";\n\ndescribe(\"is-equal.ts exports\", () => {\n it(\"loads module exports\", () => {\n expect(moduleExports).toBeDefined();\n expect(typeof moduleExports).toBe(\"object\");\n });\n});\n"],"mappings":";;;;AAGA,SAAS,6BAA6B;AACpC,IAAG,8BAA8B;AAC/B,SAAOA,iBAAc,CAAC,aAAa;AACnC,SAAO,OAAOA,iBAAc,CAAC,KAAK,SAAS;GAC3C;EACF"}
@@ -1,6 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
2
3
 
3
4
  //#region src/lru-cache.ts
5
+ var lru_cache_exports = /* @__PURE__ */ require_runtime.__exportAll({ LRUCache: () => LRUCache });
4
6
  var LRUNode = class {
5
7
  key;
6
8
  data;
@@ -188,4 +190,10 @@ var LRUCache = class {
188
190
  };
189
191
 
190
192
  //#endregion
191
- exports.LRUCache = LRUCache;
193
+ exports.LRUCache = LRUCache;
194
+ Object.defineProperty(exports, 'lru_cache_exports', {
195
+ enumerable: true,
196
+ get: function () {
197
+ return lru_cache_exports;
198
+ }
199
+ });
@@ -1,4 +1,7 @@
1
+ import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
2
+
1
3
  //#region src/lru-cache.ts
4
+ var lru_cache_exports = /* @__PURE__ */ __exportAll({ LRUCache: () => LRUCache });
2
5
  var LRUNode = class {
3
6
  key;
4
7
  data;
@@ -186,5 +189,5 @@ var LRUCache = class {
186
189
  };
187
190
 
188
191
  //#endregion
189
- export { LRUCache };
192
+ export { LRUCache, lru_cache_exports };
190
193
  //# sourceMappingURL=lru-cache.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"lru-cache.mjs","names":[],"sources":["../src/lru-cache.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nclass LRUNode<T> {\n public readonly key: string;\n\n public data: T;\n\n public size: number;\n\n public prev: LRUNode<T> | SentinelNode<T> | null = null;\n\n public next: LRUNode<T> | SentinelNode<T> | null = null;\n\n constructor(key: string, data: T, size: number) {\n this.key = key;\n this.data = data;\n this.size = size;\n }\n}\n\n/**\n * Sentinel node used for head/tail boundaries.\n * These nodes don't contain actual cache data but simplify list operations.\n */\nclass SentinelNode<T> {\n public prev: LRUNode<T> | SentinelNode<T> | null = null;\n\n public next: LRUNode<T> | SentinelNode<T> | null = null;\n}\n\n/**\n * LRU (Least Recently Used) Cache implementation using a doubly-linked list\n * and hash map for O(1) operations.\n *\n * Algorithm:\n * - Uses a doubly-linked list to maintain access order (most recent at head)\n * - Hash map provides O(1) key-to-node lookup\n * - Sentinel head/tail nodes simplify edge case handling\n * - Size-based eviction supports custom size calculation functions\n *\n * Data Structure Layout:\n * HEAD \\<-\\> [most recent] \\<-\\> ... \\<-\\> [least recent] \\<-\\> TAIL\n *\n * Operations:\n * - get(): Move accessed node to head (mark as most recent)\n * - set(): Add new node at head, evict from tail if over capacity\n * - Eviction: Remove least recent node (tail.prev) when size exceeds limit\n */\nexport class LRUCache<T> {\n private readonly cache: Map<string, LRUNode<T>> = new Map();\n\n private readonly head: SentinelNode<T>;\n\n private readonly tail: SentinelNode<T>;\n\n private totalSize: number = 0;\n\n private readonly maxSize: number;\n\n private readonly calculateSize: ((value: T) => number) | undefined;\n\n constructor(maxSize: number, calculateSize?: (value: T) => number) {\n this.maxSize = maxSize;\n this.calculateSize = calculateSize;\n\n // Create sentinel nodes to simplify doubly-linked list operations\n // HEAD <-> TAIL (empty list)\n this.head = new SentinelNode<T>();\n this.tail = new SentinelNode<T>();\n this.head.next = this.tail;\n this.tail.prev = this.head;\n }\n\n /**\n * Adds a node immediately after the head (marks as most recently used). Used when inserting new items or when an item is accessed. **PRECONDITION:** node must be disconnected (prev/next should be null)\n *\n * @param node - The node to add after the head.\n */\n private addToHead(node: LRUNode<T>): void {\n node.prev = this.head;\n node.next = this.head.next;\n // head.next is always non-null (points to tail or another node)\n this.head.next!.prev = node;\n this.head.next = node;\n }\n\n /**\n * Removes a node from its current position in the doubly-linked list. Updates the prev/next pointers of adjacent nodes to maintain list integrity. **PRECONDITION:** node must be connected (prev/next are non-null)\n *\n * @param node - The node to remove from the list.\n */\n private removeNode(node: LRUNode<T>): void {\n // Connected nodes always have non-null prev/next\n node.prev!.next = node.next;\n node.next!.prev = node.prev;\n }\n\n /**\n * Moves an existing node to the head position (marks as most recently used). This is the core LRU operation - accessed items become most recent.\n *\n * @param node - The node to move to the head.\n */\n private moveToHead(node: LRUNode<T>): void {\n this.removeNode(node);\n this.addToHead(node);\n }\n\n /**\n * Removes and returns the least recently used node (the one before tail). This is called during eviction when the cache exceeds capacity. **PRECONDITION:** cache is not empty (ensured by caller)\n *\n * @returns The removed least recently used node.\n */\n private removeTail(): LRUNode<T> {\n const lastNode = this.tail.prev as LRUNode<T>;\n // tail.prev is always non-null and always LRUNode when cache is not empty\n this.removeNode(lastNode);\n return lastNode;\n }\n\n /**\n * Sets a key-value pair in the cache.\n * If the key exists, updates the value and moves to head.\n * If new, adds at head and evicts from tail if necessary.\n *\n * Time Complexity:\n * - O(1) for uniform item sizes\n * - O(k) where k is the number of items evicted (can be O(N) for variable sizes)\n *\n * @param key - The key to set.\n * @param value - The value to set.\n */\n public set(key: string, value: T): void {\n const size = this.calculateSize?.(value) ?? 1;\n if (size > this.maxSize) {\n // console.warn(\"Single item size exceeds maxSize\");\n return;\n }\n\n const existing = this.cache.get(key);\n if (existing) {\n // Update existing node: adjust size and move to head (most recent)\n existing.data = value;\n this.totalSize = this.totalSize - existing.size + size;\n existing.size = size;\n this.moveToHead(existing);\n } else {\n // Add new node at head (most recent position)\n const newNode = new LRUNode(key, value, size);\n this.cache.set(key, newNode);\n this.addToHead(newNode);\n this.totalSize += size;\n }\n\n // Evict least recently used items until under capacity\n while (this.totalSize > this.maxSize && this.cache.size > 0) {\n const tail = this.removeTail();\n this.cache.delete(tail.key);\n this.totalSize -= tail.size;\n }\n }\n\n /**\n * Checks if a key exists in the cache.\n * This is a pure query operation - does NOT update LRU order.\n *\n * Time Complexity: O(1)\n */\n public has(key: string): boolean {\n return this.cache.has(key);\n }\n\n /**\n * Retrieves a value by key and marks it as most recently used.\n * Moving to head maintains the LRU property for future evictions.\n *\n * Time Complexity: O(1)\n */\n public get(key: string): T | undefined {\n const node = this.cache.get(key);\n if (!node) return undefined;\n\n // Mark as most recently used by moving to head\n this.moveToHead(node);\n\n return node.data;\n }\n\n /**\n * Returns an iterator over the cache entries. The order is outputted in the\n * order of most recently used to least recently used.\n */\n public *[Symbol.iterator](): IterableIterator<[string, T]> {\n let current = this.head.next;\n while (current && current !== this.tail) {\n // Between head and tail, current is always LRUNode\n const node = current as LRUNode<T>;\n yield [node.key, node.data];\n current = current.next;\n }\n }\n\n /**\n * Removes a specific key from the cache.\n * Updates both the hash map and doubly-linked list.\n *\n * Time Complexity: O(1)\n */\n public remove(key: string): void {\n const node = this.cache.get(key);\n if (!node) return;\n\n this.removeNode(node);\n this.cache.delete(key);\n this.totalSize -= node.size;\n }\n\n /**\n * Returns the number of items in the cache.\n */\n public get size(): number {\n return this.cache.size;\n }\n\n /**\n * Returns the current total size of all cached items.\n * This uses the custom size calculation if provided.\n */\n public get currentSize(): number {\n return this.totalSize;\n }\n}\n"],"mappings":";AAkBA,IAAM,UAAN,MAAiB;CACf,AAAgB;CAEhB,AAAO;CAEP,AAAO;CAEP,AAAO,OAA4C;CAEnD,AAAO,OAA4C;CAEnD,YAAY,KAAa,MAAS,MAAc;AAC9C,OAAK,MAAM;AACX,OAAK,OAAO;AACZ,OAAK,OAAO;;;;;;;AAQhB,IAAM,eAAN,MAAsB;CACpB,AAAO,OAA4C;CAEnD,AAAO,OAA4C;;;;;;;;;;;;;;;;;;;;AAqBrD,IAAa,WAAb,MAAyB;CACvB,AAAiB,wBAAiC,IAAI,KAAK;CAE3D,AAAiB;CAEjB,AAAiB;CAEjB,AAAQ,YAAoB;CAE5B,AAAiB;CAEjB,AAAiB;CAEjB,YAAY,SAAiB,eAAsC;AACjE,OAAK,UAAU;AACf,OAAK,gBAAgB;AAIrB,OAAK,OAAO,IAAI,cAAiB;AACjC,OAAK,OAAO,IAAI,cAAiB;AACjC,OAAK,KAAK,OAAO,KAAK;AACtB,OAAK,KAAK,OAAO,KAAK;;;;;;;CAQxB,AAAQ,UAAU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ACzD,IAAI,UAAU,KAAK,KAAK;AACxB,SAAO,WAAW,YAAY,KAAK,MAAM;GAEvC,MAAM,OAAO;AACb,SAAM,CAAC,KAAK,KAAK,KAAK,KAAK;AAC3B,aAAU,QAAQ;;;;;;;;;CAUtB,AAAO,OAAO,KAAmB;EAC/B,MAAM,OAAO,KAAK,MAAM,IAAI,IAAI;AAChC,MAAI,CAAC,KAAM;AAEX,OAAK,WAAW,KAAK;AACrB,OAAK,MAAM,OAAO,IAAI;AACtB,OAAK,aAAa,KAAK;;;;;CAMzB,IAAW,OAAe;AACxB,SAAO,KAAK,MAAM;;;;;;CAOpB,IAAW,cAAsB;AAC/B,SAAO,KAAK"}
1
+ {"version":3,"file":"lru-cache.mjs","names":[],"sources":["../src/lru-cache.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nclass LRUNode<T> {\n public readonly key: string;\n\n public data: T;\n\n public size: number;\n\n public prev: LRUNode<T> | SentinelNode<T> | null = null;\n\n public next: LRUNode<T> | SentinelNode<T> | null = null;\n\n constructor(key: string, data: T, size: number) {\n this.key = key;\n this.data = data;\n this.size = size;\n }\n}\n\n/**\n * Sentinel node used for head/tail boundaries.\n * These nodes don't contain actual cache data but simplify list operations.\n */\nclass SentinelNode<T> {\n public prev: LRUNode<T> | SentinelNode<T> | null = null;\n\n public next: LRUNode<T> | SentinelNode<T> | null = null;\n}\n\n/**\n * LRU (Least Recently Used) Cache implementation using a doubly-linked list\n * and hash map for O(1) operations.\n *\n * Algorithm:\n * - Uses a doubly-linked list to maintain access order (most recent at head)\n * - Hash map provides O(1) key-to-node lookup\n * - Sentinel head/tail nodes simplify edge case handling\n * - Size-based eviction supports custom size calculation functions\n *\n * Data Structure Layout:\n * HEAD \\<-\\> [most recent] \\<-\\> ... \\<-\\> [least recent] \\<-\\> TAIL\n *\n * Operations:\n * - get(): Move accessed node to head (mark as most recent)\n * - set(): Add new node at head, evict from tail if over capacity\n * - Eviction: Remove least recent node (tail.prev) when size exceeds limit\n */\nexport class LRUCache<T> {\n private readonly cache: Map<string, LRUNode<T>> = new Map();\n\n private readonly head: SentinelNode<T>;\n\n private readonly tail: SentinelNode<T>;\n\n private totalSize: number = 0;\n\n private readonly maxSize: number;\n\n private readonly calculateSize: ((value: T) => number) | undefined;\n\n constructor(maxSize: number, calculateSize?: (value: T) => number) {\n this.maxSize = maxSize;\n this.calculateSize = calculateSize;\n\n // Create sentinel nodes to simplify doubly-linked list operations\n // HEAD <-> TAIL (empty list)\n this.head = new SentinelNode<T>();\n this.tail = new SentinelNode<T>();\n this.head.next = this.tail;\n this.tail.prev = this.head;\n }\n\n /**\n * Adds a node immediately after the head (marks as most recently used). Used when inserting new items or when an item is accessed. **PRECONDITION:** node must be disconnected (prev/next should be null)\n *\n * @param node - The node to add after the head.\n */\n private addToHead(node: LRUNode<T>): void {\n node.prev = this.head;\n node.next = this.head.next;\n // head.next is always non-null (points to tail or another node)\n this.head.next!.prev = node;\n this.head.next = node;\n }\n\n /**\n * Removes a node from its current position in the doubly-linked list. Updates the prev/next pointers of adjacent nodes to maintain list integrity. **PRECONDITION:** node must be connected (prev/next are non-null)\n *\n * @param node - The node to remove from the list.\n */\n private removeNode(node: LRUNode<T>): void {\n // Connected nodes always have non-null prev/next\n node.prev!.next = node.next;\n node.next!.prev = node.prev;\n }\n\n /**\n * Moves an existing node to the head position (marks as most recently used). This is the core LRU operation - accessed items become most recent.\n *\n * @param node - The node to move to the head.\n */\n private moveToHead(node: LRUNode<T>): void {\n this.removeNode(node);\n this.addToHead(node);\n }\n\n /**\n * Removes and returns the least recently used node (the one before tail). This is called during eviction when the cache exceeds capacity. **PRECONDITION:** cache is not empty (ensured by caller)\n *\n * @returns The removed least recently used node.\n */\n private removeTail(): LRUNode<T> {\n const lastNode = this.tail.prev as LRUNode<T>;\n // tail.prev is always non-null and always LRUNode when cache is not empty\n this.removeNode(lastNode);\n return lastNode;\n }\n\n /**\n * Sets a key-value pair in the cache.\n * If the key exists, updates the value and moves to head.\n * If new, adds at head and evicts from tail if necessary.\n *\n * Time Complexity:\n * - O(1) for uniform item sizes\n * - O(k) where k is the number of items evicted (can be O(N) for variable sizes)\n *\n * @param key - The key to set.\n * @param value - The value to set.\n */\n public set(key: string, value: T): void {\n const size = this.calculateSize?.(value) ?? 1;\n if (size > this.maxSize) {\n // console.warn(\"Single item size exceeds maxSize\");\n return;\n }\n\n const existing = this.cache.get(key);\n if (existing) {\n // Update existing node: adjust size and move to head (most recent)\n existing.data = value;\n this.totalSize = this.totalSize - existing.size + size;\n existing.size = size;\n this.moveToHead(existing);\n } else {\n // Add new node at head (most recent position)\n const newNode = new LRUNode(key, value, size);\n this.cache.set(key, newNode);\n this.addToHead(newNode);\n this.totalSize += size;\n }\n\n // Evict least recently used items until under capacity\n while (this.totalSize > this.maxSize && this.cache.size > 0) {\n const tail = this.removeTail();\n this.cache.delete(tail.key);\n this.totalSize -= tail.size;\n }\n }\n\n /**\n * Checks if a key exists in the cache.\n * This is a pure query operation - does NOT update LRU order.\n *\n * Time Complexity: O(1)\n */\n public has(key: string): boolean {\n return this.cache.has(key);\n }\n\n /**\n * Retrieves a value by key and marks it as most recently used.\n * Moving to head maintains the LRU property for future evictions.\n *\n * Time Complexity: O(1)\n */\n public get(key: string): T | undefined {\n const node = this.cache.get(key);\n if (!node) return undefined;\n\n // Mark as most recently used by moving to head\n this.moveToHead(node);\n\n return node.data;\n }\n\n /**\n * Returns an iterator over the cache entries. The order is outputted in the\n * order of most recently used to least recently used.\n */\n public *[Symbol.iterator](): IterableIterator<[string, T]> {\n let current = this.head.next;\n while (current && current !== this.tail) {\n // Between head and tail, current is always LRUNode\n const node = current as LRUNode<T>;\n yield [node.key, node.data];\n current = current.next;\n }\n }\n\n /**\n * Removes a specific key from the cache.\n * Updates both the hash map and doubly-linked list.\n *\n * Time Complexity: O(1)\n */\n public remove(key: string): void {\n const node = this.cache.get(key);\n if (!node) return;\n\n this.removeNode(node);\n this.cache.delete(key);\n this.totalSize -= node.size;\n }\n\n /**\n * Returns the number of items in the cache.\n */\n public get size(): number {\n return this.cache.size;\n }\n\n /**\n * Returns the current total size of all cached items.\n * This uses the custom size calculation if provided.\n */\n public get currentSize(): number {\n return this.totalSize;\n }\n}\n"],"mappings":";;;;AAkBA,IAAM,UAAN,MAAiB;CACf,AAAgB;CAEhB,AAAO;CAEP,AAAO;CAEP,AAAO,OAA4C;CAEnD,AAAO,OAA4C;CAEnD,YAAY,KAAa,MAAS,MAAc;AAC9C,OAAK,MAAM;AACX,OAAK,OAAO;AACZ,OAAK,OAAO;;;;;;;AAQhB,IAAM,eAAN,MAAsB;CACpB,AAAO,OAA4C;CAEnD,AAAO,OAA4C;;;;;;;;;;;;;;;;;;;;AAqBrD,IAAa,WAAb,MAAyB;CACvB,AAAiB,wBAAiC,IAAI,KAAK;CAE3D,AAAiB;CAEjB,AAAiB;CAEjB,AAAQ,YAAoB;CAE5B,AAAiB;CAEjB,AAAiB;CAEjB,YAAY,SAAiB,eAAsC;AACjE,OAAK,UAAU;AACf,OAAK,gBAAgB;AAIrB,OAAK,OAAO,IAAI,cAAiB;AACjC,OAAK,OAAO,IAAI,cAAiB;AACjC,OAAK,KAAK,OAAO,KAAK;AACtB,OAAK,KAAK,OAAO,KAAK;;;;;;;CAQxB,AAAQ,UAAU,MAAwB;AACxC,OAAK,OAAO,KAAK;AACjB,OAAK,OAAO,KAAK,KAAK;AAEtB,OAAK,KAAK,KAAM,OAAO;AACvB,OAAK,KAAK,OAAO;;;;;;;CAQnB,AAAQ,WAAW,MAAwB;AAEzC,OAA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AAO,OAAO,KAAmB;EAC/B,MAAM,OAAO,KAAK,MAAM,IAAI,IAAI;AAChC,MAAI,CAAC,KAAM;AAEX,OAAK,WAAW,KAAK;AACrB,OAAK,MAAM,OAAO,IAAI;AACtB,OAAK,aAAa,KAAK;;;;;CAMzB,IAAW,OAAe;AACxB,SAAO,KAAK,MAAM;;;;;;CAOpB,IAAW,cAAsB;AAC/B,SAAO,KAAK"}
@@ -0,0 +1,12 @@
1
+ const require_lru_cache = require('./lru-cache.cjs');
2
+ let vitest = require("vitest");
3
+
4
+ //#region src/lru-cache.test.ts
5
+ (0, vitest.describe)("lru-cache.ts exports", () => {
6
+ (0, vitest.it)("loads module exports", () => {
7
+ (0, vitest.expect)(require_lru_cache.lru_cache_exports).toBeDefined();
8
+ (0, vitest.expect)(typeof require_lru_cache.lru_cache_exports).toBe("object");
9
+ });
10
+ });
11
+
12
+ //#endregion
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,14 @@
1
+ import { lru_cache_exports } from "./lru-cache.mjs";
2
+ import { describe, expect, it } from "vitest";
3
+
4
+ //#region src/lru-cache.test.ts
5
+ describe("lru-cache.ts exports", () => {
6
+ it("loads module exports", () => {
7
+ expect(lru_cache_exports).toBeDefined();
8
+ expect(typeof lru_cache_exports).toBe("object");
9
+ });
10
+ });
11
+
12
+ //#endregion
13
+ export { };
14
+ //# sourceMappingURL=lru-cache.test.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lru-cache.test.mjs","names":["moduleExports"],"sources":["../src/lru-cache.test.ts"],"sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport * as moduleExports from \"./lru-cache.ts\";\n\ndescribe(\"lru-cache.ts exports\", () => {\n it(\"loads module exports\", () => {\n expect(moduleExports).toBeDefined();\n expect(typeof moduleExports).toBe(\"object\");\n });\n});\n"],"mappings":";;;;AAGA,SAAS,8BAA8B;AACrC,IAAG,8BAA8B;AAC/B,SAAOA,kBAAc,CAAC,aAAa;AACnC,SAAO,OAAOA,kBAAc,CAAC,KAAK,SAAS;GAC3C;EACF"}
@@ -1,7 +1,13 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
2
3
  const require_remove_accents = require('./remove-accents.cjs');
3
4
 
4
5
  //#region src/match-sorter.ts
6
+ var match_sorter_exports = /* @__PURE__ */ require_runtime.__exportAll({
7
+ defaultBaseSortFn: () => defaultBaseSortFn,
8
+ matchSorter: () => matchSorter,
9
+ rankings: () => rankings
10
+ });
5
11
  const rankings = {
6
12
  CASE_SENSITIVE_EQUAL: 7,
7
13
  EQUAL: 6,
@@ -262,4 +268,10 @@ function getKeyAttributes(key) {
262
268
  //#endregion
263
269
  exports.defaultBaseSortFn = defaultBaseSortFn;
264
270
  exports.matchSorter = matchSorter;
271
+ Object.defineProperty(exports, 'match_sorter_exports', {
272
+ enumerable: true,
273
+ get: function () {
274
+ return match_sorter_exports;
275
+ }
276
+ });
265
277
  exports.rankings = rankings;
@@ -1,6 +1,12 @@
1
+ import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
1
2
  import { removeAccents } from "./remove-accents.mjs";
2
3
 
3
4
  //#region src/match-sorter.ts
5
+ var match_sorter_exports = /* @__PURE__ */ __exportAll({
6
+ defaultBaseSortFn: () => defaultBaseSortFn,
7
+ matchSorter: () => matchSorter,
8
+ rankings: () => rankings
9
+ });
4
10
  const rankings = {
5
11
  CASE_SENSITIVE_EQUAL: 7,
6
12
  EQUAL: 6,
@@ -259,5 +265,5 @@ function getKeyAttributes(key) {
259
265
  }
260
266
 
261
267
  //#endregion
262
- export { defaultBaseSortFn, matchSorter, rankings };
268
+ export { defaultBaseSortFn, matchSorter, match_sorter_exports, rankings };
263
269
  //# sourceMappingURL=match-sorter.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"match-sorter.mjs","names":[],"sources":["../src/match-sorter.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { removeAccents } from \"./remove-accents\";\n\n/**\n * Forked from match-sorter by Kent C. Dodds\n */\n\ninterface KeyAttributes {\n threshold?: Ranking;\n maxRanking: Ranking;\n minRanking: Ranking;\n}\ninterface RankingInfo {\n rankedValue: string;\n rank: Ranking;\n keyIndex: number;\n keyThreshold: Ranking | undefined;\n}\n\ninterface ValueGetterKey<ItemType> {\n (item: ItemType): string | Array<string>;\n}\ninterface IndexedItem<ItemType> {\n item: ItemType;\n index: number;\n}\ninterface RankedItem<ItemType> extends RankingInfo, IndexedItem<ItemType> {}\n\ninterface BaseSorter<ItemType> {\n (a: RankedItem<ItemType>, b: RankedItem<ItemType>): number;\n}\n\ninterface Sorter<ItemType> {\n (matchItems: Array<RankedItem<ItemType>>): Array<RankedItem<ItemType>>;\n}\n\ninterface KeyAttributesOptions<ItemType> {\n key?: string | ValueGetterKey<ItemType>;\n threshold?: Ranking;\n maxRanking?: Ranking;\n minRanking?: Ranking;\n}\n\ntype KeyOption<ItemType> =\n | KeyAttributesOptions<ItemType>\n | ValueGetterKey<ItemType>\n | string;\n\ninterface MatchSorterOptions<ItemType = unknown> {\n keys?: ReadonlyArray<KeyOption<ItemType>>;\n threshold?: Ranking;\n baseSort?: BaseSorter<ItemType>;\n keepDiacritics?: boolean;\n sorter?: Sorter<ItemType>;\n}\ntype IndexableByString = Record<string, unknown>;\n\nconst rankings = {\n CASE_SENSITIVE_EQUAL: 7,\n EQUAL: 6,\n STARTS_WITH: 5,\n WORD_STARTS_WITH: 4,\n CONTAINS: 3,\n ACRONYM: 2,\n MATCHES: 1,\n NO_MATCH: 0\n} as const;\n\ntype Ranking = (typeof rankings)[keyof typeof rankings];\n\nconst defaultBaseSortFn: BaseSorter<unknown> = (a, b) =>\n String(a.rankedValue).localeCompare(String(b.rankedValue));\n\n/**\n * Takes an array of items and a value and returns a new array with the items that match the given value\n * @param items - the items to sort\n * @param value - the value to use for ranking\n * @param options - Some options to configure the sorter\n * @returns - the new sorted array\n */\nfunction matchSorter<ItemType = string>(\n items: ReadonlyArray<ItemType>,\n value: string,\n options: MatchSorterOptions<ItemType> = {}\n): Array<ItemType> {\n const {\n keys,\n threshold = rankings.MATCHES,\n baseSort = defaultBaseSortFn,\n sorter = matchedItems =>\n matchedItems.sort((a, b) => sortRankedValues(a, b, baseSort))\n } = options;\n const matchedItems = items.reduce(\n (ret: Array<RankedItem<ItemType>>, item: ItemType, index: number) =>\n reduceItemsToRanked(ret, item, index),\n []\n );\n\n return sorter(matchedItems).map(({ item }) => item);\n\n function reduceItemsToRanked(\n matches: Array<RankedItem<ItemType>>,\n item: ItemType,\n index: number\n ): Array<RankedItem<ItemType>> {\n const rankingInfo = getHighestRanking(item, keys, value, options);\n const { rank, keyThreshold = threshold } = rankingInfo;\n if (rank >= keyThreshold) {\n matches.push({\n ...rankingInfo,\n item,\n index\n });\n }\n return matches;\n }\n}\n\nmatchSorter.rankings = rankings;\n\n/**\n * Gets the highest ranking for value for the given item based on its values for the given keys\n * @param item - the item to rank\n * @param keys - the keys to get values from the item for the ranking\n * @param value - the value to rank against\n * @param options - options to control the ranking\n * @returns The highest ranking\n */\nfunction getHighestRanking<ItemType>(\n item: ItemType,\n keys: ReadonlyArray<KeyOption<ItemType>> | undefined,\n value: string,\n options: MatchSorterOptions<ItemType>\n): RankingInfo {\n if (!keys) {\n // if keys is not specified, then we assume the item given is ready to be matched\n const stringItem = item as unknown as string;\n\n return {\n // ends up being duplicate of 'item' in matches but consistent\n rankedValue: stringItem,\n rank: getMatchRanking(stringItem, value, options),\n keyIndex: -1,\n keyThreshold: options.threshold\n };\n }\n const valuesToRank = getAllValuesToRank(item, keys);\n\n return valuesToRank.reduce(\n (\n { rank, rankedValue, keyIndex, keyThreshold },\n { itemValue, attributes },\n i\n ) => {\n let newRank = getMatchRanking(itemValue, value, options);\n let newRankedValue = rankedValue;\n const { minRanking, maxRanking, threshold } = attributes;\n if (newRank < minRanking && newRank >= rankings.MATCHES) {\n newRank = minRanking;\n } else if (newRank > maxRanking) {\n newRank = maxRanking;\n }\n if (newRank > rank) {\n rank = newRank as 0;\n keyIndex = i;\n keyThreshold = threshold;\n newRankedValue = itemValue;\n }\n return {\n rankedValue: newRankedValue,\n rank,\n keyIndex,\n keyThreshold\n };\n },\n {\n rankedValue: item as unknown as string,\n rank: rankings.NO_MATCH,\n keyIndex: -1,\n keyThreshold: options.threshold\n }\n );\n}\n\n/**\n * Gives a rankings score based on how well the two strings match.\n * @param testString - the string to test against\n * @param stringToRank - the string to rank\n * @param options - options for the match (like keepDiacritics for comparison)\n * @returns the ranking for how well stringToRank matches testString\n */\nfunction getMatchRanking<ItemType>(\n testString: string,\n stringToRank: string,\n options: MatchSorterOptions<ItemType>\n): Ranking {\n testString = prepareValueForComparison(testString, options);\n stringToRank = prepareValueForComparison(stringToRank, options);\n\n // too long\n if (stringToRank.length > testString.length) {\n return rankings.NO_MATCH;\n }\n\n // case sensitive equals\n if (testString === stringToRank) {\n return rankings.CASE_SENSITIVE_EQUAL;\n }\n\n // Lower casing before further comparison\n testString = testString.toLowerCase();\n stringToRank = stringToRank.toLowerCase();\n\n // case insensitive equals\n if (testString === stringToRank) {\n return rankings.EQUAL;\n }\n\n // starts with\n if (testString.startsWith(stringToRank)) {\n return rankings.STARTS_WITH;\n }\n\n // word starts with\n if (testString.includes(` ${stringToRank}`)) {\n return rankings.WORD_STARTS_WITH;\n }\n\n // contains\n if (testString.includes(stringToRank)) {\n return rankings.CONTAINS;\n } else if (stringToRank.length === 1) {\n // If the only character in the given stringToRank\n // isn't even contained in the testString, then\n // it's definitely not a match.\n return rankings.NO_MATCH;\n }\n\n // acronym\n if (getAcronym(testString).includes(stringToRank)) {\n return rankings.ACRONYM;\n }\n\n // will return a number between rankings.MATCHES and\n // rankings.MATCHES + 1 depending on how close of a match it is.\n return getClosenessRanking(testString, stringToRank);\n}\n\n/**\n * Generates an acronym for a string.\n *\n * @param value - the string for which to produce the acronym\n * @returns the acronym\n */\nfunction getAcronym(value: string): string {\n let acronym = \"\";\n const wordsInString = value.split(\" \");\n for (const wordInString of wordsInString) {\n const splitByHyphenWords = wordInString.split(\"-\");\n for (const splitByHyphenWord of splitByHyphenWords) {\n acronym += splitByHyphenWord.slice(0, 1);\n }\n }\n return acronym;\n}\n\n/**\n * Returns a score based on how spread apart the\n * characters from the stringToRank are within the testString.\n * A number close to rankings.MATCHES represents a loose match. A number close\n * to rankings.MATCHES + 1 represents a tighter match.\n * @param testString - the string to test against\n * @param stringToRank - the string to rank\n * @returns the number between rankings.MATCHES and\n * rankings.MATCHES + 1 for how well stringToRank matches testString\n */\nfunction getClosenessRanking(\n testString: string,\n stringToRank: string\n): Ranking {\n let matchingInOrderCharCount = 0;\n let charNumber = 0;\n function findMatchingCharacter(\n matchChar: string,\n string: string,\n index: number\n ) {\n for (let j = index, J = string.length; j < J; j++) {\n const stringChar = string[j];\n if (stringChar === matchChar) {\n matchingInOrderCharCount += 1;\n return j + 1;\n }\n }\n return -1;\n }\n function getRanking(spread: number) {\n const spreadPercentage = 1 / spread;\n const inOrderPercentage = matchingInOrderCharCount / stringToRank.length;\n const ranking = rankings.MATCHES + inOrderPercentage * spreadPercentage;\n\n return ranking as Ranking;\n }\n const firstIndex = findMatchingCharacter(stringToRank[0]!, testString, 0);\n if (firstIndex < 0) {\n return rankings.NO_MATCH;\n }\n charNumber = firstIndex;\n for (let i = 1, I = stringToRank.length; i < I; i++) {\n const matchChar = stringToRank[i];\n charNumber = findMatchingCharacter(matchChar!, testString, charNumber);\n const found = charNumber > -1;\n if (!found) {\n return rankings.NO_MATCH;\n }\n }\n\n const spread = charNumber - firstIndex;\n\n return getRanking(spread);\n}\n\n/**\n * Sorts items that have a rank, index, and keyIndex\n * @param a - the first item to sort\n * @param b - the second item to sort\n * @returns -1 if a should come first, 1 if b should come first, 0 if equal\n */\nfunction sortRankedValues<ItemType>(\n a: RankedItem<ItemType>,\n b: RankedItem<ItemType>,\n baseSort: BaseSorter<ItemType>\n): number {\n const aFirst = -1;\n const bFirst = 1;\n const { rank: aRank, keyIndex: aKeyIndex } = a;\n const { rank: bRank, keyIndex: bKeyIndex } = b;\n const same = aRank === bRank;\n if (same) {\n if (aKeyIndex === bKeyIndex) {\n // use the base sort function as a tie-breaker\n return baseSort(a, b);\n }\n return aKeyIndex < bKeyIndex ? aFirst : bFirst;\n }\n return aRank > bRank ? aFirst : bFirst;\n}\n\n/**\n * Prepares value for comparison by stringifying it, removing diacritics (if specified)\n * @param value - the value to clean\n * @param options - options for the match (like keepDiacritics for comparison)\n * @returns the prepared value\n */\nfunction prepareValueForComparison<ItemType>(\n value: string,\n options: MatchSorterOptions<ItemType>\n): string {\n // value might not actually be a string at this point (we don't get to choose)\n // so part of preparing the value for comparison is ensure that it is a string\n value = `${value}`; // toString\n if (!options.keepDiacritics) {\n value = removeAccents(value);\n }\n return value;\n}\n\n/**\n * Gets value for key in item at arbitrarily nested keypath\n * @param item - the item\n * @param key - the potentially nested keypath or property callback\n * @returns - an array containing the value(s) at the nested keypath\n */\nfunction getItemValues<ItemType>(\n item: ItemType,\n key: KeyOption<ItemType>\n): Array<string> {\n if (typeof key === \"object\") {\n key = key.key as string;\n }\n let value: string | Array<string> | null | unknown;\n if (typeof key === \"function\") {\n value = key(item);\n } else if (item === null) {\n value = null;\n } else if (Object.hasOwnProperty.call(item, key)) {\n value = (item as IndexableByString)[key];\n } else if (key.includes(\".\")) {\n return getNestedValues<ItemType>(key, item);\n } else {\n value = null;\n }\n\n // because `value` can also be undefined\n if (value === null) {\n return [];\n }\n if (Array.isArray(value)) {\n return value;\n }\n return [String(value)];\n}\n\n/**\n * Given path: \"foo.bar.baz\"\n * And item: \\{foo: \\{bar: \\{baz: 'buzz'\\}\\}\\}\n * -\\> 'buzz'\n *\n * @param path - a dot-separated set of keys\n * @param item - the item to get the value from\n */\nfunction getNestedValues<ItemType>(\n path: string,\n item: ItemType\n): Array<string> {\n const keys = path.split(\".\");\n\n type ValueA = Array<ItemType | IndexableByString | string>;\n let values: ValueA = [item];\n\n for (let i = 0, I = keys.length; i < I; i++) {\n const nestedKey = keys[i];\n let nestedValues: ValueA = [];\n\n for (let j = 0, J = values.length; j < J; j++) {\n const nestedItem = values[j];\n\n if (nestedItem === null) {\n continue;\n }\n\n if (nestedKey && Object.hasOwnProperty.call(nestedItem, nestedKey)) {\n const nestedValue = (nestedItem as IndexableByString)[nestedKey];\n if (nestedValue !== null) {\n nestedValues.push(nestedValue as IndexableByString | string);\n }\n } else if (nestedItem && nestedKey === \"*\") {\n // ensure that values is an array\n nestedValues = [...nestedValues, nestedItem];\n }\n }\n\n values = nestedValues;\n }\n\n if (Array.isArray(values[0])) {\n // keep allowing the implicit wildcard for an array of strings at the end of\n // the path; don't use `.flat()` because that's not available in node.js v10\n const result: Array<string> = [];\n\n return result.concat(...(values as Array<string>));\n }\n // Based on our logic it should be an array of strings by now...\n // assuming the user's path terminated in strings\n return values as Array<string>;\n}\n\n/**\n * Gets all the values for the given keys in the given item and returns an array of those values\n * @param item - the item from which the values will be retrieved\n * @param keys - the keys to use to retrieve the values\n * @returns objects with \\{itemValue, attributes\\}\n */\nfunction getAllValuesToRank<ItemType>(\n item: ItemType,\n keys: ReadonlyArray<KeyOption<ItemType>>\n) {\n const allValues: Array<{ itemValue: string; attributes: KeyAttributes }> = [];\n for (let j = 0, J = keys.length; j < J; j++) {\n const key = keys[j];\n const attributes = getKeyAttributes(key!);\n const itemValues = getItemValues(item, key!);\n for (let i = 0, I = itemValues.length; i < I; i++) {\n allValues.push({\n itemValue: itemValues[i]!,\n attributes\n });\n }\n }\n return allValues;\n}\n\nconst defaultKeyAttributes = {\n maxRanking: Infinity as Ranking,\n minRanking: -Infinity as Ranking\n};\n/**\n * Gets all the attributes for the given key\n * @param key - the key from which the attributes will be retrieved\n * @returns object containing the key's attributes\n */\nfunction getKeyAttributes<ItemType>(key: KeyOption<ItemType>): KeyAttributes {\n if (typeof key === \"string\") {\n return defaultKeyAttributes;\n }\n return {\n ...defaultKeyAttributes,\n ...key\n };\n}\n\nexport { defaultBaseSortFn, matchSorter, rankings };\n\nexport type {\n KeyAttributes,\n KeyAttributesOptions,\n KeyOption,\n MatchSorterOptions,\n RankingInfo,\n ValueGetterKey\n};\n"],"mappings":";;;AA0EA,MAAM,WAAW;CACf,sBAAsB;CACtB,OAAO;CACP,aAAa;CACb,kBAAkB;CAClB,UAAU;CACV,SAAS;CACT,SAAS;CACT,UAAU;CACX;AAID,MAAM,qBAA0C,GAAG,MACjD,OAAO,EAAE,YAAY,CAAC,cAAc,OAAO,EAAE,YAAY,CAAC;;;;;;;;AAS5D,SAAS,YACP,OACA,OACA,UAAwC,EAAE,EACzB;CACjB,MAAM,EACJ,MACA,YAAY,SAAS,SACrB,WAAW,mBACX,UAAS,iBACP,aAAa,MAAM,GAAG,MAAM,iBAAiB,GAAG,GAAG,SAAS,CAAC,KAC7D;AAOJ,QAAO,OANc,MAAM,QACxB,KAAkC,MAAgB,UACjD,oBAAoB,KAAK,MAAM,MAAM,EACvC,EAAE,CAGsB,CAAC,CAAC,KAAK,EAAE,WAAW,KAAK;CAEnD,SAAS,oBACP,SACA,MACA,OAC6B;EAC7B,MAAM,cAAc,kBAAkB,MAAM,MAAM,OAAO,QAAQ;EACjE,MAAM,EAAE,MAAM,eAAe,cAAc;AAC3C,MAAI,QAAQ,aACV,SAAQ,KAAK;GACX,GAAG;GACH;GACA;GACD,CAAC;AAEJ,SAAO;;;AAIX,YAAY,WAAW;;;;;;;;;AAUvB,SAAS,kBACP,MACA,MACA,OACA,SACa;AACb,KAAI,CAAC,M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EACjB,MAAM,aAAa,iBAAiB,IAAK;EACzC,MAAM,aAAa,cAAc,MAAM,IAAK;AAC5C,OAAK,IAAI,IAAI,GAAG,IAAI,WAAW,QAAQ,IAAI,GAAG,IAC5C,WAAU,KAAK;GACb,WAAW,WAAW;GACtB;GACD,CAAC;;AAGN,QAAO;;AAGT,MAAM,uBAAuB;CAC3B,YAAY;CACZ,YAAY;CACb;;;;;;AAMD,SAAS,iBAA2B,KAAyC;AAC3E,KAAI,OAAO,QAAQ,SACjB,QAAO;AAET,QAAO;EACL,GAAG;EACH,GAAG;EACJ"}
1
+ {"version":3,"file":"match-sorter.mjs","names":[],"sources":["../src/match-sorter.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { removeAccents } from \"./remove-accents\";\n\n/**\n * Forked from match-sorter by Kent C. Dodds\n */\n\ninterface KeyAttributes {\n threshold?: Ranking;\n maxRanking: Ranking;\n minRanking: Ranking;\n}\ninterface RankingInfo {\n rankedValue: string;\n rank: Ranking;\n keyIndex: number;\n keyThreshold: Ranking | undefined;\n}\n\ninterface ValueGetterKey<ItemType> {\n (item: ItemType): string | Array<string>;\n}\ninterface IndexedItem<ItemType> {\n item: ItemType;\n index: number;\n}\ninterface RankedItem<ItemType> extends RankingInfo, IndexedItem<ItemType> {}\n\ninterface BaseSorter<ItemType> {\n (a: RankedItem<ItemType>, b: RankedItem<ItemType>): number;\n}\n\ninterface Sorter<ItemType> {\n (matchItems: Array<RankedItem<ItemType>>): Array<RankedItem<ItemType>>;\n}\n\ninterface KeyAttributesOptions<ItemType> {\n key?: string | ValueGetterKey<ItemType>;\n threshold?: Ranking;\n maxRanking?: Ranking;\n minRanking?: Ranking;\n}\n\ntype KeyOption<ItemType> =\n | KeyAttributesOptions<ItemType>\n | ValueGetterKey<ItemType>\n | string;\n\ninterface MatchSorterOptions<ItemType = unknown> {\n keys?: ReadonlyArray<KeyOption<ItemType>>;\n threshold?: Ranking;\n baseSort?: BaseSorter<ItemType>;\n keepDiacritics?: boolean;\n sorter?: Sorter<ItemType>;\n}\ntype IndexableByString = Record<string, unknown>;\n\nconst rankings = {\n CASE_SENSITIVE_EQUAL: 7,\n EQUAL: 6,\n STARTS_WITH: 5,\n WORD_STARTS_WITH: 4,\n CONTAINS: 3,\n ACRONYM: 2,\n MATCHES: 1,\n NO_MATCH: 0\n} as const;\n\ntype Ranking = (typeof rankings)[keyof typeof rankings];\n\nconst defaultBaseSortFn: BaseSorter<unknown> = (a, b) =>\n String(a.rankedValue).localeCompare(String(b.rankedValue));\n\n/**\n * Takes an array of items and a value and returns a new array with the items that match the given value\n * @param items - the items to sort\n * @param value - the value to use for ranking\n * @param options - Some options to configure the sorter\n * @returns - the new sorted array\n */\nfunction matchSorter<ItemType = string>(\n items: ReadonlyArray<ItemType>,\n value: string,\n options: MatchSorterOptions<ItemType> = {}\n): Array<ItemType> {\n const {\n keys,\n threshold = rankings.MATCHES,\n baseSort = defaultBaseSortFn,\n sorter = matchedItems =>\n matchedItems.sort((a, b) => sortRankedValues(a, b, baseSort))\n } = options;\n const matchedItems = items.reduce(\n (ret: Array<RankedItem<ItemType>>, item: ItemType, index: number) =>\n reduceItemsToRanked(ret, item, index),\n []\n );\n\n return sorter(matchedItems).map(({ item }) => item);\n\n function reduceItemsToRanked(\n matches: Array<RankedItem<ItemType>>,\n item: ItemType,\n index: number\n ): Array<RankedItem<ItemType>> {\n const rankingInfo = getHighestRanking(item, keys, value, options);\n const { rank, keyThreshold = threshold } = rankingInfo;\n if (rank >= keyThreshold) {\n matches.push({\n ...rankingInfo,\n item,\n index\n });\n }\n return matches;\n }\n}\n\nmatchSorter.rankings = rankings;\n\n/**\n * Gets the highest ranking for value for the given item based on its values for the given keys\n * @param item - the item to rank\n * @param keys - the keys to get values from the item for the ranking\n * @param value - the value to rank against\n * @param options - options to control the ranking\n * @returns The highest ranking\n */\nfunction getHighestRanking<ItemType>(\n item: ItemType,\n keys: ReadonlyArray<KeyOption<ItemType>> | undefined,\n value: string,\n options: MatchSorterOptions<ItemType>\n): RankingInfo {\n if (!keys) {\n // if keys is not specified, then we assume the item given is ready to be matched\n const stringItem = item as unknown as string;\n\n return {\n // ends up being duplicate of 'item' in matches but consistent\n rankedValue: stringItem,\n rank: getMatchRanking(stringItem, value, options),\n keyIndex: -1,\n keyThreshold: options.threshold\n };\n }\n const valuesToRank = getAllValuesToRank(item, keys);\n\n return valuesToRank.reduce(\n (\n { rank, rankedValue, keyIndex, keyThreshold },\n { itemValue, attributes },\n i\n ) => {\n let newRank = getMatchRanking(itemValue, value, options);\n let newRankedValue = rankedValue;\n const { minRanking, maxRanking, threshold } = attributes;\n if (newRank < minRanking && newRank >= rankings.MATCHES) {\n newRank = minRanking;\n } else if (newRank > maxRanking) {\n newRank = maxRanking;\n }\n if (newRank > rank) {\n rank = newRank as 0;\n keyIndex = i;\n keyThreshold = threshold;\n newRankedValue = itemValue;\n }\n return {\n rankedValue: newRankedValue,\n rank,\n keyIndex,\n keyThreshold\n };\n },\n {\n rankedValue: item as unknown as string,\n rank: rankings.NO_MATCH,\n keyIndex: -1,\n keyThreshold: options.threshold\n }\n );\n}\n\n/**\n * Gives a rankings score based on how well the two strings match.\n * @param testString - the string to test against\n * @param stringToRank - the string to rank\n * @param options - options for the match (like keepDiacritics for comparison)\n * @returns the ranking for how well stringToRank matches testString\n */\nfunction getMatchRanking<ItemType>(\n testString: string,\n stringToRank: string,\n options: MatchSorterOptions<ItemType>\n): Ranking {\n testString = prepareValueForComparison(testString, options);\n stringToRank = prepareValueForComparison(stringToRank, options);\n\n // too long\n if (stringToRank.length > testString.length) {\n return rankings.NO_MATCH;\n }\n\n // case sensitive equals\n if (testString === stringToRank) {\n return rankings.CASE_SENSITIVE_EQUAL;\n }\n\n // Lower casing before further comparison\n testString = testString.toLowerCase();\n stringToRank = stringToRank.toLowerCase();\n\n // case insensitive equals\n if (testString === stringToRank) {\n return rankings.EQUAL;\n }\n\n // starts with\n if (testString.startsWith(stringToRank)) {\n return rankings.STARTS_WITH;\n }\n\n // word starts with\n if (testString.includes(` ${stringToRank}`)) {\n return rankings.WORD_STARTS_WITH;\n }\n\n // contains\n if (testString.includes(stringToRank)) {\n return rankings.CONTAINS;\n } else if (stringToRank.length === 1) {\n // If the only character in the given stringToRank\n // isn't even contained in the testString, then\n // it's definitely not a match.\n return rankings.NO_MATCH;\n }\n\n // acronym\n if (getAcronym(testString).includes(stringToRank)) {\n return rankings.ACRONYM;\n }\n\n // will return a number between rankings.MATCHES and\n // rankings.MATCHES + 1 depending on how close of a match it is.\n return getClosenessRanking(testString, stringToRank);\n}\n\n/**\n * Generates an acronym for a string.\n *\n * @param value - the string for which to produce the acronym\n * @returns the acronym\n */\nfunction getAcronym(value: string): string {\n let acronym = \"\";\n const wordsInString = value.split(\" \");\n for (const wordInString of wordsInString) {\n const splitByHyphenWords = wordInString.split(\"-\");\n for (const splitByHyphenWord of splitByHyphenWords) {\n acronym += splitByHyphenWord.slice(0, 1);\n }\n }\n return acronym;\n}\n\n/**\n * Returns a score based on how spread apart the\n * characters from the stringToRank are within the testString.\n * A number close to rankings.MATCHES represents a loose match. A number close\n * to rankings.MATCHES + 1 represents a tighter match.\n * @param testString - the string to test against\n * @param stringToRank - the string to rank\n * @returns the number between rankings.MATCHES and\n * rankings.MATCHES + 1 for how well stringToRank matches testString\n */\nfunction getClosenessRanking(\n testString: string,\n stringToRank: string\n): Ranking {\n let matchingInOrderCharCount = 0;\n let charNumber = 0;\n function findMatchingCharacter(\n matchChar: string,\n string: string,\n index: number\n ) {\n for (let j = index, J = string.length; j < J; j++) {\n const stringChar = string[j];\n if (stringChar === matchChar) {\n matchingInOrderCharCount += 1;\n return j + 1;\n }\n }\n return -1;\n }\n function getRanking(spread: number) {\n const spreadPercentage = 1 / spread;\n const inOrderPercentage = matchingInOrderCharCount / stringToRank.length;\n const ranking = rankings.MATCHES + inOrderPercentage * spreadPercentage;\n\n return ranking as Ranking;\n }\n const firstIndex = findMatchingCharacter(stringToRank[0]!, testString, 0);\n if (firstIndex < 0) {\n return rankings.NO_MATCH;\n }\n charNumber = firstIndex;\n for (let i = 1, I = stringToRank.length; i < I; i++) {\n const matchChar = stringToRank[i];\n charNumber = findMatchingCharacter(matchChar!, testString, charNumber);\n const found = charNumber > -1;\n if (!found) {\n return rankings.NO_MATCH;\n }\n }\n\n const spread = charNumber - firstIndex;\n\n return getRanking(spread);\n}\n\n/**\n * Sorts items that have a rank, index, and keyIndex\n * @param a - the first item to sort\n * @param b - the second item to sort\n * @returns -1 if a should come first, 1 if b should come first, 0 if equal\n */\nfunction sortRankedValues<ItemType>(\n a: RankedItem<ItemType>,\n b: RankedItem<ItemType>,\n baseSort: BaseSorter<ItemType>\n): number {\n const aFirst = -1;\n const bFirst = 1;\n const { rank: aRank, keyIndex: aKeyIndex } = a;\n const { rank: bRank, keyIndex: bKeyIndex } = b;\n const same = aRank === bRank;\n if (same) {\n if (aKeyIndex === bKeyIndex) {\n // use the base sort function as a tie-breaker\n return baseSort(a, b);\n }\n return aKeyIndex < bKeyIndex ? aFirst : bFirst;\n }\n return aRank > bRank ? aFirst : bFirst;\n}\n\n/**\n * Prepares value for comparison by stringifying it, removing diacritics (if specified)\n * @param value - the value to clean\n * @param options - options for the match (like keepDiacritics for comparison)\n * @returns the prepared value\n */\nfunction prepareValueForComparison<ItemType>(\n value: string,\n options: MatchSorterOptions<ItemType>\n): string {\n // value might not actually be a string at this point (we don't get to choose)\n // so part of preparing the value for comparison is ensure that it is a string\n value = `${value}`; // toString\n if (!options.keepDiacritics) {\n value = removeAccents(value);\n }\n return value;\n}\n\n/**\n * Gets value for key in item at arbitrarily nested keypath\n * @param item - the item\n * @param key - the potentially nested keypath or property callback\n * @returns - an array containing the value(s) at the nested keypath\n */\nfunction getItemValues<ItemType>(\n item: ItemType,\n key: KeyOption<ItemType>\n): Array<string> {\n if (typeof key === \"object\") {\n key = key.key as string;\n }\n let value: string | Array<string> | null | unknown;\n if (typeof key === \"function\") {\n value = key(item);\n } else if (item === null) {\n value = null;\n } else if (Object.hasOwnProperty.call(item, key)) {\n value = (item as IndexableByString)[key];\n } else if (key.includes(\".\")) {\n return getNestedValues<ItemType>(key, item);\n } else {\n value = null;\n }\n\n // because `value` can also be undefined\n if (value === null) {\n return [];\n }\n if (Array.isArray(value)) {\n return value;\n }\n return [String(value)];\n}\n\n/**\n * Given path: \"foo.bar.baz\"\n * And item: \\{foo: \\{bar: \\{baz: 'buzz'\\}\\}\\}\n * -\\> 'buzz'\n *\n * @param path - a dot-separated set of keys\n * @param item - the item to get the value from\n */\nfunction getNestedValues<ItemType>(\n path: string,\n item: ItemType\n): Array<string> {\n const keys = path.split(\".\");\n\n type ValueA = Array<ItemType | IndexableByString | string>;\n let values: ValueA = [item];\n\n for (let i = 0, I = keys.length; i < I; i++) {\n const nestedKey = keys[i];\n let nestedValues: ValueA = [];\n\n for (let j = 0, J = values.length; j < J; j++) {\n const nestedItem = values[j];\n\n if (nestedItem === null) {\n continue;\n }\n\n if (nestedKey && Object.hasOwnProperty.call(nestedItem, nestedKey)) {\n const nestedValue = (nestedItem as IndexableByString)[nestedKey];\n if (nestedValue !== null) {\n nestedValues.push(nestedValue as IndexableByString | string);\n }\n } else if (nestedItem && nestedKey === \"*\") {\n // ensure that values is an array\n nestedValues = [...nestedValues, nestedItem];\n }\n }\n\n values = nestedValues;\n }\n\n if (Array.isArray(values[0])) {\n // keep allowing the implicit wildcard for an array of strings at the end of\n // the path; don't use `.flat()` because that's not available in node.js v10\n const result: Array<string> = [];\n\n return result.concat(...(values as Array<string>));\n }\n // Based on our logic it should be an array of strings by now...\n // assuming the user's path terminated in strings\n return values as Array<string>;\n}\n\n/**\n * Gets all the values for the given keys in the given item and returns an array of those values\n * @param item - the item from which the values will be retrieved\n * @param keys - the keys to use to retrieve the values\n * @returns objects with \\{itemValue, attributes\\}\n */\nfunction getAllValuesToRank<ItemType>(\n item: ItemType,\n keys: ReadonlyArray<KeyOption<ItemType>>\n) {\n const allValues: Array<{ itemValue: string; attributes: KeyAttributes }> = [];\n for (let j = 0, J = keys.length; j < J; j++) {\n const key = keys[j];\n const attributes = getKeyAttributes(key!);\n const itemValues = getItemValues(item, key!);\n for (let i = 0, I = itemValues.length; i < I; i++) {\n allValues.push({\n itemValue: itemValues[i]!,\n attributes\n });\n }\n }\n return allValues;\n}\n\nconst defaultKeyAttributes = {\n maxRanking: Infinity as Ranking,\n minRanking: -Infinity as Ranking\n};\n/**\n * Gets all the attributes for the given key\n * @param key - the key from which the attributes will be retrieved\n * @returns object containing the key's attributes\n */\nfunction getKeyAttributes<ItemType>(key: KeyOption<ItemType>): KeyAttributes {\n if (typeof key === \"string\") {\n return defaultKeyAttributes;\n }\n return {\n ...defaultKeyAttributes,\n ...key\n };\n}\n\nexport { defaultBaseSortFn, matchSorter, rankings };\n\nexport type {\n KeyAttributes,\n KeyAttributesOptions,\n KeyOption,\n MatchSorterOptions,\n RankingInfo,\n ValueGetterKey\n};\n"],"mappings":";;;;;;;;;AA0EA,MAAM,WAAW;CACf,sBAAsB;CACtB,OAAO;CACP,aAAa;CACb,kBAAkB;CAClB,UAAU;CACV,SAAS;CACT,SAAS;CACT,UAAU;CACX;AAID,MAAM,qBAA0C,GAAG,MACjD,OAAO,EAAE,YAAY,CAAC,cAAc,OAAO,EAAE,YAAY,CAAC;;;;;;;;AAS5D,SAAS,YACP,OACA,OACA,UAAwC,EAAE,EACzB;CACjB,MAAM,EACJ,MACA,YAAY,SAAS,SACrB,WAAW,mBACX,UAAS,iBACP,aAAa,MAAM,GAAG,MAAM,iBAAiB,GAAG,GAAG,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B;AAGF,OAAI,aAAa,OAAO,eAAe,KAAK,YAAY,UAAU,EAAE;IAClE,MAAM,cAAe,WAAiC;AACtD,QAAI,gBAAgB,KAClB,cAAa,KAAK,YAA0C;cAErD,cAAc,cAAc,IAErC,gBAAe,CAAC,GAAG,cAAc,WAAW;;AAIhD,WAAS;;AAGX,KAAI,MAAM,QAAQ,OAAO,GAAG,CAK1B,QAAO,EAAM,CAAC,OAAO,GAAI,OAAyB;AAIpD,QAAO;;;;;;;;AAST,SAAS,mBACP,MACA,MACA;CACA,MAAM,YAAqE,EAAE;AAC7E,MAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,IAAI,GAAG,KAAK;EAC3C,MAAM,MAAM,KAAK;EACjB,MAAM,aAAa,iBAAiB,IAAK;EACzC,MAAM,aAAa,cAAc,MAAM,IAAK;AAC5C,OAAK,IAAI,IAAI,GAAG,IAAI,WAAW,QAAQ,IAAI,GAAG,IAC5C,WAAU,KAAK;GACb,WAAW,WAAW;GACtB;GACD,CAAC;;AAGN,QAAO;;AAGT,MAAM,uBAAuB;CAC3B,YAAY;CACZ,YAAY;CACb;;;;;;AAMD,SAAS,iBAA2B,KAAyC;AAC3E,KAAI,OAAO,QAAQ,SACjB,QAAO;AAET,QAAO;EACL,GAAG;EACH,GAAG;EACJ"}
@@ -0,0 +1,12 @@
1
+ const require_match_sorter = require('./match-sorter.cjs');
2
+ let vitest = require("vitest");
3
+
4
+ //#region src/match-sorter.test.ts
5
+ (0, vitest.describe)("match-sorter.ts exports", () => {
6
+ (0, vitest.it)("loads module exports", () => {
7
+ (0, vitest.expect)(require_match_sorter.match_sorter_exports).toBeDefined();
8
+ (0, vitest.expect)(typeof require_match_sorter.match_sorter_exports).toBe("object");
9
+ });
10
+ });
11
+
12
+ //#endregion
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,14 @@
1
+ import { match_sorter_exports } from "./match-sorter.mjs";
2
+ import { describe, expect, it } from "vitest";
3
+
4
+ //#region src/match-sorter.test.ts
5
+ describe("match-sorter.ts exports", () => {
6
+ it("loads module exports", () => {
7
+ expect(match_sorter_exports).toBeDefined();
8
+ expect(typeof match_sorter_exports).toBe("object");
9
+ });
10
+ });
11
+
12
+ //#endregion
13
+ export { };
14
+ //# sourceMappingURL=match-sorter.test.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"match-sorter.test.mjs","names":["moduleExports"],"sources":["../src/match-sorter.test.ts"],"sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport * as moduleExports from \"./match-sorter.ts\";\n\ndescribe(\"match-sorter.ts exports\", () => {\n it(\"loads module exports\", () => {\n expect(moduleExports).toBeDefined();\n expect(typeof moduleExports).toBe(\"object\");\n });\n});\n"],"mappings":";;;;AAGA,SAAS,iCAAiC;AACxC,IAAG,8BAA8B;AAC/B,SAAOA,qBAAc,CAAC,aAAa;AACnC,SAAO,OAAOA,qBAAc,CAAC,KAAK,SAAS;GAC3C;EACF"}
package/dist/memoize.cjs CHANGED
@@ -1,6 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
2
3
 
3
4
  //#region src/memoize.ts
5
+ var memoize_exports = /* @__PURE__ */ require_runtime.__exportAll({ memoizeOnId: () => memoizeOnId });
4
6
  /**
5
7
  * Memoizes a function based on its string identifier.
6
8
  *
@@ -18,4 +20,10 @@ const memoizeOnId = (fn) => {
18
20
  };
19
21
 
20
22
  //#endregion
21
- exports.memoizeOnId = memoizeOnId;
23
+ exports.memoizeOnId = memoizeOnId;
24
+ Object.defineProperty(exports, 'memoize_exports', {
25
+ enumerable: true,
26
+ get: function () {
27
+ return memoize_exports;
28
+ }
29
+ });
package/dist/memoize.mjs CHANGED
@@ -1,4 +1,7 @@
1
+ import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
2
+
1
3
  //#region src/memoize.ts
4
+ var memoize_exports = /* @__PURE__ */ __exportAll({ memoizeOnId: () => memoizeOnId });
2
5
  /**
3
6
  * Memoizes a function based on its string identifier.
4
7
  *
@@ -16,5 +19,5 @@ const memoizeOnId = (fn) => {
16
19
  };
17
20
 
18
21
  //#endregion
19
- export { memoizeOnId };
22
+ export { memoizeOnId, memoize_exports };
20
23
  //# sourceMappingURL=memoize.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"memoize.mjs","names":[],"sources":["../src/memoize.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/**\n * Memoizes a function based on its string identifier.\n *\n * @param fn - The function to memoize.\n * @returns A memoized version of the input function.\n */\nexport const memoizeOnId = <T>(fn: (id: string) => T) => {\n // eslint-disable-next-line ts/unbound-method\n const hasOwnProperty = Object.prototype.hasOwnProperty;\n const results: Record<string, T> = {};\n\n const memoizedFn = (id: string) => {\n if (hasOwnProperty.call(results, id)) {\n return results[id];\n }\n return (results[id] = fn(id));\n };\n\n return memoizedFn;\n};\n"],"mappings":";;;;;;;AAwBA,MAAa,eAAkB,OAA0B;CAEvD,MAAM,iBAAiB,OAAO,UAAU;CACxC,MAAM,UAA6B,EAAE;CAErC,MAAM,cAAc,OAAe;AACjC,MAAI,eAAe,KAAK,SAAS,GAAG,CAClC,QAAO,QAAQ;AAEjB,SAAQ,QAAQ,MAAM,GAAG,GAAG;;AAG9B,QAAO"}
1
+ {"version":3,"file":"memoize.mjs","names":[],"sources":["../src/memoize.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/**\n * Memoizes a function based on its string identifier.\n *\n * @param fn - The function to memoize.\n * @returns A memoized version of the input function.\n */\nexport const memoizeOnId = <T>(fn: (id: string) => T) => {\n // eslint-disable-next-line ts/unbound-method\n const hasOwnProperty = Object.prototype.hasOwnProperty;\n const results: Record<string, T> = {};\n\n const memoizedFn = (id: string) => {\n if (hasOwnProperty.call(results, id)) {\n return results[id];\n }\n return (results[id] = fn(id));\n };\n\n return memoizedFn;\n};\n"],"mappings":";;;;;;;;;;AAwBA,MAAa,eAAkB,OAA0B;CAEvD,MAAM,iBAAiB,OAAO,UAAU;CACxC,MAAM,UAA6B,EAAE;CAErC,MAAM,cAAc,OAAe;AACjC,MAAI,eAAe,KAAK,SAAS,GAAG,CAClC,QAAO,QAAQ;AAEjB,SAAQ,QAAQ,MAAM,GAAG,GAAG;;AAG9B,QAAO"}
@@ -0,0 +1,12 @@
1
+ const require_memoize = require('./memoize.cjs');
2
+ let vitest = require("vitest");
3
+
4
+ //#region src/memoize.test.ts
5
+ (0, vitest.describe)("memoize.ts exports", () => {
6
+ (0, vitest.it)("loads module exports", () => {
7
+ (0, vitest.expect)(require_memoize.memoize_exports).toBeDefined();
8
+ (0, vitest.expect)(typeof require_memoize.memoize_exports).toBe("object");
9
+ });
10
+ });
11
+
12
+ //#endregion
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,14 @@
1
+ import { memoize_exports } from "./memoize.mjs";
2
+ import { describe, expect, it } from "vitest";
3
+
4
+ //#region src/memoize.test.ts
5
+ describe("memoize.ts exports", () => {
6
+ it("loads module exports", () => {
7
+ expect(memoize_exports).toBeDefined();
8
+ expect(typeof memoize_exports).toBe("object");
9
+ });
10
+ });
11
+
12
+ //#endregion
13
+ export { };
14
+ //# sourceMappingURL=memoize.test.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memoize.test.mjs","names":["moduleExports"],"sources":["../src/memoize.test.ts"],"sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport * as moduleExports from \"./memoize.ts\";\n\ndescribe(\"memoize.ts exports\", () => {\n it(\"loads module exports\", () => {\n expect(moduleExports).toBeDefined();\n expect(typeof moduleExports).toBe(\"object\");\n });\n});\n"],"mappings":";;;;AAGA,SAAS,4BAA4B;AACnC,IAAG,8BAA8B;AAC/B,SAAOA,gBAAc,CAAC,aAAa;AACnC,SAAO,OAAOA,gBAAc,CAAC,KAAK,SAAS;GAC3C;EACF"}
package/dist/noop.cjs CHANGED
@@ -1,6 +1,11 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
2
3
 
3
4
  //#region src/noop.ts
5
+ var noop_exports = /* @__PURE__ */ require_runtime.__exportAll({
6
+ asyncNoop: () => asyncNoop,
7
+ noop: () => noop
8
+ });
4
9
  /**
5
10
  * A no op, or no-op, function for no operation
6
11
  *
@@ -22,4 +27,10 @@ async function asyncNoop(_params) {}
22
27
 
23
28
  //#endregion
24
29
  exports.asyncNoop = asyncNoop;
25
- exports.noop = noop;
30
+ exports.noop = noop;
31
+ Object.defineProperty(exports, 'noop_exports', {
32
+ enumerable: true,
33
+ get: function () {
34
+ return noop_exports;
35
+ }
36
+ });
package/dist/noop.mjs CHANGED
@@ -1,4 +1,10 @@
1
+ import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
2
+
1
3
  //#region src/noop.ts
4
+ var noop_exports = /* @__PURE__ */ __exportAll({
5
+ asyncNoop: () => asyncNoop,
6
+ noop: () => noop
7
+ });
2
8
  /**
3
9
  * A no op, or no-op, function for no operation
4
10
  *
@@ -19,5 +25,5 @@ const noop = (_params) => {};
19
25
  async function asyncNoop(_params) {}
20
26
 
21
27
  //#endregion
22
- export { asyncNoop, noop };
28
+ export { asyncNoop, noop, noop_exports };
23
29
  //# sourceMappingURL=noop.mjs.map
package/dist/noop.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"noop.mjs","names":[],"sources":["../src/noop.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/**\n * A no op, or no-op, function for no operation\n *\n * @remarks Please see {@link https://dev.to/praneshpsg239/noop-in-javascript-478h | this article} for more information.\n *\n * @param _params - An optional parameter passed to the function. It can be anything (but is not used in any way)\n */\nexport const noop = (_params?: unknown): void => {};\n\n/**\n * An asynchronous no-operation function that does nothing.\n * This can be used as a placeholder or default function.\n *\n * @example\n * asyncNoop(); // Does nothing\n *\n * @returns This function returns a Promise that resolves to undefined.\n */\nexport async function asyncNoop(_params?: unknown): Promise<void> {}\n"],"mappings":";;;;;;;;AAyBA,MAAa,QAAQ,YAA4B;;;;;;;;;;AAWjD,eAAsB,UAAU,SAAkC"}
1
+ {"version":3,"file":"noop.mjs","names":[],"sources":["../src/noop.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/**\n * A no op, or no-op, function for no operation\n *\n * @remarks Please see {@link https://dev.to/praneshpsg239/noop-in-javascript-478h | this article} for more information.\n *\n * @param _params - An optional parameter passed to the function. It can be anything (but is not used in any way)\n */\nexport const noop = (_params?: unknown): void => {};\n\n/**\n * An asynchronous no-operation function that does nothing.\n * This can be used as a placeholder or default function.\n *\n * @example\n * asyncNoop(); // Does nothing\n *\n * @returns This function returns a Promise that resolves to undefined.\n */\nexport async function asyncNoop(_params?: unknown): Promise<void> {}\n"],"mappings":";;;;;;;;;;;;;;AAyBA,MAAa,QAAQ,YAA4B;;;;;;;;;;AAWjD,eAAsB,UAAU,SAAkC"}
@@ -0,0 +1,12 @@
1
+ const require_noop = require('./noop.cjs');
2
+ let vitest = require("vitest");
3
+
4
+ //#region src/noop.test.ts
5
+ (0, vitest.describe)("noop.ts exports", () => {
6
+ (0, vitest.it)("loads module exports", () => {
7
+ (0, vitest.expect)(require_noop.noop_exports).toBeDefined();
8
+ (0, vitest.expect)(typeof require_noop.noop_exports).toBe("object");
9
+ });
10
+ });
11
+
12
+ //#endregion
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,14 @@
1
+ import { noop_exports } from "./noop.mjs";
2
+ import { describe, expect, it } from "vitest";
3
+
4
+ //#region src/noop.test.ts
5
+ describe("noop.ts exports", () => {
6
+ it("loads module exports", () => {
7
+ expect(noop_exports).toBeDefined();
8
+ expect(typeof noop_exports).toBe("object");
9
+ });
10
+ });
11
+
12
+ //#endregion
13
+ export { };
14
+ //# sourceMappingURL=noop.test.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"noop.test.mjs","names":["moduleExports"],"sources":["../src/noop.test.ts"],"sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport * as moduleExports from \"./noop.ts\";\n\ndescribe(\"noop.ts exports\", () => {\n it(\"loads module exports\", () => {\n expect(moduleExports).toBeDefined();\n expect(typeof moduleExports).toBe(\"object\");\n });\n});\n"],"mappings":";;;;AAGA,SAAS,yBAAyB;AAChC,IAAG,8BAA8B;AAC/B,SAAOA,aAAc,CAAC,aAAa;AACnC,SAAO,OAAOA,aAAc,CAAC,KAAK,SAAS;GAC3C;EACF"}
package/dist/omit.cjs CHANGED
@@ -1,6 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
2
3
 
3
4
  //#region src/omit.ts
5
+ var omit_exports = /* @__PURE__ */ require_runtime.__exportAll({ omit: () => omit });
4
6
  /**
5
7
  * Creates a new object with specified keys omitted.
6
8
  *
@@ -28,4 +30,10 @@ function omit(obj, keys) {
28
30
  }
29
31
 
30
32
  //#endregion
31
- exports.omit = omit;
33
+ exports.omit = omit;
34
+ Object.defineProperty(exports, 'omit_exports', {
35
+ enumerable: true,
36
+ get: function () {
37
+ return omit_exports;
38
+ }
39
+ });
package/dist/omit.mjs CHANGED
@@ -1,4 +1,7 @@
1
+ import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
2
+
1
3
  //#region src/omit.ts
4
+ var omit_exports = /* @__PURE__ */ __exportAll({ omit: () => omit });
2
5
  /**
3
6
  * Creates a new object with specified keys omitted.
4
7
  *
@@ -26,5 +29,5 @@ function omit(obj, keys) {
26
29
  }
27
30
 
28
31
  //#endregion
29
- export { omit };
32
+ export { omit, omit_exports };
30
33
  //# sourceMappingURL=omit.mjs.map