@gtkx/utils 1.0.0-rc.1 → 1.0.0-rc.3

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 (319) hide show
  1. package/dist/array/index-before-or-end.d.ts +15 -0
  2. package/dist/array/index-before-or-end.d.ts.map +1 -0
  3. package/dist/array/index-before-or-end.js +21 -0
  4. package/dist/array/index-before-or-end.js.map +1 -0
  5. package/dist/array/index.d.ts +6 -0
  6. package/dist/array/index.d.ts.map +1 -0
  7. package/dist/array/index.js +6 -0
  8. package/dist/array/index.js.map +1 -0
  9. package/dist/array/remove.d.ts +14 -0
  10. package/dist/array/remove.d.ts.map +1 -0
  11. package/dist/array/remove.js +19 -0
  12. package/dist/array/remove.js.map +1 -0
  13. package/dist/array/sort-strings-by.d.ts +15 -0
  14. package/dist/array/sort-strings-by.d.ts.map +1 -0
  15. package/dist/array/sort-strings-by.js +17 -0
  16. package/dist/array/sort-strings-by.js.map +1 -0
  17. package/dist/array/sort-strings.d.ts +12 -0
  18. package/dist/array/sort-strings.d.ts.map +1 -0
  19. package/dist/array/sort-strings.js +14 -0
  20. package/dist/array/sort-strings.js.map +1 -0
  21. package/dist/array/uniq-by.d.ts +18 -0
  22. package/dist/array/uniq-by.d.ts.map +1 -0
  23. package/dist/array/uniq-by.js +29 -0
  24. package/dist/array/uniq-by.js.map +1 -0
  25. package/dist/class/any-class.d.ts +8 -0
  26. package/dist/class/any-class.d.ts.map +1 -0
  27. package/dist/class/any-class.js +2 -0
  28. package/dist/class/any-class.js.map +1 -0
  29. package/dist/class/get-parent-class.d.ts +10 -0
  30. package/dist/class/get-parent-class.d.ts.map +1 -0
  31. package/dist/class/get-parent-class.js +12 -0
  32. package/dist/class/get-parent-class.js.map +1 -0
  33. package/dist/class/index.d.ts +4 -0
  34. package/dist/class/index.d.ts.map +1 -0
  35. package/dist/class/index.js +3 -0
  36. package/dist/class/index.js.map +1 -0
  37. package/dist/class/walk-class-chain.d.ts +13 -0
  38. package/dist/class/walk-class-chain.d.ts.map +1 -0
  39. package/dist/class/walk-class-chain.js +23 -0
  40. package/dist/class/walk-class-chain.js.map +1 -0
  41. package/dist/error/error-like.d.ts +6 -0
  42. package/dist/error/error-like.d.ts.map +1 -0
  43. package/dist/error/error-like.js +15 -0
  44. package/dist/error/error-like.js.map +1 -0
  45. package/dist/error/error-message.d.ts +13 -0
  46. package/dist/error/error-message.d.ts.map +1 -0
  47. package/dist/error/error-message.js +16 -0
  48. package/dist/error/error-message.js.map +1 -0
  49. package/dist/error/format-child-process-error.d.ts +12 -0
  50. package/dist/error/format-child-process-error.d.ts.map +1 -0
  51. package/dist/error/format-child-process-error.js +21 -0
  52. package/dist/error/format-child-process-error.js.map +1 -0
  53. package/dist/error/index.d.ts +4 -0
  54. package/dist/error/index.d.ts.map +1 -0
  55. package/dist/error/index.js +4 -0
  56. package/dist/error/index.js.map +1 -0
  57. package/dist/error/normalize-error.d.ts +13 -0
  58. package/dist/error/normalize-error.d.ts.map +1 -0
  59. package/dist/error/normalize-error.js +20 -0
  60. package/dist/error/normalize-error.js.map +1 -0
  61. package/dist/function/call-method.d.ts +3 -0
  62. package/dist/function/call-method.d.ts.map +1 -0
  63. package/dist/function/call-method.js +19 -0
  64. package/dist/function/call-method.js.map +1 -0
  65. package/dist/function/index.d.ts +2 -0
  66. package/dist/function/index.d.ts.map +1 -0
  67. package/dist/function/index.js +2 -0
  68. package/dist/function/index.js.map +1 -0
  69. package/dist/index.d.ts +13 -9
  70. package/dist/index.d.ts.map +1 -1
  71. package/dist/index.js +13 -9
  72. package/dist/index.js.map +1 -1
  73. package/dist/log/create-logger.d.ts +15 -0
  74. package/dist/log/create-logger.d.ts.map +1 -0
  75. package/dist/log/create-logger.js +17 -0
  76. package/dist/log/create-logger.js.map +1 -0
  77. package/dist/log/default-logger.d.ts +36 -0
  78. package/dist/log/default-logger.d.ts.map +1 -0
  79. package/dist/log/default-logger.js +44 -0
  80. package/dist/log/default-logger.js.map +1 -0
  81. package/dist/log/index.d.ts +4 -0
  82. package/dist/log/index.d.ts.map +1 -0
  83. package/dist/log/index.js +4 -0
  84. package/dist/log/index.js.map +1 -0
  85. package/dist/log/logger.d.ts +64 -0
  86. package/dist/log/logger.d.ts.map +1 -0
  87. package/dist/log/logger.js +100 -0
  88. package/dist/log/logger.js.map +1 -0
  89. package/dist/map/get-or-insert.d.ts +23 -0
  90. package/dist/map/get-or-insert.d.ts.map +1 -0
  91. package/dist/map/get-or-insert.js +25 -0
  92. package/dist/map/get-or-insert.js.map +1 -0
  93. package/dist/map/index.d.ts +2 -0
  94. package/dist/map/index.d.ts.map +1 -0
  95. package/dist/map/index.js +2 -0
  96. package/dist/map/index.js.map +1 -0
  97. package/dist/object/index.d.ts +4 -0
  98. package/dist/object/index.d.ts.map +1 -0
  99. package/dist/object/index.js +4 -0
  100. package/dist/object/index.js.map +1 -0
  101. package/dist/object/omit.d.ts +15 -0
  102. package/dist/object/omit.d.ts.map +1 -0
  103. package/dist/object/omit.js +24 -0
  104. package/dist/object/omit.js.map +1 -0
  105. package/dist/object/pick-by.d.ts +15 -0
  106. package/dist/object/pick-by.d.ts.map +1 -0
  107. package/dist/object/pick-by.js +24 -0
  108. package/dist/object/pick-by.js.map +1 -0
  109. package/dist/object/structured-clone.d.ts +19 -0
  110. package/dist/object/structured-clone.d.ts.map +1 -0
  111. package/dist/object/structured-clone.js +28 -0
  112. package/dist/object/structured-clone.js.map +1 -0
  113. package/dist/predicate/are-object-keys-equal.d.ts +3 -0
  114. package/dist/predicate/are-object-keys-equal.d.ts.map +1 -0
  115. package/dist/predicate/are-object-keys-equal.js +9 -0
  116. package/dist/predicate/are-object-keys-equal.js.map +1 -0
  117. package/dist/predicate/index.d.ts +7 -0
  118. package/dist/predicate/index.d.ts.map +1 -0
  119. package/dist/predicate/index.js +7 -0
  120. package/dist/predicate/index.js.map +1 -0
  121. package/dist/predicate/is-deep-equal.d.ts +3 -0
  122. package/dist/predicate/is-deep-equal.d.ts.map +1 -0
  123. package/dist/predicate/is-deep-equal.js +35 -0
  124. package/dist/predicate/is-deep-equal.js.map +1 -0
  125. package/dist/predicate/is-plain-object.d.ts +17 -0
  126. package/dist/predicate/is-plain-object.d.ts.map +1 -0
  127. package/dist/predicate/is-plain-object.js +23 -0
  128. package/dist/predicate/is-plain-object.js.map +1 -0
  129. package/dist/predicate/is-record.d.ts +14 -0
  130. package/dist/predicate/is-record.d.ts.map +1 -0
  131. package/dist/predicate/is-record.js +16 -0
  132. package/dist/predicate/is-record.js.map +1 -0
  133. package/dist/predicate/is-same-array-by.d.ts +15 -0
  134. package/dist/predicate/is-same-array-by.d.ts.map +1 -0
  135. package/dist/predicate/is-same-array-by.js +20 -0
  136. package/dist/predicate/is-same-array-by.js.map +1 -0
  137. package/dist/predicate/is-same-array.d.ts +15 -0
  138. package/dist/predicate/is-same-array.d.ts.map +1 -0
  139. package/dist/predicate/is-same-array.js +18 -0
  140. package/dist/predicate/is-same-array.js.map +1 -0
  141. package/dist/predicate/is-shallow-equal.d.ts +3 -0
  142. package/dist/predicate/is-shallow-equal.d.ts.map +1 -0
  143. package/dist/predicate/is-shallow-equal.js +28 -0
  144. package/dist/predicate/is-shallow-equal.js.map +1 -0
  145. package/dist/process/exit-code-for-signal.d.ts +14 -0
  146. package/dist/process/exit-code-for-signal.d.ts.map +1 -0
  147. package/dist/process/exit-code-for-signal.js +19 -0
  148. package/dist/process/exit-code-for-signal.js.map +1 -0
  149. package/dist/process/index.d.ts +4 -0
  150. package/dist/process/index.d.ts.map +1 -0
  151. package/dist/process/index.js +4 -0
  152. package/dist/process/index.js.map +1 -0
  153. package/dist/process/install-graceful-shutdown.d.ts +16 -0
  154. package/dist/process/install-graceful-shutdown.d.ts.map +1 -0
  155. package/dist/{graceful-shutdown.js → process/install-graceful-shutdown.js} +28 -28
  156. package/dist/process/install-graceful-shutdown.js.map +1 -0
  157. package/dist/process/resolve-executable.d.ts +14 -0
  158. package/dist/process/resolve-executable.d.ts.map +1 -0
  159. package/dist/process/resolve-executable.js +47 -0
  160. package/dist/process/resolve-executable.js.map +1 -0
  161. package/dist/set/drain.d.ts +11 -0
  162. package/dist/set/drain.d.ts.map +1 -0
  163. package/dist/set/drain.js +16 -0
  164. package/dist/set/drain.js.map +1 -0
  165. package/dist/set/index.d.ts +2 -0
  166. package/dist/set/index.d.ts.map +1 -0
  167. package/dist/set/index.js +2 -0
  168. package/dist/set/index.js.map +1 -0
  169. package/dist/source/index.d.ts +4 -0
  170. package/dist/source/index.d.ts.map +1 -0
  171. package/dist/source/index.js +4 -0
  172. package/dist/source/index.js.map +1 -0
  173. package/dist/source/sanitize-identifier.d.ts +14 -0
  174. package/dist/source/sanitize-identifier.d.ts.map +1 -0
  175. package/dist/source/sanitize-identifier.js +65 -0
  176. package/dist/source/sanitize-identifier.js.map +1 -0
  177. package/dist/source/source-string-literal.d.ts +13 -0
  178. package/dist/source/source-string-literal.d.ts.map +1 -0
  179. package/dist/source/source-string-literal.js +24 -0
  180. package/dist/source/source-string-literal.js.map +1 -0
  181. package/dist/source/to-camel-identifier.d.ts +13 -0
  182. package/dist/source/to-camel-identifier.d.ts.map +1 -0
  183. package/dist/source/to-camel-identifier.js +17 -0
  184. package/dist/source/to-camel-identifier.js.map +1 -0
  185. package/dist/string/camel-case.d.ts +17 -0
  186. package/dist/string/camel-case.d.ts.map +1 -0
  187. package/dist/string/camel-case.js +21 -0
  188. package/dist/string/camel-case.js.map +1 -0
  189. package/dist/string/index.d.ts +6 -0
  190. package/dist/string/index.d.ts.map +1 -0
  191. package/dist/string/index.js +6 -0
  192. package/dist/string/index.js.map +1 -0
  193. package/dist/string/kebab-case.d.ts +14 -0
  194. package/dist/string/kebab-case.d.ts.map +1 -0
  195. package/dist/string/kebab-case.js +16 -0
  196. package/dist/string/kebab-case.js.map +1 -0
  197. package/dist/string/lower-first.d.ts +13 -0
  198. package/dist/string/lower-first.d.ts.map +1 -0
  199. package/dist/string/lower-first.js +15 -0
  200. package/dist/string/lower-first.js.map +1 -0
  201. package/dist/string/pascal-case.d.ts +16 -0
  202. package/dist/string/pascal-case.d.ts.map +1 -0
  203. package/dist/string/pascal-case.js +20 -0
  204. package/dist/string/pascal-case.js.map +1 -0
  205. package/dist/string/upper-first.d.ts +13 -0
  206. package/dist/string/upper-first.d.ts.map +1 -0
  207. package/dist/string/upper-first.js +15 -0
  208. package/dist/string/upper-first.js.map +1 -0
  209. package/dist/string/word-segments.d.ts +3 -0
  210. package/dist/string/word-segments.d.ts.map +1 -0
  211. package/dist/string/word-segments.js +12 -0
  212. package/dist/string/word-segments.js.map +1 -0
  213. package/dist/util/index.d.ts +2 -0
  214. package/dist/util/index.d.ts.map +1 -0
  215. package/dist/util/index.js +2 -0
  216. package/dist/util/index.js.map +1 -0
  217. package/dist/util/package-version.d.ts +12 -0
  218. package/dist/util/package-version.d.ts.map +1 -0
  219. package/dist/util/package-version.js +15 -0
  220. package/dist/util/package-version.js.map +1 -0
  221. package/package.json +1 -3
  222. package/src/array/index-before-or-end.ts +27 -0
  223. package/src/array/index.ts +5 -0
  224. package/src/array/remove.ts +20 -0
  225. package/src/array/sort-strings-by.ts +17 -0
  226. package/src/array/sort-strings.ts +14 -0
  227. package/src/array/uniq-by.ts +33 -0
  228. package/src/class/any-class.ts +10 -0
  229. package/src/class/get-parent-class.ts +15 -0
  230. package/src/class/index.ts +3 -0
  231. package/src/class/walk-class-chain.ts +29 -0
  232. package/src/error/error-like.ts +19 -0
  233. package/src/error/error-message.ts +17 -0
  234. package/src/error/format-child-process-error.ts +24 -0
  235. package/src/error/index.ts +3 -0
  236. package/src/error/normalize-error.ts +22 -0
  237. package/src/function/call-method.ts +22 -0
  238. package/src/function/index.ts +1 -0
  239. package/src/index.ts +13 -19
  240. package/src/log/create-logger.ts +18 -0
  241. package/src/log/default-logger.ts +49 -0
  242. package/src/log/index.ts +3 -0
  243. package/src/log/logger.ts +142 -0
  244. package/src/map/get-or-insert.ts +33 -0
  245. package/src/map/index.ts +1 -0
  246. package/src/object/index.ts +3 -0
  247. package/src/object/omit.ts +26 -0
  248. package/src/object/pick-by.ts +30 -0
  249. package/src/object/structured-clone.ts +31 -0
  250. package/src/predicate/are-object-keys-equal.ts +15 -0
  251. package/src/predicate/index.ts +6 -0
  252. package/src/predicate/is-deep-equal.ts +41 -0
  253. package/src/predicate/is-plain-object.ts +25 -0
  254. package/src/predicate/is-record.ts +16 -0
  255. package/src/predicate/is-same-array-by.ts +21 -0
  256. package/src/predicate/is-same-array.ts +19 -0
  257. package/src/predicate/is-shallow-equal.ts +32 -0
  258. package/src/process/exit-code-for-signal.ts +20 -0
  259. package/src/process/index.ts +3 -0
  260. package/src/{graceful-shutdown.ts → process/install-graceful-shutdown.ts} +48 -36
  261. package/src/process/resolve-executable.ts +57 -0
  262. package/src/set/drain.ts +17 -0
  263. package/src/set/index.ts +1 -0
  264. package/src/source/index.ts +3 -0
  265. package/src/source/sanitize-identifier.ts +66 -0
  266. package/src/source/source-string-literal.ts +27 -0
  267. package/src/source/to-camel-identifier.ts +18 -0
  268. package/src/string/camel-case.ts +22 -0
  269. package/src/string/index.ts +5 -0
  270. package/src/string/kebab-case.ts +18 -0
  271. package/src/string/lower-first.ts +15 -0
  272. package/src/string/pascal-case.ts +21 -0
  273. package/src/string/upper-first.ts +15 -0
  274. package/src/string/word-segments.ts +15 -0
  275. package/src/util/index.ts +1 -0
  276. package/src/util/package-version.ts +16 -0
  277. package/dist/class.d.ts +0 -22
  278. package/dist/class.d.ts.map +0 -1
  279. package/dist/class.js +0 -28
  280. package/dist/class.js.map +0 -1
  281. package/dist/collection.d.ts +0 -30
  282. package/dist/collection.d.ts.map +0 -1
  283. package/dist/collection.js +0 -64
  284. package/dist/collection.js.map +0 -1
  285. package/dist/error.d.ts +0 -21
  286. package/dist/error.d.ts.map +0 -1
  287. package/dist/error.js +0 -40
  288. package/dist/error.js.map +0 -1
  289. package/dist/graceful-shutdown.d.ts +0 -22
  290. package/dist/graceful-shutdown.d.ts.map +0 -1
  291. package/dist/graceful-shutdown.js.map +0 -1
  292. package/dist/log.d.ts +0 -103
  293. package/dist/log.d.ts.map +0 -1
  294. package/dist/log.js +0 -129
  295. package/dist/log.js.map +0 -1
  296. package/dist/package-version.d.ts +0 -7
  297. package/dist/package-version.d.ts.map +0 -1
  298. package/dist/package-version.js +0 -8
  299. package/dist/package-version.js.map +0 -1
  300. package/dist/reflect.d.ts +0 -11
  301. package/dist/reflect.d.ts.map +0 -1
  302. package/dist/reflect.js +0 -14
  303. package/dist/reflect.js.map +0 -1
  304. package/dist/source.d.ts +0 -21
  305. package/dist/source.d.ts.map +0 -1
  306. package/dist/source.js +0 -78
  307. package/dist/source.js.map +0 -1
  308. package/dist/string.d.ts +0 -32
  309. package/dist/string.d.ts.map +0 -1
  310. package/dist/string.js +0 -43
  311. package/dist/string.js.map +0 -1
  312. package/src/class.ts +0 -36
  313. package/src/collection.ts +0 -65
  314. package/src/error.ts +0 -42
  315. package/src/log.ts +0 -164
  316. package/src/package-version.ts +0 -9
  317. package/src/reflect.ts +0 -13
  318. package/src/source.ts +0 -84
  319. package/src/string.ts +0 -46
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Finds the index of the first item matching `before`, or `list.length` when `before` is `null` or
3
+ * nothing matches. Use it to resolve where a new item should be inserted so it lands before the
4
+ * referenced one, defaulting to the end.
5
+ *
6
+ * @template T - The list item type.
7
+ * @template B - The reference value type.
8
+ * @param list - The list to search.
9
+ * @param before - The item to insert before, or `null` to target the end.
10
+ * @param isMatch - Called with each item and the non-null `before`; return `true` on a match.
11
+ * @returns The matched index, or `list.length`.
12
+ */
13
+ declare const indexBeforeOrEnd: <T, B>(list: T[], before: B | null, isMatch: (item: T, before: B) => boolean) => number;
14
+ export { indexBeforeOrEnd };
15
+ //# sourceMappingURL=index-before-or-end.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-before-or-end.d.ts","sourceRoot":"","sources":["../../src/array/index-before-or-end.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,gBAAgB,GAAI,CAAC,EAAE,CAAC,EAC1B,MAAM,CAAC,EAAE,EACT,QAAQ,CAAC,GAAG,IAAI,EAChB,SAAS,CAAC,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,KAAK,OAAO,KACzC,MAQF,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Finds the index of the first item matching `before`, or `list.length` when `before` is `null` or
3
+ * nothing matches. Use it to resolve where a new item should be inserted so it lands before the
4
+ * referenced one, defaulting to the end.
5
+ *
6
+ * @template T - The list item type.
7
+ * @template B - The reference value type.
8
+ * @param list - The list to search.
9
+ * @param before - The item to insert before, or `null` to target the end.
10
+ * @param isMatch - Called with each item and the non-null `before`; return `true` on a match.
11
+ * @returns The matched index, or `list.length`.
12
+ */
13
+ const indexBeforeOrEnd = (list, before, isMatch) => {
14
+ if (before === null) {
15
+ return list.length;
16
+ }
17
+ const index = list.findIndex((item) => isMatch(item, before));
18
+ return index === -1 ? list.length : index;
19
+ };
20
+ export { indexBeforeOrEnd };
21
+ //# sourceMappingURL=index-before-or-end.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-before-or-end.js","sourceRoot":"","sources":["../../src/array/index-before-or-end.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,gBAAgB,GAAG,CACrB,IAAS,EACT,MAAgB,EAChB,OAAwC,EAClC,EAAE;IACR,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IAE9D,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;AAC9C,CAAC,CAAC;AAEF,OAAO,EAAE,gBAAgB,EAAE,CAAC","sourcesContent":["/**\n * Finds the index of the first item matching `before`, or `list.length` when `before` is `null` or\n * nothing matches. Use it to resolve where a new item should be inserted so it lands before the\n * referenced one, defaulting to the end.\n *\n * @template T - The list item type.\n * @template B - The reference value type.\n * @param list - The list to search.\n * @param before - The item to insert before, or `null` to target the end.\n * @param isMatch - Called with each item and the non-null `before`; return `true` on a match.\n * @returns The matched index, or `list.length`.\n */\nconst indexBeforeOrEnd = <T, B>(\n list: T[],\n before: B | null,\n isMatch: (item: T, before: B) => boolean,\n): number => {\n if (before === null) {\n return list.length;\n }\n\n const index = list.findIndex((item) => isMatch(item, before));\n\n return index === -1 ? list.length : index;\n};\n\nexport { indexBeforeOrEnd };\n"]}
@@ -0,0 +1,6 @@
1
+ export { indexBeforeOrEnd } from "./index-before-or-end.js";
2
+ export { remove } from "./remove.js";
3
+ export { sortStringsBy } from "./sort-strings-by.js";
4
+ export { sortStrings } from "./sort-strings.js";
5
+ export { uniqBy } from "./uniq-by.js";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/array/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,6 @@
1
+ export { indexBeforeOrEnd } from "./index-before-or-end.js";
2
+ export { remove } from "./remove.js";
3
+ export { sortStringsBy } from "./sort-strings-by.js";
4
+ export { sortStrings } from "./sort-strings.js";
5
+ export { uniqBy } from "./uniq-by.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/array/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC","sourcesContent":["export { indexBeforeOrEnd } from \"./index-before-or-end.js\";\nexport { remove } from \"./remove.js\";\nexport { sortStringsBy } from \"./sort-strings-by.js\";\nexport { sortStrings } from \"./sort-strings.js\";\nexport { uniqBy } from \"./uniq-by.js\";\n"]}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Removes the first strictly-equal (`===`) occurrence of `value` from `arr` in place.
3
+ *
4
+ * @template T - The type of the array elements.
5
+ * @param arr - The array to mutate.
6
+ * @param value - The value to remove.
7
+ *
8
+ * @example
9
+ * const items = ["a", "b", "c"];
10
+ * remove(items, "b"); // items is now ["a", "c"]
11
+ */
12
+ declare function remove<T>(arr: T[], value: T): void;
13
+ export { remove };
14
+ //# sourceMappingURL=remove.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove.d.ts","sourceRoot":"","sources":["../../src/array/remove.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,iBAAS,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAM3C;AAED,OAAO,EAAE,MAAM,EAAE,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Removes the first strictly-equal (`===`) occurrence of `value` from `arr` in place.
3
+ *
4
+ * @template T - The type of the array elements.
5
+ * @param arr - The array to mutate.
6
+ * @param value - The value to remove.
7
+ *
8
+ * @example
9
+ * const items = ["a", "b", "c"];
10
+ * remove(items, "b"); // items is now ["a", "c"]
11
+ */
12
+ function remove(arr, value) {
13
+ const index = arr.indexOf(value);
14
+ if (index !== -1) {
15
+ arr.splice(index, 1);
16
+ }
17
+ }
18
+ export { remove };
19
+ //# sourceMappingURL=remove.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove.js","sourceRoot":"","sources":["../../src/array/remove.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,SAAS,MAAM,CAAI,GAAQ,EAAE,KAAQ;IACjC,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAEjC,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;QACf,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IACzB,CAAC;AACL,CAAC;AAED,OAAO,EAAE,MAAM,EAAE,CAAC","sourcesContent":["/**\n * Removes the first strictly-equal (`===`) occurrence of `value` from `arr` in place.\n *\n * @template T - The type of the array elements.\n * @param arr - The array to mutate.\n * @param value - The value to remove.\n *\n * @example\n * const items = [\"a\", \"b\", \"c\"];\n * remove(items, \"b\"); // items is now [\"a\", \"c\"]\n */\nfunction remove<T>(arr: T[], value: T): void {\n const index = arr.indexOf(value);\n\n if (index !== -1) {\n arr.splice(index, 1);\n }\n}\n\nexport { remove };\n"]}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Returns the items sorted by a string key using locale-aware comparison.
3
+ *
4
+ * @template T - The type of items being sorted.
5
+ * @param items - The items to sort.
6
+ * @param key - Maps an item to the string its order is decided by.
7
+ * @returns A new array of the items in ascending locale order of their keys.
8
+ *
9
+ * @example
10
+ * sortStringsBy([{ name: "b" }, { name: "a" }], (item) => item.name);
11
+ * // [{ name: "a" }, { name: "b" }]
12
+ */
13
+ declare function sortStringsBy<T>(items: Iterable<T>, key: (item: T) => string): T[];
14
+ export { sortStringsBy };
15
+ //# sourceMappingURL=sort-strings-by.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sort-strings-by.d.ts","sourceRoot":"","sources":["../../src/array/sort-strings-by.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,iBAAS,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,MAAM,GAAG,CAAC,EAAE,CAE3E;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Returns the items sorted by a string key using locale-aware comparison.
3
+ *
4
+ * @template T - The type of items being sorted.
5
+ * @param items - The items to sort.
6
+ * @param key - Maps an item to the string its order is decided by.
7
+ * @returns A new array of the items in ascending locale order of their keys.
8
+ *
9
+ * @example
10
+ * sortStringsBy([{ name: "b" }, { name: "a" }], (item) => item.name);
11
+ * // [{ name: "a" }, { name: "b" }]
12
+ */
13
+ function sortStringsBy(items, key) {
14
+ return [...items].toSorted((a, b) => key(a).localeCompare(key(b)));
15
+ }
16
+ export { sortStringsBy };
17
+ //# sourceMappingURL=sort-strings-by.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sort-strings-by.js","sourceRoot":"","sources":["../../src/array/sort-strings-by.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,SAAS,aAAa,CAAI,KAAkB,EAAE,GAAwB;IAClE,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACvE,CAAC;AAED,OAAO,EAAE,aAAa,EAAE,CAAC","sourcesContent":["/**\n * Returns the items sorted by a string key using locale-aware comparison.\n *\n * @template T - The type of items being sorted.\n * @param items - The items to sort.\n * @param key - Maps an item to the string its order is decided by.\n * @returns A new array of the items in ascending locale order of their keys.\n *\n * @example\n * sortStringsBy([{ name: \"b\" }, { name: \"a\" }], (item) => item.name);\n * // [{ name: \"a\" }, { name: \"b\" }]\n */\nfunction sortStringsBy<T>(items: Iterable<T>, key: (item: T) => string): T[] {\n return [...items].toSorted((a, b) => key(a).localeCompare(key(b)));\n}\n\nexport { sortStringsBy };\n"]}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Returns the values sorted as strings using locale-aware comparison.
3
+ *
4
+ * @param values - The strings to sort.
5
+ * @returns A new array of the values in ascending locale order.
6
+ *
7
+ * @example
8
+ * sortStrings(["b", "a", "c"]); // ["a", "b", "c"]
9
+ */
10
+ declare function sortStrings(values: Iterable<string>): string[];
11
+ export { sortStrings };
12
+ //# sourceMappingURL=sort-strings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sort-strings.d.ts","sourceRoot":"","sources":["../../src/array/sort-strings.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,iBAAS,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,CAEvD;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Returns the values sorted as strings using locale-aware comparison.
3
+ *
4
+ * @param values - The strings to sort.
5
+ * @returns A new array of the values in ascending locale order.
6
+ *
7
+ * @example
8
+ * sortStrings(["b", "a", "c"]); // ["a", "b", "c"]
9
+ */
10
+ function sortStrings(values) {
11
+ return [...values].toSorted((a, b) => a.localeCompare(b));
12
+ }
13
+ export { sortStrings };
14
+ //# sourceMappingURL=sort-strings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sort-strings.js","sourceRoot":"","sources":["../../src/array/sort-strings.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,SAAS,WAAW,CAAC,MAAwB;IACzC,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9D,CAAC;AAED,OAAO,EAAE,WAAW,EAAE,CAAC","sourcesContent":["/**\n * Returns the values sorted as strings using locale-aware comparison.\n *\n * @param values - The strings to sort.\n * @returns A new array of the values in ascending locale order.\n *\n * @example\n * sortStrings([\"b\", \"a\", \"c\"]); // [\"a\", \"b\", \"c\"]\n */\nfunction sortStrings(values: Iterable<string>): string[] {\n return [...values].toSorted((a, b) => a.localeCompare(b));\n}\n\nexport { sortStrings };\n"]}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Returns a new array of the unique elements of `arr`, keyed by the value the `mapper` returns.
3
+ *
4
+ * When two elements map to the same key the first occurrence is kept and later ones discarded,
5
+ * preserving first-seen order.
6
+ *
7
+ * @template T - The type of elements in the array.
8
+ * @param arr - The array to deduplicate.
9
+ * @param mapper - Maps an element to the key its uniqueness is decided by.
10
+ * @returns A new array containing only the first element seen for each distinct key.
11
+ *
12
+ * @example
13
+ * uniqBy([2.1, 1.2, 2.3], Math.floor); // [2.1, 1.2]
14
+ * uniqBy([{ id: "a" }, { id: "a" }, { id: "b" }], (item) => item.id); // [{ id: "a" }, { id: "b" }]
15
+ */
16
+ declare function uniqBy<T>(arr: T[], mapper: (item: T, index: number, array: T[]) => unknown): T[];
17
+ export { uniqBy };
18
+ //# sourceMappingURL=uniq-by.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uniq-by.d.ts","sourceRoot":"","sources":["../../src/array/uniq-by.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,iBAAS,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,OAAO,GAAG,CAAC,EAAE,CAezF;AAED,OAAO,EAAE,MAAM,EAAE,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Returns a new array of the unique elements of `arr`, keyed by the value the `mapper` returns.
3
+ *
4
+ * When two elements map to the same key the first occurrence is kept and later ones discarded,
5
+ * preserving first-seen order.
6
+ *
7
+ * @template T - The type of elements in the array.
8
+ * @param arr - The array to deduplicate.
9
+ * @param mapper - Maps an element to the key its uniqueness is decided by.
10
+ * @returns A new array containing only the first element seen for each distinct key.
11
+ *
12
+ * @example
13
+ * uniqBy([2.1, 1.2, 2.3], Math.floor); // [2.1, 1.2]
14
+ * uniqBy([{ id: "a" }, { id: "a" }, { id: "b" }], (item) => item.id); // [{ id: "a" }, { id: "b" }]
15
+ */
16
+ function uniqBy(arr, mapper) {
17
+ const seen = new Map();
18
+ let index = 0;
19
+ for (const item of arr) {
20
+ const key = mapper(item, index, arr);
21
+ if (!seen.has(key)) {
22
+ seen.set(key, item);
23
+ }
24
+ index++;
25
+ }
26
+ return seen.values().toArray();
27
+ }
28
+ export { uniqBy };
29
+ //# sourceMappingURL=uniq-by.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uniq-by.js","sourceRoot":"","sources":["../../src/array/uniq-by.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,SAAS,MAAM,CAAI,GAAQ,EAAE,MAAuD;IAChF,MAAM,IAAI,GAAoB,IAAI,GAAG,EAAE,CAAC;IACxC,IAAI,KAAK,GAAG,CAAC,CAAC;IAEd,KAAK,MAAM,IAAI,IAAI,GAAG,EAAE,CAAC;QACrB,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;QAErC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACjB,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACxB,CAAC;QAED,KAAK,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,CAAC;AACnC,CAAC;AAED,OAAO,EAAE,MAAM,EAAE,CAAC","sourcesContent":["/**\n * Returns a new array of the unique elements of `arr`, keyed by the value the `mapper` returns.\n *\n * When two elements map to the same key the first occurrence is kept and later ones discarded,\n * preserving first-seen order.\n *\n * @template T - The type of elements in the array.\n * @param arr - The array to deduplicate.\n * @param mapper - Maps an element to the key its uniqueness is decided by.\n * @returns A new array containing only the first element seen for each distinct key.\n *\n * @example\n * uniqBy([2.1, 1.2, 2.3], Math.floor); // [2.1, 1.2]\n * uniqBy([{ id: \"a\" }, { id: \"a\" }, { id: \"b\" }], (item) => item.id); // [{ id: \"a\" }, { id: \"b\" }]\n */\nfunction uniqBy<T>(arr: T[], mapper: (item: T, index: number, array: T[]) => unknown): T[] {\n const seen: Map<unknown, T> = new Map();\n let index = 0;\n\n for (const item of arr) {\n const key = mapper(item, index, arr);\n\n if (!seen.has(key)) {\n seen.set(key, item);\n }\n\n index++;\n }\n\n return seen.values().toArray();\n}\n\nexport { uniqBy };\n"]}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * A constructor value of any (possibly abstract) class producing instances of `T`.
3
+ */
4
+ type AnyClass<T extends object = object> = (abstract new (...args: never[]) => T) & {
5
+ prototype: T;
6
+ };
7
+ export { type AnyClass };
8
+ //# sourceMappingURL=any-class.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"any-class.d.ts","sourceRoot":"","sources":["../../src/class/any-class.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,KAAK,QAAQ,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,MAChD,GAAG,IAAI,EAAE,KAAK,EAAE,KACf,CAAC,CAAC,GAAG;IACN,SAAS,EAAE,CAAC,CAAC;CAChB,CAAC;AAEF,OAAO,EAAE,KAAK,QAAQ,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=any-class.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"any-class.js","sourceRoot":"","sources":["../../src/class/any-class.ts"],"names":[],"mappings":"AASA,OAAO,EAAiB,CAAC","sourcesContent":["/**\n * A constructor value of any (possibly abstract) class producing instances of `T`.\n */\ntype AnyClass<T extends object = object> = (abstract new (\n ...args: never[]\n) => T) & {\n prototype: T;\n};\n\nexport { type AnyClass };\n"]}
@@ -0,0 +1,10 @@
1
+ import type { AnyClass } from "./any-class.js";
2
+ /**
3
+ * Returns the direct superclass of `cls`, or `null` when it has no class ancestor.
4
+ *
5
+ * @param cls - The class whose prototype parent to inspect.
6
+ * @returns The parent class, or `null` when there is none.
7
+ */
8
+ declare function getParentClass(cls: AnyClass): AnyClass | null;
9
+ export { getParentClass };
10
+ //# sourceMappingURL=get-parent-class.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-parent-class.d.ts","sourceRoot":"","sources":["../../src/class/get-parent-class.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C;;;;;GAKG;AACH,iBAAS,cAAc,CAAC,GAAG,EAAE,QAAQ,GAAG,QAAQ,GAAG,IAAI,CAItD;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Returns the direct superclass of `cls`, or `null` when it has no class ancestor.
3
+ *
4
+ * @param cls - The class whose prototype parent to inspect.
5
+ * @returns The parent class, or `null` when there is none.
6
+ */
7
+ function getParentClass(cls) {
8
+ const parent = Object.getPrototypeOf(cls);
9
+ return typeof parent === "function" && parent !== Function.prototype ? parent : null;
10
+ }
11
+ export { getParentClass };
12
+ //# sourceMappingURL=get-parent-class.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-parent-class.js","sourceRoot":"","sources":["../../src/class/get-parent-class.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,SAAS,cAAc,CAAC,GAAa;IACjC,MAAM,MAAM,GAAY,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IAEnD,OAAO,OAAO,MAAM,KAAK,UAAU,IAAI,MAAM,KAAK,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAE,MAAmB,CAAC,CAAC,CAAC,IAAI,CAAC;AACvG,CAAC;AAED,OAAO,EAAE,cAAc,EAAE,CAAC","sourcesContent":["import type { AnyClass } from \"./any-class.js\";\n\n/**\n * Returns the direct superclass of `cls`, or `null` when it has no class ancestor.\n *\n * @param cls - The class whose prototype parent to inspect.\n * @returns The parent class, or `null` when there is none.\n */\nfunction getParentClass(cls: AnyClass): AnyClass | null {\n const parent: unknown = Object.getPrototypeOf(cls);\n\n return typeof parent === \"function\" && parent !== Function.prototype ? (parent as AnyClass) : null;\n}\n\nexport { getParentClass };\n"]}
@@ -0,0 +1,4 @@
1
+ export type { AnyClass } from "./any-class.js";
2
+ export { getParentClass } from "./get-parent-class.js";
3
+ export { walkClassChain } from "./walk-class-chain.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/class/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { getParentClass } from "./get-parent-class.js";
2
+ export { walkClassChain } from "./walk-class-chain.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/class/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC","sourcesContent":["export type { AnyClass } from \"./any-class.js\";\nexport { getParentClass } from \"./get-parent-class.js\";\nexport { walkClassChain } from \"./walk-class-chain.js\";\n"]}
@@ -0,0 +1,13 @@
1
+ import type { AnyClass } from "./any-class.js";
2
+ /**
3
+ * Walks the class chain from `cls` up through its ancestors, calling `visit` on each and returning
4
+ * the first result that is not `undefined`.
5
+ *
6
+ * @template T - The type produced by the visitor.
7
+ * @param cls - The class to start from, or `null` to visit nothing.
8
+ * @param visit - Called with each class in the chain; a defined return value stops the walk.
9
+ * @returns The first defined result from `visit`, or `undefined` when none was produced.
10
+ */
11
+ declare function walkClassChain<T>(cls: AnyClass | null, visit: (ancestor: AnyClass) => T | undefined): T | undefined;
12
+ export { walkClassChain };
13
+ //# sourceMappingURL=walk-class-chain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"walk-class-chain.d.ts","sourceRoot":"","sources":["../../src/class/walk-class-chain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG/C;;;;;;;;GAQG;AACH,iBAAS,cAAc,CAAC,CAAC,EAAE,GAAG,EAAE,QAAQ,GAAG,IAAI,EAAE,KAAK,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,CAAC,GAAG,SAAS,GAAG,CAAC,GAAG,SAAS,CAc5G;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { getParentClass } from "./get-parent-class.js";
2
+ /**
3
+ * Walks the class chain from `cls` up through its ancestors, calling `visit` on each and returning
4
+ * the first result that is not `undefined`.
5
+ *
6
+ * @template T - The type produced by the visitor.
7
+ * @param cls - The class to start from, or `null` to visit nothing.
8
+ * @param visit - Called with each class in the chain; a defined return value stops the walk.
9
+ * @returns The first defined result from `visit`, or `undefined` when none was produced.
10
+ */
11
+ function walkClassChain(cls, visit) {
12
+ let current = cls;
13
+ while (current !== null) {
14
+ const result = visit(current);
15
+ if (result !== undefined) {
16
+ return result;
17
+ }
18
+ current = getParentClass(current);
19
+ }
20
+ return undefined;
21
+ }
22
+ export { walkClassChain };
23
+ //# sourceMappingURL=walk-class-chain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"walk-class-chain.js","sourceRoot":"","sources":["../../src/class/walk-class-chain.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD;;;;;;;;GAQG;AACH,SAAS,cAAc,CAAI,GAAoB,EAAE,KAA4C;IACzF,IAAI,OAAO,GAAG,GAAG,CAAC;IAElB,OAAO,OAAO,KAAK,IAAI,EAAE,CAAC;QACtB,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;QAE9B,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACvB,OAAO,MAAM,CAAC;QAClB,CAAC;QAED,OAAO,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,OAAO,EAAE,cAAc,EAAE,CAAC","sourcesContent":["import type { AnyClass } from \"./any-class.js\";\nimport { getParentClass } from \"./get-parent-class.js\";\n\n/**\n * Walks the class chain from `cls` up through its ancestors, calling `visit` on each and returning\n * the first result that is not `undefined`.\n *\n * @template T - The type produced by the visitor.\n * @param cls - The class to start from, or `null` to visit nothing.\n * @param visit - Called with each class in the chain; a defined return value stops the walk.\n * @returns The first defined result from `visit`, or `undefined` when none was produced.\n */\nfunction walkClassChain<T>(cls: AnyClass | null, visit: (ancestor: AnyClass) => T | undefined): T | undefined {\n let current = cls;\n\n while (current !== null) {\n const result = visit(current);\n\n if (result !== undefined) {\n return result;\n }\n\n current = getParentClass(current);\n }\n\n return undefined;\n}\n\nexport { walkClassChain };\n"]}
@@ -0,0 +1,6 @@
1
+ declare function isErrorLike(value: unknown): value is {
2
+ message: string;
3
+ };
4
+ declare function readStream(value: unknown): string;
5
+ export { isErrorLike, readStream };
6
+ //# sourceMappingURL=error-like.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-like.d.ts","sourceRoot":"","sources":["../../src/error/error-like.ts"],"names":[],"mappings":"AAEA,iBAAS,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAEjE;AAED,iBAAS,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAU1C;AAED,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,15 @@
1
+ import { isRecord } from "../predicate/is-record.js";
2
+ function isErrorLike(value) {
3
+ return isRecord(value) && "message" in value && typeof value.message === "string";
4
+ }
5
+ function readStream(value) {
6
+ if (typeof value === "string") {
7
+ return value;
8
+ }
9
+ if (value instanceof Uint8Array || Buffer.isBuffer(value)) {
10
+ return value.toString();
11
+ }
12
+ return "";
13
+ }
14
+ export { isErrorLike, readStream };
15
+ //# sourceMappingURL=error-like.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-like.js","sourceRoot":"","sources":["../../src/error/error-like.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD,SAAS,WAAW,CAAC,KAAc;IAC/B,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,SAAS,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,CAAC;AACtF,CAAC;AAED,SAAS,UAAU,CAAC,KAAc;IAC9B,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,IAAI,KAAK,YAAY,UAAU,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACxD,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC5B,CAAC;IAED,OAAO,EAAE,CAAC;AACd,CAAC;AAED,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC","sourcesContent":["import { isRecord } from \"../predicate/is-record.js\";\n\nfunction isErrorLike(value: unknown): value is { message: string } {\n return isRecord(value) && \"message\" in value && typeof value.message === \"string\";\n}\n\nfunction readStream(value: unknown): string {\n if (typeof value === \"string\") {\n return value;\n }\n\n if (value instanceof Uint8Array || Buffer.isBuffer(value)) {\n return value.toString();\n }\n\n return \"\";\n}\n\nexport { isErrorLike, readStream };\n"]}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Extracts a human-readable message from an unknown thrown value, falling back to its string form.
3
+ *
4
+ * @param error - The caught value to describe.
5
+ * @returns The value's message when it has one, otherwise its string form.
6
+ *
7
+ * @example
8
+ * errorMessage(new Error("boom")); // "boom"
9
+ * errorMessage(42); // "42"
10
+ */
11
+ declare function errorMessage(error: unknown): string;
12
+ export { errorMessage };
13
+ //# sourceMappingURL=error-message.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-message.d.ts","sourceRoot":"","sources":["../../src/error/error-message.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,iBAAS,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAE5C;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { isErrorLike } from "./error-like.js";
2
+ /**
3
+ * Extracts a human-readable message from an unknown thrown value, falling back to its string form.
4
+ *
5
+ * @param error - The caught value to describe.
6
+ * @returns The value's message when it has one, otherwise its string form.
7
+ *
8
+ * @example
9
+ * errorMessage(new Error("boom")); // "boom"
10
+ * errorMessage(42); // "42"
11
+ */
12
+ function errorMessage(error) {
13
+ return Error.isError(error) || isErrorLike(error) ? error.message : String(error);
14
+ }
15
+ export { errorMessage };
16
+ //# sourceMappingURL=error-message.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-message.js","sourceRoot":"","sources":["../../src/error/error-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C;;;;;;;;;GASG;AACH,SAAS,YAAY,CAAC,KAAc;IAChC,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACtF,CAAC;AAED,OAAO,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import { isErrorLike } from \"./error-like.js\";\n\n/**\n * Extracts a human-readable message from an unknown thrown value, falling back to its string form.\n *\n * @param error - The caught value to describe.\n * @returns The value's message when it has one, otherwise its string form.\n *\n * @example\n * errorMessage(new Error(\"boom\")); // \"boom\"\n * errorMessage(42); // \"42\"\n */\nfunction errorMessage(error: unknown): string {\n return Error.isError(error) || isErrorLike(error) ? error.message : String(error);\n}\n\nexport { errorMessage };\n"]}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Combines the `stderr` and `stdout` of a failed child-process error into a single trimmed string.
3
+ *
4
+ * @param error - The child-process error to read output from.
5
+ * @returns The joined output, or `undefined` when neither stream carried any text.
6
+ *
7
+ * @example
8
+ * formatChildProcessError({ stderr: "boom" }); // "boom"
9
+ */
10
+ declare function formatChildProcessError(error: unknown): string | undefined;
11
+ export { formatChildProcessError };
12
+ //# sourceMappingURL=format-child-process-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-child-process-error.d.ts","sourceRoot":"","sources":["../../src/error/format-child-process-error.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AACH,iBAAS,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CASnE;AAED,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { isRecord } from "../predicate/is-record.js";
2
+ import { readStream } from "./error-like.js";
3
+ /**
4
+ * Combines the `stderr` and `stdout` of a failed child-process error into a single trimmed string.
5
+ *
6
+ * @param error - The child-process error to read output from.
7
+ * @returns The joined output, or `undefined` when neither stream carried any text.
8
+ *
9
+ * @example
10
+ * formatChildProcessError({ stderr: "boom" }); // "boom"
11
+ */
12
+ function formatChildProcessError(error) {
13
+ if (!isRecord(error)) {
14
+ return undefined;
15
+ }
16
+ const { stderr, stdout } = error;
17
+ const details = [readStream(stderr), readStream(stdout)].filter(Boolean).join("\n").trim();
18
+ return details.length > 0 ? details : undefined;
19
+ }
20
+ export { formatChildProcessError };
21
+ //# sourceMappingURL=format-child-process-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-child-process-error.js","sourceRoot":"","sources":["../../src/error/format-child-process-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;;;;;;;GAQG;AACH,SAAS,uBAAuB,CAAC,KAAc;IAC3C,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACnB,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC;IACjC,MAAM,OAAO,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;IAE3F,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;AACpD,CAAC;AAED,OAAO,EAAE,uBAAuB,EAAE,CAAC","sourcesContent":["import { isRecord } from \"../predicate/is-record.js\";\nimport { readStream } from \"./error-like.js\";\n\n/**\n * Combines the `stderr` and `stdout` of a failed child-process error into a single trimmed string.\n *\n * @param error - The child-process error to read output from.\n * @returns The joined output, or `undefined` when neither stream carried any text.\n *\n * @example\n * formatChildProcessError({ stderr: \"boom\" }); // \"boom\"\n */\nfunction formatChildProcessError(error: unknown): string | undefined {\n if (!isRecord(error)) {\n return undefined;\n }\n\n const { stderr, stdout } = error;\n const details = [readStream(stderr), readStream(stdout)].filter(Boolean).join(\"\\n\").trim();\n\n return details.length > 0 ? details : undefined;\n}\n\nexport { formatChildProcessError };\n"]}
@@ -0,0 +1,4 @@
1
+ export { errorMessage } from "./error-message.js";
2
+ export { formatChildProcessError } from "./format-child-process-error.js";
3
+ export { normalizeError } from "./normalize-error.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/error/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { errorMessage } from "./error-message.js";
2
+ export { formatChildProcessError } from "./format-child-process-error.js";
3
+ export { normalizeError } from "./normalize-error.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/error/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC","sourcesContent":["export { errorMessage } from \"./error-message.js\";\nexport { formatChildProcessError } from \"./format-child-process-error.js\";\nexport { normalizeError } from \"./normalize-error.js\";\n"]}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Coerces an unknown thrown value into an `Error`, reusing it when it already is one and otherwise
3
+ * wrapping its message while copying any error-like own properties.
4
+ *
5
+ * @param error - The caught value to normalize.
6
+ * @returns The value itself when it is an `Error`, otherwise a new `Error` carrying its message.
7
+ *
8
+ * @example
9
+ * normalizeError("boom"); // Error: boom
10
+ */
11
+ declare function normalizeError(error: unknown): Error;
12
+ export { normalizeError };
13
+ //# sourceMappingURL=normalize-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-error.d.ts","sourceRoot":"","sources":["../../src/error/normalize-error.ts"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,iBAAS,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CAM7C;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { isErrorLike } from "./error-like.js";
2
+ import { errorMessage } from "./error-message.js";
3
+ /**
4
+ * Coerces an unknown thrown value into an `Error`, reusing it when it already is one and otherwise
5
+ * wrapping its message while copying any error-like own properties.
6
+ *
7
+ * @param error - The caught value to normalize.
8
+ * @returns The value itself when it is an `Error`, otherwise a new `Error` carrying its message.
9
+ *
10
+ * @example
11
+ * normalizeError("boom"); // Error: boom
12
+ */
13
+ function normalizeError(error) {
14
+ if (Error.isError(error)) {
15
+ return error;
16
+ }
17
+ return Object.assign(new Error(errorMessage(error)), isErrorLike(error) ? error : {});
18
+ }
19
+ export { normalizeError };
20
+ //# sourceMappingURL=normalize-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-error.js","sourceRoot":"","sources":["../../src/error/normalize-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;;;;;;;;GASG;AACH,SAAS,cAAc,CAAC,KAAc;IAClC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAC1F,CAAC;AAED,OAAO,EAAE,cAAc,EAAE,CAAC","sourcesContent":["import { isErrorLike } from \"./error-like.js\";\nimport { errorMessage } from \"./error-message.js\";\n\n/**\n * Coerces an unknown thrown value into an `Error`, reusing it when it already is one and otherwise\n * wrapping its message while copying any error-like own properties.\n *\n * @param error - The caught value to normalize.\n * @returns The value itself when it is an `Error`, otherwise a new `Error` carrying its message.\n *\n * @example\n * normalizeError(\"boom\"); // Error: boom\n */\nfunction normalizeError(error: unknown): Error {\n if (Error.isError(error)) {\n return error;\n }\n\n return Object.assign(new Error(errorMessage(error)), isErrorLike(error) ? error : {});\n}\n\nexport { normalizeError };\n"]}
@@ -0,0 +1,3 @@
1
+ declare function callMethod(target: object, method: string, args: unknown[]): unknown;
2
+ export { callMethod };
3
+ //# sourceMappingURL=call-method.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"call-method.d.ts","sourceRoot":"","sources":["../../src/function/call-method.ts"],"names":[],"mappings":"AAeA,iBAAS,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAI5E;AAED,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Calls the named method on `target` with the given arguments, returning `undefined` when the
3
+ * property is missing or not callable.
4
+ *
5
+ * @param target - The object to read the method from and bind as `this`.
6
+ * @param method - The name of the method to look up.
7
+ * @param args - The arguments passed to the method.
8
+ * @returns The method's return value, or `undefined` when it is not a function.
9
+ *
10
+ * @example
11
+ * callMethod(console, "log", ["hi"]); // logs "hi"; returns undefined
12
+ */
13
+ const isCallable = (value) => typeof value === "function";
14
+ function callMethod(target, method, args) {
15
+ const fn = Reflect.get(target, method);
16
+ return isCallable(fn) ? Reflect.apply(fn, target, args) : undefined;
17
+ }
18
+ export { callMethod };
19
+ //# sourceMappingURL=call-method.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"call-method.js","sourceRoot":"","sources":["../../src/function/call-method.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,GAAG,CAAC,KAAc,EAA0D,EAAE,CAC1F,OAAO,KAAK,KAAK,UAAU,CAAC;AAEhC,SAAS,UAAU,CAAC,MAAc,EAAE,MAAc,EAAE,IAAe;IAC/D,MAAM,EAAE,GAAY,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEhD,OAAO,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACxE,CAAC;AAED,OAAO,EAAE,UAAU,EAAE,CAAC","sourcesContent":["/**\n * Calls the named method on `target` with the given arguments, returning `undefined` when the\n * property is missing or not callable.\n *\n * @param target - The object to read the method from and bind as `this`.\n * @param method - The name of the method to look up.\n * @param args - The arguments passed to the method.\n * @returns The method's return value, or `undefined` when it is not a function.\n *\n * @example\n * callMethod(console, \"log\", [\"hi\"]); // logs \"hi\"; returns undefined\n */\nconst isCallable = (value: unknown): value is (this: object, ...args: unknown[]) => unknown =>\n typeof value === \"function\";\n\nfunction callMethod(target: object, method: string, args: unknown[]): unknown {\n const fn: unknown = Reflect.get(target, method);\n\n return isCallable(fn) ? Reflect.apply(fn, target, args) : undefined;\n}\n\nexport { callMethod };\n"]}