@augment-vir/common 29.3.0 → 30.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (296) hide show
  1. package/LICENSE-CC0 +121 -0
  2. package/LICENSE-MIT +21 -0
  3. package/README.md +7 -3
  4. package/dist/augments/array/array-map.d.ts +34 -0
  5. package/dist/augments/array/array-map.js +32 -0
  6. package/dist/augments/array/array-to-object.d.ts +53 -0
  7. package/dist/augments/array/array-to-object.js +67 -0
  8. package/dist/augments/array/awaited/awaited-filter.d.ts +36 -0
  9. package/dist/augments/array/awaited/awaited-filter.js +36 -0
  10. package/dist/augments/array/awaited/awaited-for-each.d.ts +31 -0
  11. package/dist/augments/array/awaited/awaited-for-each.js +34 -0
  12. package/dist/augments/array/awaited/awaited-map.d.ts +33 -0
  13. package/dist/augments/array/awaited/awaited-map.js +40 -0
  14. package/dist/augments/array/filter.d.ts +32 -0
  15. package/dist/augments/array/filter.js +74 -0
  16. package/dist/augments/array/remove-duplicates.d.ts +60 -0
  17. package/dist/augments/array/remove-duplicates.js +72 -0
  18. package/dist/augments/array/repeat-array.d.ts +23 -0
  19. package/dist/augments/array/repeat-array.js +25 -0
  20. package/dist/augments/array/shuffle-array.d.ts +9 -0
  21. package/dist/augments/array/shuffle-array.js +17 -0
  22. package/dist/augments/array/string-array.d.ts +9 -0
  23. package/dist/augments/array/string-array.js +11 -0
  24. package/dist/augments/core-exports.d.ts +1 -0
  25. package/dist/augments/core-exports.js +1 -0
  26. package/dist/augments/enum/enum-value-check.d.ts +32 -0
  27. package/dist/augments/enum/enum-value-check.js +34 -0
  28. package/dist/augments/error/combine-errors.d.ts +24 -0
  29. package/dist/augments/error/combine-errors.js +34 -0
  30. package/dist/augments/function/call-asynchronously.d.ts +25 -0
  31. package/dist/augments/function/call-asynchronously.js +26 -0
  32. package/dist/augments/function/call-with-retries.d.ts +24 -0
  33. package/dist/augments/function/call-with-retries.js +50 -0
  34. package/dist/augments/function/debounce.d.ts +89 -0
  35. package/dist/augments/function/debounce.js +112 -0
  36. package/dist/augments/function/execution-duration.d.ts +20 -0
  37. package/dist/augments/function/execution-duration.js +39 -0
  38. package/dist/augments/function/if-truthy.d.ts +28 -0
  39. package/dist/augments/function/if-truthy.js +35 -0
  40. package/dist/{types/augments → augments/function}/wrap-in-try.d.ts +14 -7
  41. package/dist/augments/function/wrap-in-try.js +98 -0
  42. package/dist/augments/json/append-json.d.ts +5 -0
  43. package/dist/augments/json/append-json.js +59 -0
  44. package/dist/augments/json/copy-through-json.d.ts +34 -0
  45. package/dist/augments/json/copy-through-json.js +42 -0
  46. package/dist/augments/json/json-compatible.d.ts +50 -0
  47. package/dist/augments/json/jsonify.d.ts +31 -0
  48. package/dist/augments/json/jsonify.js +33 -0
  49. package/dist/augments/log/log-colors.d.ts +64 -0
  50. package/dist/augments/log/log-colors.js +157 -0
  51. package/dist/augments/log/log-string.d.ts +35 -0
  52. package/dist/augments/log/log-string.js +73 -0
  53. package/dist/augments/log/log-writer.d.ts +30 -0
  54. package/dist/augments/log/log.d.ts +56 -0
  55. package/dist/augments/log/log.js +85 -0
  56. package/dist/augments/log/logger.d.ts +60 -0
  57. package/dist/augments/log/logger.js +59 -0
  58. package/dist/augments/number/clamp.d.ts +18 -0
  59. package/dist/augments/number/clamp.js +19 -0
  60. package/dist/augments/number/coords.d.ts +23 -0
  61. package/dist/augments/number/digit.d.ts +8 -0
  62. package/dist/augments/number/dimensions.d.ts +23 -0
  63. package/dist/augments/number/min-max.d.ts +18 -0
  64. package/dist/augments/number/min-max.js +16 -0
  65. package/dist/augments/number/number-conversion.d.ts +29 -0
  66. package/dist/augments/number/number-conversion.js +56 -0
  67. package/dist/augments/number/round.d.ts +22 -0
  68. package/dist/augments/number/round.js +24 -0
  69. package/dist/augments/number/scientific.d.ts +18 -0
  70. package/dist/augments/number/scientific.js +20 -0
  71. package/dist/augments/number/truncate-number.d.ts +40 -0
  72. package/dist/{esm/augments → augments/number}/truncate-number.js +39 -17
  73. package/dist/augments/number/wrap-number.d.ts +19 -0
  74. package/dist/augments/number/wrap-number.js +28 -0
  75. package/dist/augments/object/diff.d.ts +51 -0
  76. package/dist/augments/object/diff.js +149 -0
  77. package/dist/augments/object/empty.d.ts +9 -0
  78. package/dist/augments/object/get-or-set.d.ts +10 -0
  79. package/dist/augments/object/get-or-set.js +100 -0
  80. package/dist/augments/object/key-count.d.ts +21 -0
  81. package/dist/augments/object/map-entries.d.ts +13 -0
  82. package/dist/augments/object/map-entries.js +80 -0
  83. package/dist/augments/object/map-enum.d.ts +11 -0
  84. package/dist/augments/object/map-enum.js +45 -0
  85. package/dist/augments/object/map-values.d.ts +35 -0
  86. package/dist/augments/object/map-values.js +65 -0
  87. package/dist/{types/augments → augments}/object/merge-deep.d.ts +4 -0
  88. package/dist/{esm/augments → augments}/object/merge-deep.js +9 -6
  89. package/dist/augments/object/merge-defined-properties.d.ts +19 -0
  90. package/dist/augments/object/merge-defined-properties.js +32 -0
  91. package/dist/augments/object/merge-property-arrays.d.ts +29 -0
  92. package/dist/augments/object/merge-property-arrays.js +39 -0
  93. package/dist/augments/object/object-entries.d.ts +31 -0
  94. package/dist/augments/object/object-entries.js +40 -0
  95. package/dist/augments/object/object-filter.d.ts +22 -0
  96. package/dist/augments/object/object-filter.js +27 -0
  97. package/dist/augments/object/object-keys.d.ts +34 -0
  98. package/dist/augments/object/object-keys.js +43 -0
  99. package/dist/augments/object/object-values.d.ts +11 -0
  100. package/dist/augments/object/object-values.js +13 -0
  101. package/dist/augments/path/esm-path.d.ts +26 -0
  102. package/dist/augments/path/esm-path.js +31 -0
  103. package/dist/augments/prisma/prisma-models.d.ts +143 -0
  104. package/dist/augments/prisma/prisma-models.js +1 -0
  105. package/dist/augments/promise/timed-promise.d.ts +22 -0
  106. package/dist/augments/promise/timed-promise.js +51 -0
  107. package/dist/augments/random/random-boolean.d.ts +24 -0
  108. package/dist/augments/random/random-boolean.js +32 -0
  109. package/dist/augments/random/random-integer.d.ts +14 -0
  110. package/dist/augments/random/random-integer.js +34 -0
  111. package/dist/augments/random/random-string.d.ts +18 -0
  112. package/dist/augments/random/random-string.js +67 -0
  113. package/dist/augments/regexp/match.d.ts +10 -0
  114. package/dist/augments/regexp/match.js +13 -0
  115. package/dist/augments/regexp/regexp-flags.d.ts +56 -0
  116. package/dist/augments/regexp/regexp-flags.js +75 -0
  117. package/dist/augments/regexp/regexp-string.d.ts +9 -0
  118. package/dist/augments/regexp/regexp-string.js +11 -0
  119. package/dist/augments/selection-set/select-collapsed.d.ts +54 -0
  120. package/dist/augments/selection-set/select-collapsed.js +63 -0
  121. package/dist/augments/selection-set/select-from.d.ts +48 -0
  122. package/dist/augments/selection-set/select-from.js +72 -0
  123. package/dist/augments/selection-set/selection-set.d.ts +37 -0
  124. package/dist/augments/selection-set/selection-set.js +1 -0
  125. package/dist/augments/string/casing/capitalization.d.ts +17 -0
  126. package/dist/augments/string/casing/capitalization.js +25 -0
  127. package/dist/augments/string/casing/casing.d.ts +73 -0
  128. package/dist/augments/string/casing/casing.js +65 -0
  129. package/dist/augments/string/casing/kebab-and-camel.d.ts +17 -0
  130. package/dist/augments/string/casing/kebab-and-camel.js +57 -0
  131. package/dist/augments/string/comma.d.ts +26 -0
  132. package/dist/augments/string/comma.js +48 -0
  133. package/dist/augments/string/join.d.ts +21 -0
  134. package/dist/augments/string/join.js +34 -0
  135. package/dist/augments/string/prefix.d.ts +30 -0
  136. package/dist/augments/string/prefix.js +30 -0
  137. package/dist/augments/string/remove-duplicate-characters.d.ts +17 -0
  138. package/dist/augments/string/remove-duplicate-characters.js +22 -0
  139. package/dist/augments/string/replace.d.ts +18 -0
  140. package/dist/augments/string/replace.js +22 -0
  141. package/dist/augments/string/split.d.ts +31 -0
  142. package/dist/augments/string/split.js +53 -0
  143. package/dist/augments/string/substring-index.d.ts +19 -0
  144. package/dist/augments/string/substring-index.js +47 -0
  145. package/dist/augments/string/suffix.d.ts +96 -0
  146. package/dist/augments/string/suffix.js +89 -0
  147. package/dist/augments/string/white-space.d.ts +12 -0
  148. package/dist/augments/string/white-space.js +19 -0
  149. package/dist/augments/string/wrap-string.d.ts +19 -0
  150. package/dist/augments/string/wrap-string.js +20 -0
  151. package/dist/augments/type/ensure-type.d.ts +12 -0
  152. package/dist/augments/type/ensure-type.js +14 -0
  153. package/dist/augments/type/readonly.d.ts +9 -0
  154. package/dist/augments/type/readonly.js +10 -0
  155. package/dist/augments/type/type-recursion.d.ts +253 -0
  156. package/dist/augments/type/type-recursion.js +1 -0
  157. package/dist/augments/type/union.d.ts +1 -0
  158. package/dist/augments/type/union.js +1 -0
  159. package/dist/augments/type/void-type.d.ts +9 -0
  160. package/dist/augments/type/void-type.js +1 -0
  161. package/dist/augments/type/writable.d.ts +10 -0
  162. package/dist/augments/type/writable.js +10 -0
  163. package/dist/index.d.ts +83 -0
  164. package/dist/index.js +83 -0
  165. package/package.json +43 -15
  166. package/dist/cjs/augments/ansi.js +0 -27
  167. package/dist/cjs/augments/array/array.js +0 -68
  168. package/dist/cjs/augments/array/remove-duplicates.js +0 -16
  169. package/dist/cjs/augments/async.js +0 -28
  170. package/dist/cjs/augments/boolean.js +0 -19
  171. package/dist/cjs/augments/common-number.js +0 -112
  172. package/dist/cjs/augments/common-string.js +0 -245
  173. package/dist/cjs/augments/debounce.js +0 -38
  174. package/dist/cjs/augments/environment.js +0 -6
  175. package/dist/cjs/augments/error.js +0 -52
  176. package/dist/cjs/augments/esm-path.js +0 -11
  177. package/dist/cjs/augments/function.js +0 -2
  178. package/dist/cjs/augments/json-compatible.js +0 -2
  179. package/dist/cjs/augments/json.js +0 -28
  180. package/dist/cjs/augments/object/any-object.js +0 -2
  181. package/dist/cjs/augments/object/enum.js +0 -48
  182. package/dist/cjs/augments/object/filter-object.js +0 -26
  183. package/dist/cjs/augments/object/get-or-set.js +0 -40
  184. package/dist/cjs/augments/object/has-key.js +0 -6
  185. package/dist/cjs/augments/object/jsonify.js +0 -6
  186. package/dist/cjs/augments/object/key-count.js +0 -2
  187. package/dist/cjs/augments/object/map-object.js +0 -61
  188. package/dist/cjs/augments/object/merge-deep.js +0 -52
  189. package/dist/cjs/augments/object/merge-property-arrays.js +0 -14
  190. package/dist/cjs/augments/object/object-entries.js +0 -40
  191. package/dist/cjs/augments/object/object.js +0 -18
  192. package/dist/cjs/augments/object/pick-deep.js +0 -2
  193. package/dist/cjs/augments/object/selection-set.js +0 -56
  194. package/dist/cjs/augments/object/typed-has-property.js +0 -29
  195. package/dist/cjs/augments/promise/deferred-promise.js +0 -31
  196. package/dist/cjs/augments/promise/promise.js +0 -79
  197. package/dist/cjs/augments/promise/wait.js +0 -66
  198. package/dist/cjs/augments/random.js +0 -118
  199. package/dist/cjs/augments/regexp.js +0 -19
  200. package/dist/cjs/augments/string/prefixes.js +0 -20
  201. package/dist/cjs/augments/string/suffixes.js +0 -40
  202. package/dist/cjs/augments/string/uuid.js +0 -13
  203. package/dist/cjs/augments/time.js +0 -35
  204. package/dist/cjs/augments/truncate-number.js +0 -153
  205. package/dist/cjs/augments/tuple.js +0 -20
  206. package/dist/cjs/augments/type-recursion.js +0 -2
  207. package/dist/cjs/augments/type.js +0 -36
  208. package/dist/cjs/augments/union.js +0 -2
  209. package/dist/cjs/augments/wrap-in-try.js +0 -37
  210. package/dist/cjs/index.js +0 -60
  211. package/dist/esm/augments/ansi.js +0 -24
  212. package/dist/esm/augments/array/array.js +0 -57
  213. package/dist/esm/augments/array/remove-duplicates.js +0 -13
  214. package/dist/esm/augments/async.js +0 -23
  215. package/dist/esm/augments/boolean.js +0 -14
  216. package/dist/esm/augments/common-number.js +0 -100
  217. package/dist/esm/augments/common-string.js +0 -227
  218. package/dist/esm/augments/debounce.js +0 -34
  219. package/dist/esm/augments/environment.js +0 -3
  220. package/dist/esm/augments/error.js +0 -45
  221. package/dist/esm/augments/esm-path.js +0 -8
  222. package/dist/esm/augments/json.js +0 -24
  223. package/dist/esm/augments/object/enum.js +0 -41
  224. package/dist/esm/augments/object/filter-object.js +0 -21
  225. package/dist/esm/augments/object/get-or-set.js +0 -36
  226. package/dist/esm/augments/object/has-key.js +0 -3
  227. package/dist/esm/augments/object/jsonify.js +0 -3
  228. package/dist/esm/augments/object/map-object.js +0 -57
  229. package/dist/esm/augments/object/merge-property-arrays.js +0 -11
  230. package/dist/esm/augments/object/object-entries.js +0 -32
  231. package/dist/esm/augments/object/object.js +0 -14
  232. package/dist/esm/augments/object/selection-set.js +0 -52
  233. package/dist/esm/augments/object/typed-has-property.js +0 -25
  234. package/dist/esm/augments/promise/deferred-promise.js +0 -28
  235. package/dist/esm/augments/promise/promise.js +0 -71
  236. package/dist/esm/augments/promise/wait.js +0 -60
  237. package/dist/esm/augments/random.js +0 -113
  238. package/dist/esm/augments/regexp.js +0 -14
  239. package/dist/esm/augments/string/prefixes.js +0 -16
  240. package/dist/esm/augments/string/suffixes.js +0 -31
  241. package/dist/esm/augments/string/uuid.js +0 -9
  242. package/dist/esm/augments/time.js +0 -31
  243. package/dist/esm/augments/tuple.js +0 -16
  244. package/dist/esm/augments/type.js +0 -30
  245. package/dist/esm/augments/wrap-in-try.js +0 -34
  246. package/dist/esm/index.js +0 -44
  247. package/dist/types/augments/ansi.d.ts +0 -1
  248. package/dist/types/augments/array/array.d.ts +0 -26
  249. package/dist/types/augments/array/remove-duplicates.d.ts +0 -1
  250. package/dist/types/augments/async.d.ts +0 -14
  251. package/dist/types/augments/boolean.d.ts +0 -6
  252. package/dist/types/augments/common-number.d.ts +0 -52
  253. package/dist/types/augments/common-string.d.ts +0 -74
  254. package/dist/types/augments/debounce.d.ts +0 -15
  255. package/dist/types/augments/environment.d.ts +0 -1
  256. package/dist/types/augments/error.d.ts +0 -9
  257. package/dist/types/augments/esm-path.d.ts +0 -4
  258. package/dist/types/augments/function.d.ts +0 -25
  259. package/dist/types/augments/json-compatible.d.ts +0 -22
  260. package/dist/types/augments/json.d.ts +0 -9
  261. package/dist/types/augments/object/any-object.d.ts +0 -2
  262. package/dist/types/augments/object/enum.d.ts +0 -8
  263. package/dist/types/augments/object/filter-object.d.ts +0 -4
  264. package/dist/types/augments/object/get-or-set.d.ts +0 -26
  265. package/dist/types/augments/object/has-key.d.ts +0 -1
  266. package/dist/types/augments/object/jsonify.d.ts +0 -2
  267. package/dist/types/augments/object/key-count.d.ts +0 -13
  268. package/dist/types/augments/object/map-object.d.ts +0 -20
  269. package/dist/types/augments/object/merge-property-arrays.d.ts +0 -1
  270. package/dist/types/augments/object/object-entries.d.ts +0 -8
  271. package/dist/types/augments/object/object.d.ts +0 -21
  272. package/dist/types/augments/object/pick-deep.d.ts +0 -14
  273. package/dist/types/augments/object/selection-set.d.ts +0 -27
  274. package/dist/types/augments/object/typed-has-property.d.ts +0 -7
  275. package/dist/types/augments/promise/deferred-promise.d.ts +0 -8
  276. package/dist/types/augments/promise/promise.d.ts +0 -15
  277. package/dist/types/augments/promise/wait.d.ts +0 -18
  278. package/dist/types/augments/random.d.ts +0 -37
  279. package/dist/types/augments/regexp.d.ts +0 -3
  280. package/dist/types/augments/string/prefixes.d.ts +0 -9
  281. package/dist/types/augments/string/suffixes.d.ts +0 -17
  282. package/dist/types/augments/string/uuid.d.ts +0 -5
  283. package/dist/types/augments/time.d.ts +0 -14
  284. package/dist/types/augments/truncate-number.d.ts +0 -19
  285. package/dist/types/augments/tuple.d.ts +0 -17
  286. package/dist/types/augments/type-recursion.d.ts +0 -161
  287. package/dist/types/augments/type.d.ts +0 -69
  288. package/dist/types/augments/union.d.ts +0 -5
  289. package/dist/types/index.d.ts +0 -44
  290. /package/dist/{esm/augments → augments/json}/json-compatible.js +0 -0
  291. /package/dist/{esm/augments/function.js → augments/log/log-writer.js} +0 -0
  292. /package/dist/{esm/augments/object/any-object.js → augments/number/coords.js} +0 -0
  293. /package/dist/{esm/augments/object/key-count.js → augments/number/digit.js} +0 -0
  294. /package/dist/{esm/augments/object/pick-deep.js → augments/number/dimensions.js} +0 -0
  295. /package/dist/{esm/augments/type-recursion.js → augments/object/empty.js} +0 -0
  296. /package/dist/{esm/augments/union.js → augments/object/key-count.js} +0 -0
package/LICENSE-CC0 ADDED
@@ -0,0 +1,121 @@
1
+ CC0 1.0 Universal
2
+
3
+ Creative Commons Legal Code
4
+
5
+ CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
6
+ LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
7
+ ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
8
+ INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
9
+ REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
10
+ PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
11
+ THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
12
+ HEREUNDER.
13
+
14
+ Statement of Purpose
15
+
16
+ The laws of most jurisdictions throughout the world automatically confer
17
+ exclusive Copyright and Related Rights (defined below) upon the creator
18
+ and subsequent owner(s) (each and all, an "owner") of an original work of
19
+ authorship and/or a database (each, a "Work").
20
+
21
+ Certain owners wish to permanently relinquish those rights to a Work for
22
+ the purpose of contributing to a commons of creative, cultural and
23
+ scientific works ("Commons") that the public can reliably and without fear
24
+ of later claims of infringement build upon, modify, incorporate in other
25
+ works, reuse and redistribute as freely as possible in any form whatsoever
26
+ and for any purposes, including without limitation commercial purposes.
27
+ These owners may contribute to the Commons to promote the ideal of a free
28
+ culture and the further production of creative, cultural and scientific
29
+ works, or to gain reputation or greater distribution for their Work in
30
+ part through the use and efforts of others.
31
+
32
+ For these and/or other purposes and motivations, and without any
33
+ expectation of additional consideration or compensation, the person
34
+ associating CC0 with a Work (the "Affirmer"), to the extent that he or she
35
+ is an owner of Copyright and Related Rights in the Work, voluntarily
36
+ elects to apply CC0 to the Work and publicly distribute the Work under its
37
+ terms, with knowledge of his or her Copyright and Related Rights in the
38
+ Work and the meaning and intended legal effect of CC0 on those rights.
39
+
40
+ 1. Copyright and Related Rights. A Work made available under CC0 may be
41
+ protected by copyright and related or neighboring rights ("Copyright and
42
+ Related Rights"). Copyright and Related Rights include, but are not
43
+ limited to, the following:
44
+
45
+ i. the right to reproduce, adapt, distribute, perform, display,
46
+ communicate, and translate a Work;
47
+ ii. moral rights retained by the original author(s) and/or performer(s);
48
+ iii. publicity and privacy rights pertaining to a person's image or
49
+ likeness depicted in a Work;
50
+ iv. rights protecting against unfair competition in regards to a Work,
51
+ subject to the limitations in paragraph 4(a), below;
52
+ v. rights protecting the extraction, dissemination, use and reuse of data
53
+ in a Work;
54
+ vi. database rights (such as those arising under Directive 96/9/EC of the
55
+ European Parliament and of the Council of 11 March 1996 on the legal
56
+ protection of databases, and under any national implementation
57
+ thereof, including any amended or successor version of such
58
+ directive); and
59
+ vii. other similar, equivalent or corresponding rights throughout the
60
+ world based on applicable law or treaty, and any national
61
+ implementations thereof.
62
+
63
+ 2. Waiver. To the greatest extent permitted by, but not in contravention
64
+ of, applicable law, Affirmer hereby overtly, fully, permanently,
65
+ irrevocably and unconditionally waives, abandons, and surrenders all of
66
+ Affirmer's Copyright and Related Rights and associated claims and causes
67
+ of action, whether now known or unknown (including existing as well as
68
+ future claims and causes of action), in the Work (i) in all territories
69
+ worldwide, (ii) for the maximum duration provided by applicable law or
70
+ treaty (including future time extensions), (iii) in any current or future
71
+ medium and for any number of copies, and (iv) for any purpose whatsoever,
72
+ including without limitation commercial, advertising or promotional
73
+ purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
74
+ member of the public at large and to the detriment of Affirmer's heirs and
75
+ successors, fully intending that such Waiver shall not be subject to
76
+ revocation, rescission, cancellation, termination, or any other legal or
77
+ equitable action to disrupt the quiet enjoyment of the Work by the public
78
+ as contemplated by Affirmer's express Statement of Purpose.
79
+
80
+ 3. Public License Fallback. Should any part of the Waiver for any reason
81
+ be judged legally invalid or ineffective under applicable law, then the
82
+ Waiver shall be preserved to the maximum extent permitted taking into
83
+ account Affirmer's express Statement of Purpose. In addition, to the
84
+ extent the Waiver is so judged Affirmer hereby grants to each affected
85
+ person a royalty-free, non transferable, non sublicensable, non exclusive,
86
+ irrevocable and unconditional license to exercise Affirmer's Copyright and
87
+ Related Rights in the Work (i) in all territories worldwide, (ii) for the
88
+ maximum duration provided by applicable law or treaty (including future
89
+ time extensions), (iii) in any current or future medium and for any number
90
+ of copies, and (iv) for any purpose whatsoever, including without
91
+ limitation commercial, advertising or promotional purposes (the
92
+ "License"). The License shall be deemed effective as of the date CC0 was
93
+ applied by Affirmer to the Work. Should any part of the License for any
94
+ reason be judged legally invalid or ineffective under applicable law, such
95
+ partial invalidity or ineffectiveness shall not invalidate the remainder
96
+ of the License, and in such case Affirmer hereby affirms that he or she
97
+ will not (i) exercise any of his or her remaining Copyright and Related
98
+ Rights in the Work or (ii) assert any associated claims and causes of
99
+ action with respect to the Work, in either case contrary to Affirmer's
100
+ express Statement of Purpose.
101
+
102
+ 4. Limitations and Disclaimers.
103
+
104
+ a. No trademark or patent rights held by Affirmer are waived, abandoned,
105
+ surrendered, licensed or otherwise affected by this document.
106
+ b. Affirmer offers the Work as-is and makes no representations or
107
+ warranties of any kind concerning the Work, express, implied,
108
+ statutory or otherwise, including without limitation warranties of
109
+ title, merchantability, fitness for a particular purpose, non
110
+ infringement, or the absence of latent or other defects, accuracy, or
111
+ the present or absence of errors, whether or not discoverable, all to
112
+ the greatest extent permissible under applicable law.
113
+ c. Affirmer disclaims responsibility for clearing rights of other persons
114
+ that may apply to the Work or any use thereof, including without
115
+ limitation any person's Copyright and Related Rights in the Work.
116
+ Further, Affirmer disclaims responsibility for obtaining any necessary
117
+ consents, permissions or other rights required for any use of the
118
+ Work.
119
+ d. Affirmer understands and acknowledges that Creative Commons is not a
120
+ party to this document and has no duty or obligation with respect to
121
+ this CC0 or use of the Work.
package/LICENSE-MIT ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 electrovir
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,7 +1,11 @@
1
1
  # @augment-vir/common
2
2
 
3
- `augment-vir` is a collection of small helper functions that I constantly use across all my JavaScript and TypeScript repos. I call these functions `augments`. These are functions, constants, and types typically placed within a "util", or "helpers", etc. directory.
3
+ A collection of augments, helpers types, functions, and classes for any JavaScript environment.
4
4
 
5
- This `common` package is for environment-agnostic augments. Everything in here will work in Node.js or the browser with identical results.
5
+ - Examples: [`filterObject`](https://electrovir.github.io/augment-vir/functions/filterObject.html), [`wait`](https://electrovir.github.io/augment-vir/functions/wait.html), [`getEnumValues`](https://electrovir.github.io/augment-vir/functions/getEnumValues.html)
6
+ - Includes a colored logger implementation: [`log`](https://electrovir.github.io/augment-vir/variables/log.html)
7
+ - Includes a SQL-select-like runtime implementation of TypeScript's `Pick`: [`selectFrom`](https://electrovir.github.io/augment-vir/functions/selectFrom-1.html)
8
+ - Includes Prisma type helpers.
9
+ - and much more...
6
10
 
7
- Note that the `random*` functions exported by this package will not work in Node.js < v19.0.0.
11
+ See all `@augment-vir` docs here: https://electrovir.github.io/augment-vir
@@ -0,0 +1,34 @@
1
+ import type { ArrayElement } from '@augment-vir/core';
2
+ import { Writable } from '../type/writable.js';
3
+ /**
4
+ * Performs
5
+ * [`[].map()`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/map)
6
+ * on an array but transfers the input tuple's size to the output type.
7
+ *
8
+ * @category Array
9
+ * @category Package : @augment-vir/common
10
+ * @example
11
+ *
12
+ * ```ts
13
+ * import {typedMap} from '@augment-vir/common';
14
+ *
15
+ * const result = await typedMap(
16
+ * [
17
+ * 1,
18
+ * 2,
19
+ * 3,
20
+ * 4,
21
+ * 5,
22
+ * ],
23
+ * (value) => {
24
+ * return value + 1;
25
+ * },
26
+ * );
27
+ * ```
28
+ *
29
+ * @returns A new array (does not mutate).
30
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
31
+ */
32
+ export declare function typedMap<const ArrayGeneric extends ReadonlyArray<any>, const OutputType>(arrayToMap: ArrayGeneric, mapCallback: (value: ArrayElement<NoInfer<ArrayGeneric>>, index: number, array: NoInfer<ArrayGeneric>) => OutputType): Writable<{
33
+ [Index in keyof ArrayGeneric]: OutputType;
34
+ }>;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Performs
3
+ * [`[].map()`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/map)
4
+ * on an array but transfers the input tuple's size to the output type.
5
+ *
6
+ * @category Array
7
+ * @category Package : @augment-vir/common
8
+ * @example
9
+ *
10
+ * ```ts
11
+ * import {typedMap} from '@augment-vir/common';
12
+ *
13
+ * const result = await typedMap(
14
+ * [
15
+ * 1,
16
+ * 2,
17
+ * 3,
18
+ * 4,
19
+ * 5,
20
+ * ],
21
+ * (value) => {
22
+ * return value + 1;
23
+ * },
24
+ * );
25
+ * ```
26
+ *
27
+ * @returns A new array (does not mutate).
28
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
29
+ */
30
+ export function typedMap(arrayToMap, mapCallback) {
31
+ return arrayToMap.map(mapCallback);
32
+ }
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Polyfill for `Object.groupBy`:
3
+ * https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/groupBy
4
+ *
5
+ * @category Array
6
+ * @category Object
7
+ * @example
8
+ *
9
+ * ```ts
10
+ * import {arrayToObject} from '@augment-vir/common';
11
+ *
12
+ * const result = arrayToObject(
13
+ * [
14
+ * 'a',
15
+ * 'b',
16
+ * ],
17
+ * (value) => `key-${value}`,
18
+ * );
19
+ * // result is `{key-a: ['a'], key-b: ['b']}`
20
+ * ```
21
+ */
22
+ export declare function groupArrayBy<ElementType, NewKey extends PropertyKey>(inputArray: ReadonlyArray<ElementType>, callback: (value: ElementType, index: number, originalArray: ReadonlyArray<ElementType>) => NewKey): Partial<Record<NewKey, ElementType[]>>;
23
+ /**
24
+ * Similar to {@link groupArrayBy} but maps array entries to a single key and requires `key` _and_
25
+ * `value` outputs from the callback. The resulting object does not have an array of elements
26
+ * (unless the original array itself contains arrays).
27
+ *
28
+ * @category Array
29
+ * @category Object
30
+ * @category Package : @augment-vir/common
31
+ * @example
32
+ *
33
+ * ```ts
34
+ * import {arrayToObject} from '@augment-vir/common';
35
+ *
36
+ * const result = arrayToObject(
37
+ * [
38
+ * 'a',
39
+ * 'b',
40
+ * ],
41
+ * (value) => {
42
+ * return {key: `key-${value}`, value};
43
+ * },
44
+ * );
45
+ * // result is `{key-a: 'a', key-b: 'b'}`
46
+ * ```
47
+ *
48
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
49
+ */
50
+ export declare function arrayToObject<ElementType, NewKey extends PropertyKey, NewValue>(inputArray: ReadonlyArray<ElementType>, callback: (value: ElementType, index: number, originalArray: ReadonlyArray<ElementType>) => {
51
+ key: NewKey;
52
+ value: NewValue;
53
+ }): Partial<Record<NewKey, NewValue>>;
@@ -0,0 +1,67 @@
1
+ import { getOrSet } from '../object/get-or-set.js';
2
+ import { typedObjectFromEntries } from '../object/object-entries.js';
3
+ /**
4
+ * Polyfill for `Object.groupBy`:
5
+ * https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/groupBy
6
+ *
7
+ * @category Array
8
+ * @category Object
9
+ * @example
10
+ *
11
+ * ```ts
12
+ * import {arrayToObject} from '@augment-vir/common';
13
+ *
14
+ * const result = arrayToObject(
15
+ * [
16
+ * 'a',
17
+ * 'b',
18
+ * ],
19
+ * (value) => `key-${value}`,
20
+ * );
21
+ * // result is `{key-a: ['a'], key-b: ['b']}`
22
+ * ```
23
+ */
24
+ export function groupArrayBy(inputArray, callback) {
25
+ return inputArray.reduce((accum, entry, index, originalArray) => {
26
+ const key = callback(entry, index, originalArray);
27
+ const entryArray = getOrSet(accum, key, () => []);
28
+ entryArray.push(entry);
29
+ return accum;
30
+ }, {});
31
+ }
32
+ /**
33
+ * Similar to {@link groupArrayBy} but maps array entries to a single key and requires `key` _and_
34
+ * `value` outputs from the callback. The resulting object does not have an array of elements
35
+ * (unless the original array itself contains arrays).
36
+ *
37
+ * @category Array
38
+ * @category Object
39
+ * @category Package : @augment-vir/common
40
+ * @example
41
+ *
42
+ * ```ts
43
+ * import {arrayToObject} from '@augment-vir/common';
44
+ *
45
+ * const result = arrayToObject(
46
+ * [
47
+ * 'a',
48
+ * 'b',
49
+ * ],
50
+ * (value) => {
51
+ * return {key: `key-${value}`, value};
52
+ * },
53
+ * );
54
+ * // result is `{key-a: 'a', key-b: 'b'}`
55
+ * ```
56
+ *
57
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
58
+ */
59
+ export function arrayToObject(inputArray, callback) {
60
+ return typedObjectFromEntries(inputArray.map((entry, index, originalArray) => {
61
+ const { key, value } = callback(entry, index, originalArray);
62
+ return [
63
+ key,
64
+ value,
65
+ ];
66
+ }));
67
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Performs
3
+ * [`[].filter()`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/filter)
4
+ * on an array but supports an async callback.
5
+ *
6
+ * @category Array
7
+ * @category Package : @augment-vir/common
8
+ * @example
9
+ *
10
+ * ```ts
11
+ * import {awaitedFilter} from '@augment-vir/common';
12
+ *
13
+ * const result = await awaitedFilter(
14
+ * [
15
+ * 1,
16
+ * 2,
17
+ * 3,
18
+ * 4,
19
+ * 5,
20
+ * ],
21
+ * async (value) => {
22
+ * return await Promise.resolve(value > 2);
23
+ * },
24
+ * );
25
+ * ```
26
+ *
27
+ * @returns A new array (does not mutate).
28
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
29
+ */
30
+ export declare function awaitedFilter<OriginalGeneric>(arrayInput: ReadonlyArray<OriginalGeneric>, filterCallback: (arrayElement: OriginalGeneric, index: number, wholeArray: ReadonlyArray<OriginalGeneric>) => Promise<unknown>, options?: {
31
+ /**
32
+ * Each call to the filter callback is blocking, meaning the next one won't start until the
33
+ * current one finishes. By default this is false.
34
+ */
35
+ blocking?: boolean | undefined;
36
+ }): Promise<OriginalGeneric[]>;
@@ -0,0 +1,36 @@
1
+ import { awaitedBlockingMap } from './awaited-map.js';
2
+ /**
3
+ * Performs
4
+ * [`[].filter()`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/filter)
5
+ * on an array but supports an async callback.
6
+ *
7
+ * @category Array
8
+ * @category Package : @augment-vir/common
9
+ * @example
10
+ *
11
+ * ```ts
12
+ * import {awaitedFilter} from '@augment-vir/common';
13
+ *
14
+ * const result = await awaitedFilter(
15
+ * [
16
+ * 1,
17
+ * 2,
18
+ * 3,
19
+ * 4,
20
+ * 5,
21
+ * ],
22
+ * async (value) => {
23
+ * return await Promise.resolve(value > 2);
24
+ * },
25
+ * );
26
+ * ```
27
+ *
28
+ * @returns A new array (does not mutate).
29
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
30
+ */
31
+ export async function awaitedFilter(arrayInput, filterCallback, options) {
32
+ const callbackResults = options?.blocking
33
+ ? await awaitedBlockingMap(arrayInput, filterCallback)
34
+ : await Promise.all(arrayInput.map(filterCallback));
35
+ return arrayInput.filter((originalValue, index) => !!callbackResults[index]);
36
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Performs
3
+ * [`[].forEach()`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach)
4
+ * on an array but supports an async callback. The async callback is blocking. Meaning,
5
+ * `awaitedForEach` will wait for a callback on array element 1 to finish before moving on to array
6
+ * element 2.
7
+ *
8
+ * @category Array
9
+ * @category Package : @augment-vir/common
10
+ * @example
11
+ *
12
+ * ```ts
13
+ * import {awaitedForEach} from '@augment-vir/common';
14
+ *
15
+ * await awaitedForEach(
16
+ * [
17
+ * 1,
18
+ * 2,
19
+ * 3,
20
+ * 4,
21
+ * 5,
22
+ * ],
23
+ * async (value) => {
24
+ * await Promise.resolve(value);
25
+ * },
26
+ * );
27
+ * ```
28
+ *
29
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
30
+ */
31
+ export declare function awaitedForEach<OriginalGeneric>(input: ReadonlyArray<OriginalGeneric>, callback: (arrayElement: OriginalGeneric, index: number, wholeArray: ReadonlyArray<OriginalGeneric>) => void | PromiseLike<void>): Promise<void>;
@@ -0,0 +1,34 @@
1
+ import { awaitedBlockingMap } from './awaited-map.js';
2
+ /**
3
+ * Performs
4
+ * [`[].forEach()`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach)
5
+ * on an array but supports an async callback. The async callback is blocking. Meaning,
6
+ * `awaitedForEach` will wait for a callback on array element 1 to finish before moving on to array
7
+ * element 2.
8
+ *
9
+ * @category Array
10
+ * @category Package : @augment-vir/common
11
+ * @example
12
+ *
13
+ * ```ts
14
+ * import {awaitedForEach} from '@augment-vir/common';
15
+ *
16
+ * await awaitedForEach(
17
+ * [
18
+ * 1,
19
+ * 2,
20
+ * 3,
21
+ * 4,
22
+ * 5,
23
+ * ],
24
+ * async (value) => {
25
+ * await Promise.resolve(value);
26
+ * },
27
+ * );
28
+ * ```
29
+ *
30
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
31
+ */
32
+ export async function awaitedForEach(input, callback) {
33
+ await awaitedBlockingMap(input, callback);
34
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Performs
3
+ * [`[].map()`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/map)
4
+ * on an array but supports an async callback. The async callback is blocking. Meaning,
5
+ * `awaitedForEach` will wait for a callback on array element 1 to finish before moving on to array
6
+ * element 2. Compare to `await Promise.all([].map(async () => {}))` which is _not_ blocking (all
7
+ * callbacks are called in parallel).
8
+ *
9
+ * @category Array
10
+ * @category Package : @augment-vir/common
11
+ * @example
12
+ *
13
+ * ```ts
14
+ * import {awaitedBlockingMap} from '@augment-vir/common';
15
+ *
16
+ * const result = await awaitedBlockingMap(
17
+ * [
18
+ * 1,
19
+ * 2,
20
+ * 3,
21
+ * 4,
22
+ * 5,
23
+ * ],
24
+ * async (value) => {
25
+ * return await Promise.resolve(value);
26
+ * },
27
+ * );
28
+ * ```
29
+ *
30
+ * @returns A new array (does not mutate).
31
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
32
+ */
33
+ export declare function awaitedBlockingMap<OriginalGeneric, MappedGeneric>(input: ReadonlyArray<OriginalGeneric>, callback: (arrayElement: OriginalGeneric, index: number, wholeArray: ReadonlyArray<OriginalGeneric>) => MappedGeneric | PromiseLike<MappedGeneric>): Promise<Awaited<MappedGeneric>[]>;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Performs
3
+ * [`[].map()`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/map)
4
+ * on an array but supports an async callback. The async callback is blocking. Meaning,
5
+ * `awaitedForEach` will wait for a callback on array element 1 to finish before moving on to array
6
+ * element 2. Compare to `await Promise.all([].map(async () => {}))` which is _not_ blocking (all
7
+ * callbacks are called in parallel).
8
+ *
9
+ * @category Array
10
+ * @category Package : @augment-vir/common
11
+ * @example
12
+ *
13
+ * ```ts
14
+ * import {awaitedBlockingMap} from '@augment-vir/common';
15
+ *
16
+ * const result = await awaitedBlockingMap(
17
+ * [
18
+ * 1,
19
+ * 2,
20
+ * 3,
21
+ * 4,
22
+ * 5,
23
+ * ],
24
+ * async (value) => {
25
+ * return await Promise.resolve(value);
26
+ * },
27
+ * );
28
+ * ```
29
+ *
30
+ * @returns A new array (does not mutate).
31
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
32
+ */
33
+ export async function awaitedBlockingMap(input, callback) {
34
+ return await input.reduce(async (accumPromise, currentElement, index, wholeArray) => {
35
+ const accum = await accumPromise;
36
+ const mappedValue = await callback(currentElement, index, wholeArray);
37
+ accum.push(mappedValue);
38
+ return accum;
39
+ }, Promise.resolve([]));
40
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Removes all given indexes from the given array.
3
+ *
4
+ * @category Array
5
+ * @category Package : @augment-vir/common
6
+ * @example
7
+ *
8
+ * ```ts
9
+ * import {filterOutIndexes} from '@augment-vir/common';
10
+ *
11
+ * const result = filterOutIndexes(
12
+ * [
13
+ * 'a',
14
+ * 'b',
15
+ * '',
16
+ * ],
17
+ * [
18
+ * 0,
19
+ * 2,
20
+ * ],
21
+ * );
22
+ * // result is `['b']`
23
+ * ```
24
+ *
25
+ * @returns A new array (does not mutate).
26
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
27
+ */
28
+ export declare function filterOutIndexes<T>(array: ReadonlyArray<T>, indexes: ReadonlyArray<number>): T[];
29
+ /** Performs `filterMap` with a type guard filter. */
30
+ export declare function filterMap<ElementType, MappedEntry, TypeGuarded extends MappedEntry>(inputArray: ReadonlyArray<ElementType>, mapCallback: (entry: ElementType, index: number, originalArray: ReadonlyArray<ElementType>) => MappedEntry, filterCallback: (mappedOutput: MappedEntry, originalEntry: ElementType, index: number, originalArray: ReadonlyArray<ElementType>) => mappedOutput is TypeGuarded): TypeGuarded[];
31
+ /** Performs a regular `filterMap`. */
32
+ export declare function filterMap<ElementType, MappedEntry>(inputArray: ReadonlyArray<ElementType>, mapCallback: (entry: ElementType, index: number, originalArray: ReadonlyArray<ElementType>) => MappedEntry, filterCallback: (mappedOutput: MappedEntry, originalEntry: ElementType, index: number, originalArray: ReadonlyArray<ElementType>) => boolean): MappedEntry[];
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Removes all given indexes from the given array.
3
+ *
4
+ * @category Array
5
+ * @category Package : @augment-vir/common
6
+ * @example
7
+ *
8
+ * ```ts
9
+ * import {filterOutIndexes} from '@augment-vir/common';
10
+ *
11
+ * const result = filterOutIndexes(
12
+ * [
13
+ * 'a',
14
+ * 'b',
15
+ * '',
16
+ * ],
17
+ * [
18
+ * 0,
19
+ * 2,
20
+ * ],
21
+ * );
22
+ * // result is `['b']`
23
+ * ```
24
+ *
25
+ * @returns A new array (does not mutate).
26
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
27
+ */
28
+ export function filterOutIndexes(array, indexes) {
29
+ return array.filter((_, index) => !indexes.includes(index));
30
+ }
31
+ /**
32
+ * Performs
33
+ * [`[].map()`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/map)
34
+ * and
35
+ * [`[].filter()`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/filter)
36
+ * (in that order) on an array with a single iteration.
37
+ *
38
+ * @category Array
39
+ * @category Package : @augment-vir/common
40
+ * @example
41
+ *
42
+ * ```ts
43
+ * import {filterMap} from '@augment-vir/common';
44
+ *
45
+ * const result = filterMap(
46
+ * [
47
+ * 'a',
48
+ * 'b',
49
+ * '',
50
+ * ],
51
+ * // map callback
52
+ * (value) => {
53
+ * return `value-${value}`;
54
+ * },
55
+ * // filter callback
56
+ * (mappedValue, originalValue) => {
57
+ * return !!originalValue;
58
+ * },
59
+ * );
60
+ * // result is `['value-a', 'value-b']`
61
+ * ```
62
+ *
63
+ * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
64
+ */
65
+ export function filterMap(inputArray, mapCallback, filterCallback) {
66
+ return inputArray.reduce((accum, entry, index, originalArray) => {
67
+ const mapOutput = mapCallback(entry, index, originalArray);
68
+ const filterOutput = filterCallback(mapOutput, entry, index, originalArray);
69
+ if (filterOutput) {
70
+ accum.push(mapOutput);
71
+ }
72
+ return accum;
73
+ }, []);
74
+ }