rubico 2.0.1 → 2.2.0

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 (501) hide show
  1. package/README.md +10 -8
  2. package/Transducer.js +28 -0
  3. package/_internal/genericTransform.js +30 -28
  4. package/_internal/reducerTryCatch.js +55 -0
  5. package/dist/Transducer.es.js +28 -1
  6. package/dist/Transducer.es.min.js +2 -2
  7. package/dist/Transducer.js +28 -1
  8. package/dist/Transducer.min.js +2 -2
  9. package/dist/Transducer.mjs +28 -1
  10. package/dist/__.es.js +1 -1
  11. package/dist/__.es.min.js +1 -1
  12. package/dist/__.js +1 -1
  13. package/dist/__.min.js +1 -1
  14. package/dist/__.mjs +1 -1
  15. package/dist/all.es.js +1 -1
  16. package/dist/all.es.min.js +1 -1
  17. package/dist/all.js +1 -1
  18. package/dist/all.min.js +1 -1
  19. package/dist/all.mjs +1 -1
  20. package/dist/always.es.js +1 -1
  21. package/dist/always.es.min.js +1 -1
  22. package/dist/always.js +1 -1
  23. package/dist/always.min.js +1 -1
  24. package/dist/always.mjs +1 -1
  25. package/dist/and.es.js +1 -1
  26. package/dist/and.es.min.js +1 -1
  27. package/dist/and.js +1 -1
  28. package/dist/and.min.js +1 -1
  29. package/dist/and.mjs +1 -1
  30. package/dist/assign.es.js +1 -1
  31. package/dist/assign.es.min.js +1 -1
  32. package/dist/assign.js +1 -1
  33. package/dist/assign.min.js +1 -1
  34. package/dist/assign.mjs +1 -1
  35. package/dist/compose.es.js +1 -1
  36. package/dist/compose.es.min.js +1 -1
  37. package/dist/compose.js +1 -1
  38. package/dist/compose.min.js +1 -1
  39. package/dist/compose.mjs +1 -1
  40. package/dist/curry.es.js +1 -1
  41. package/dist/curry.es.min.js +1 -1
  42. package/dist/curry.js +1 -1
  43. package/dist/curry.min.js +1 -1
  44. package/dist/curry.mjs +1 -1
  45. package/dist/eq.es.js +1 -1
  46. package/dist/eq.es.min.js +1 -1
  47. package/dist/eq.js +1 -1
  48. package/dist/eq.min.js +1 -1
  49. package/dist/eq.mjs +1 -1
  50. package/dist/every.es.js +1 -1
  51. package/dist/every.es.min.js +1 -1
  52. package/dist/every.js +1 -1
  53. package/dist/every.min.js +1 -1
  54. package/dist/every.mjs +1 -1
  55. package/dist/filter.es.js +1 -1
  56. package/dist/filter.es.min.js +1 -1
  57. package/dist/filter.js +1 -1
  58. package/dist/filter.min.js +1 -1
  59. package/dist/filter.mjs +1 -1
  60. package/dist/flatMap.es.js +1 -1
  61. package/dist/flatMap.es.min.js +1 -1
  62. package/dist/flatMap.js +1 -1
  63. package/dist/flatMap.min.js +1 -1
  64. package/dist/flatMap.mjs +1 -1
  65. package/dist/forEach.es.js +1 -1
  66. package/dist/forEach.es.min.js +1 -1
  67. package/dist/forEach.js +1 -1
  68. package/dist/forEach.min.js +1 -1
  69. package/dist/forEach.mjs +1 -1
  70. package/dist/get.es.js +1 -1
  71. package/dist/get.es.min.js +1 -1
  72. package/dist/get.js +1 -1
  73. package/dist/get.min.js +1 -1
  74. package/dist/get.mjs +1 -1
  75. package/dist/gt.es.js +1 -1
  76. package/dist/gt.es.min.js +1 -1
  77. package/dist/gt.js +1 -1
  78. package/dist/gt.min.js +1 -1
  79. package/dist/gt.mjs +1 -1
  80. package/dist/gte.es.js +1 -1
  81. package/dist/gte.es.min.js +1 -1
  82. package/dist/gte.js +1 -1
  83. package/dist/gte.min.js +1 -1
  84. package/dist/gte.mjs +1 -1
  85. package/dist/lt.es.js +1 -1
  86. package/dist/lt.es.min.js +1 -1
  87. package/dist/lt.js +1 -1
  88. package/dist/lt.min.js +1 -1
  89. package/dist/lt.mjs +1 -1
  90. package/dist/lte.es.js +1 -1
  91. package/dist/lte.es.min.js +1 -1
  92. package/dist/lte.js +1 -1
  93. package/dist/lte.min.js +1 -1
  94. package/dist/lte.mjs +1 -1
  95. package/dist/map.es.js +1 -1
  96. package/dist/map.es.min.js +1 -1
  97. package/dist/map.js +1 -1
  98. package/dist/map.min.js +1 -1
  99. package/dist/map.mjs +1 -1
  100. package/dist/not.es.js +1 -1
  101. package/dist/not.es.min.js +1 -1
  102. package/dist/not.js +1 -1
  103. package/dist/not.min.js +1 -1
  104. package/dist/not.mjs +1 -1
  105. package/dist/omit.es.js +1 -1
  106. package/dist/omit.es.min.js +1 -1
  107. package/dist/omit.js +1 -1
  108. package/dist/omit.min.js +1 -1
  109. package/dist/omit.mjs +1 -1
  110. package/dist/or.es.js +1 -1
  111. package/dist/or.es.min.js +1 -1
  112. package/dist/or.js +1 -1
  113. package/dist/or.min.js +1 -1
  114. package/dist/or.mjs +1 -1
  115. package/dist/pick.es.js +1 -1
  116. package/dist/pick.es.min.js +1 -1
  117. package/dist/pick.js +1 -1
  118. package/dist/pick.min.js +1 -1
  119. package/dist/pick.mjs +1 -1
  120. package/dist/pipe.es.js +1 -1
  121. package/dist/pipe.es.min.js +1 -1
  122. package/dist/pipe.js +1 -1
  123. package/dist/pipe.min.js +1 -1
  124. package/dist/pipe.mjs +1 -1
  125. package/dist/reduce.es.js +1 -1
  126. package/dist/reduce.es.min.js +1 -1
  127. package/dist/reduce.js +1 -1
  128. package/dist/reduce.min.js +1 -1
  129. package/dist/reduce.mjs +1 -1
  130. package/dist/rubico.es.js +57 -46
  131. package/dist/rubico.es.min.js +2 -2
  132. package/dist/rubico.global.js +57 -46
  133. package/dist/rubico.global.min.js +2 -2
  134. package/dist/rubico.js +57 -46
  135. package/dist/rubico.min.js +2 -2
  136. package/dist/rubico.mjs +57 -46
  137. package/dist/set.es.js +1 -1
  138. package/dist/set.es.min.js +1 -1
  139. package/dist/set.js +1 -1
  140. package/dist/set.min.js +1 -1
  141. package/dist/set.mjs +1 -1
  142. package/dist/some.es.js +1 -1
  143. package/dist/some.es.min.js +1 -1
  144. package/dist/some.js +1 -1
  145. package/dist/some.min.js +1 -1
  146. package/dist/some.mjs +1 -1
  147. package/dist/switchCase.es.js +1 -1
  148. package/dist/switchCase.es.min.js +1 -1
  149. package/dist/switchCase.js +1 -1
  150. package/dist/switchCase.min.js +1 -1
  151. package/dist/switchCase.mjs +1 -1
  152. package/dist/tap.es.js +32 -2
  153. package/dist/tap.es.min.js +2 -2
  154. package/dist/tap.js +32 -2
  155. package/dist/tap.min.js +2 -2
  156. package/dist/tap.mjs +32 -2
  157. package/dist/thunkify.es.js +1 -1
  158. package/dist/thunkify.es.min.js +1 -1
  159. package/dist/thunkify.js +1 -1
  160. package/dist/thunkify.min.js +1 -1
  161. package/dist/thunkify.mjs +1 -1
  162. package/dist/transform.es.js +26 -24
  163. package/dist/transform.es.min.js +2 -2
  164. package/dist/transform.js +26 -24
  165. package/dist/transform.min.js +2 -2
  166. package/dist/transform.mjs +26 -24
  167. package/dist/tryCatch.es.js +1 -1
  168. package/dist/tryCatch.es.min.js +1 -1
  169. package/dist/tryCatch.js +1 -1
  170. package/dist/tryCatch.min.js +1 -1
  171. package/dist/tryCatch.mjs +1 -1
  172. package/dist/x/append.es.js +1 -1
  173. package/dist/x/append.es.min.js +1 -1
  174. package/dist/x/append.js +1 -1
  175. package/dist/x/append.min.js +1 -1
  176. package/dist/x/append.mjs +1 -1
  177. package/dist/x/callProp.es.js +1 -1
  178. package/dist/x/callProp.es.min.js +1 -1
  179. package/dist/x/callProp.js +1 -1
  180. package/dist/x/callProp.min.js +1 -1
  181. package/dist/x/callProp.mjs +1 -1
  182. package/dist/x/defaultsDeep.es.js +1 -1
  183. package/dist/x/defaultsDeep.es.min.js +1 -1
  184. package/dist/x/defaultsDeep.js +1 -1
  185. package/dist/x/defaultsDeep.min.js +1 -1
  186. package/dist/x/defaultsDeep.mjs +1 -1
  187. package/dist/x/differenceWith.es.js +1 -1
  188. package/dist/x/differenceWith.es.min.js +1 -1
  189. package/dist/x/differenceWith.js +1 -1
  190. package/dist/x/differenceWith.min.js +1 -1
  191. package/dist/x/differenceWith.mjs +1 -1
  192. package/dist/x/filterOut.es.js +1 -1
  193. package/dist/x/filterOut.es.min.js +1 -1
  194. package/dist/x/filterOut.js +1 -1
  195. package/dist/x/filterOut.min.js +1 -1
  196. package/dist/x/filterOut.mjs +1 -1
  197. package/dist/x/find.es.js +1 -1
  198. package/dist/x/find.es.min.js +1 -1
  199. package/dist/x/find.js +1 -1
  200. package/dist/x/find.min.js +1 -1
  201. package/dist/x/find.mjs +1 -1
  202. package/dist/x/findIndex.es.js +1 -1
  203. package/dist/x/findIndex.es.min.js +1 -1
  204. package/dist/x/findIndex.js +1 -1
  205. package/dist/x/findIndex.min.js +1 -1
  206. package/dist/x/findIndex.mjs +1 -1
  207. package/dist/x/first.es.js +1 -1
  208. package/dist/x/first.es.min.js +1 -1
  209. package/dist/x/first.js +1 -1
  210. package/dist/x/first.min.js +1 -1
  211. package/dist/x/first.mjs +1 -1
  212. package/dist/x/flatten.es.js +1 -1
  213. package/dist/x/flatten.es.min.js +1 -1
  214. package/dist/x/flatten.js +1 -1
  215. package/dist/x/flatten.min.js +1 -1
  216. package/dist/x/flatten.mjs +1 -1
  217. package/dist/x/groupBy.es.js +1 -1
  218. package/dist/x/groupBy.es.min.js +1 -1
  219. package/dist/x/groupBy.js +1 -1
  220. package/dist/x/groupBy.min.js +1 -1
  221. package/dist/x/groupBy.mjs +1 -1
  222. package/dist/x/has.es.js +1 -1
  223. package/dist/x/has.es.min.js +1 -1
  224. package/dist/x/has.js +1 -1
  225. package/dist/x/has.min.js +1 -1
  226. package/dist/x/has.mjs +1 -1
  227. package/dist/x/identity.es.js +1 -1
  228. package/dist/x/identity.es.min.js +1 -1
  229. package/dist/x/identity.js +1 -1
  230. package/dist/x/identity.min.js +1 -1
  231. package/dist/x/identity.mjs +1 -1
  232. package/dist/x/includes.es.js +1 -1
  233. package/dist/x/includes.es.min.js +1 -1
  234. package/dist/x/includes.js +1 -1
  235. package/dist/x/includes.min.js +1 -1
  236. package/dist/x/includes.mjs +1 -1
  237. package/dist/x/isDeepEqual.es.js +1 -1
  238. package/dist/x/isDeepEqual.es.min.js +1 -1
  239. package/dist/x/isDeepEqual.js +1 -1
  240. package/dist/x/isDeepEqual.min.js +1 -1
  241. package/dist/x/isDeepEqual.mjs +1 -1
  242. package/dist/x/isEmpty.es.js +1 -1
  243. package/dist/x/isEmpty.es.min.js +1 -1
  244. package/dist/x/isEmpty.js +1 -1
  245. package/dist/x/isEmpty.min.js +1 -1
  246. package/dist/x/isEmpty.mjs +1 -1
  247. package/dist/x/isEqual.es.js +1 -1
  248. package/dist/x/isEqual.es.min.js +1 -1
  249. package/dist/x/isEqual.js +1 -1
  250. package/dist/x/isEqual.min.js +1 -1
  251. package/dist/x/isEqual.mjs +1 -1
  252. package/dist/x/isFunction.es.js +1 -1
  253. package/dist/x/isFunction.es.min.js +1 -1
  254. package/dist/x/isFunction.js +1 -1
  255. package/dist/x/isFunction.min.js +1 -1
  256. package/dist/x/isFunction.mjs +1 -1
  257. package/dist/x/isIn.es.js +1 -1
  258. package/dist/x/isIn.es.min.js +1 -1
  259. package/dist/x/isIn.js +1 -1
  260. package/dist/x/isIn.min.js +1 -1
  261. package/dist/x/isIn.mjs +1 -1
  262. package/dist/x/isObject.es.js +1 -1
  263. package/dist/x/isObject.es.min.js +1 -1
  264. package/dist/x/isObject.js +1 -1
  265. package/dist/x/isObject.min.js +1 -1
  266. package/dist/x/isObject.mjs +1 -1
  267. package/dist/x/isString.es.js +1 -1
  268. package/dist/x/isString.es.min.js +1 -1
  269. package/dist/x/isString.js +1 -1
  270. package/dist/x/isString.min.js +1 -1
  271. package/dist/x/isString.mjs +1 -1
  272. package/dist/x/keys.es.js +1 -1
  273. package/dist/x/keys.es.min.js +1 -1
  274. package/dist/x/keys.js +1 -1
  275. package/dist/x/keys.min.js +1 -1
  276. package/dist/x/keys.mjs +1 -1
  277. package/dist/x/last.es.js +1 -1
  278. package/dist/x/last.es.min.js +1 -1
  279. package/dist/x/last.js +1 -1
  280. package/dist/x/last.min.js +1 -1
  281. package/dist/x/last.mjs +1 -1
  282. package/dist/x/maxBy.es.js +1 -1
  283. package/dist/x/maxBy.es.min.js +1 -1
  284. package/dist/x/maxBy.js +1 -1
  285. package/dist/x/maxBy.min.js +1 -1
  286. package/dist/x/maxBy.mjs +1 -1
  287. package/dist/x/noop.es.js +1 -1
  288. package/dist/x/noop.es.min.js +1 -1
  289. package/dist/x/noop.js +1 -1
  290. package/dist/x/noop.min.js +1 -1
  291. package/dist/x/noop.mjs +1 -1
  292. package/dist/x/pluck.es.js +1 -1
  293. package/dist/x/pluck.es.min.js +1 -1
  294. package/dist/x/pluck.js +1 -1
  295. package/dist/x/pluck.min.js +1 -1
  296. package/dist/x/pluck.mjs +1 -1
  297. package/dist/x/prepend.es.js +1 -1
  298. package/dist/x/prepend.es.min.js +1 -1
  299. package/dist/x/prepend.js +1 -1
  300. package/dist/x/prepend.min.js +1 -1
  301. package/dist/x/prepend.mjs +1 -1
  302. package/dist/x/size.es.js +1 -1
  303. package/dist/x/size.es.min.js +1 -1
  304. package/dist/x/size.js +1 -1
  305. package/dist/x/size.min.js +1 -1
  306. package/dist/x/size.mjs +1 -1
  307. package/dist/x/trace.es.js +32 -2
  308. package/dist/x/trace.es.min.js +2 -2
  309. package/dist/x/trace.js +32 -2
  310. package/dist/x/trace.min.js +2 -2
  311. package/dist/x/trace.mjs +32 -2
  312. package/dist/x/unionWith.es.js +1 -1
  313. package/dist/x/unionWith.es.min.js +1 -1
  314. package/dist/x/unionWith.js +1 -1
  315. package/dist/x/unionWith.min.js +1 -1
  316. package/dist/x/unionWith.mjs +1 -1
  317. package/dist/x/uniq.es.js +1 -1
  318. package/dist/x/uniq.es.min.js +1 -1
  319. package/dist/x/uniq.js +1 -1
  320. package/dist/x/uniq.min.js +1 -1
  321. package/dist/x/uniq.mjs +1 -1
  322. package/dist/x/unless.es.js +1 -1
  323. package/dist/x/unless.es.min.js +1 -1
  324. package/dist/x/unless.js +1 -1
  325. package/dist/x/unless.min.js +1 -1
  326. package/dist/x/unless.mjs +1 -1
  327. package/dist/x/values.es.js +1 -1
  328. package/dist/x/values.es.min.js +1 -1
  329. package/dist/x/values.js +1 -1
  330. package/dist/x/values.min.js +1 -1
  331. package/dist/x/values.mjs +1 -1
  332. package/dist/x/when.es.js +1 -1
  333. package/dist/x/when.es.min.js +1 -1
  334. package/dist/x/when.js +1 -1
  335. package/dist/x/when.min.js +1 -1
  336. package/dist/x/when.mjs +1 -1
  337. package/es.js +57 -46
  338. package/index.js +57 -46
  339. package/package.json +43 -2
  340. package/tap.js +15 -4
  341. package/.eslintignore +0 -5
  342. package/.eslintrc.js +0 -330
  343. package/.github/workflows/nodejs.yml +0 -27
  344. package/.vscode/launch.json +0 -25
  345. package/AggregateReducer.test.js +0 -82
  346. package/CHANGELOG.md +0 -310
  347. package/CNAME +0 -1
  348. package/CODE_OF_CONDUCT.md +0 -128
  349. package/CONTRIBUTING.md +0 -4
  350. package/Transducer.test.js +0 -117
  351. package/_config.yml +0 -1
  352. package/_internal/improvedGenericTransform.js +0 -93
  353. package/archive/FlatMappingIterator-2020-09-28.js +0 -68
  354. package/archive/_Promise-2023-05-29.js +0 -93
  355. package/archive/arrayMap2-2023-05-29.js +0 -73
  356. package/archive/benchmarks-v1.9.7/all.js +0 -34
  357. package/archive/benchmarks-v1.9.7/and.js +0 -24
  358. package/archive/benchmarks-v1.9.7/any.js +0 -32
  359. package/archive/benchmarks-v1.9.7/assign.js +0 -174
  360. package/archive/benchmarks-v1.9.7/curry.js +0 -55
  361. package/archive/benchmarks-v1.9.7/eq.js +0 -25
  362. package/archive/benchmarks-v1.9.7/filter.js +0 -1322
  363. package/archive/benchmarks-v1.9.7/flatMap.js +0 -48
  364. package/archive/benchmarks-v1.9.7/forEach.js +0 -33
  365. package/archive/benchmarks-v1.9.7/fork.js +0 -123
  366. package/archive/benchmarks-v1.9.7/get.js +0 -44
  367. package/archive/benchmarks-v1.9.7/gt.js +0 -25
  368. package/archive/benchmarks-v1.9.7/gte.js +0 -25
  369. package/archive/benchmarks-v1.9.7/integration.js +0 -88
  370. package/archive/benchmarks-v1.9.7/lt.js +0 -25
  371. package/archive/benchmarks-v1.9.7/lte.js +0 -25
  372. package/archive/benchmarks-v1.9.7/map.js +0 -892
  373. package/archive/benchmarks-v1.9.7/misc.js +0 -470
  374. package/archive/benchmarks-v1.9.7/omit.js +0 -28
  375. package/archive/benchmarks-v1.9.7/or.js +0 -51
  376. package/archive/benchmarks-v1.9.7/pick.js +0 -24
  377. package/archive/benchmarks-v1.9.7/pipe.js +0 -152
  378. package/archive/benchmarks-v1.9.7/reduce.js +0 -739
  379. package/archive/benchmarks-v1.9.7/switchCase.js +0 -256
  380. package/archive/benchmarks-v1.9.7/tap.js +0 -90
  381. package/archive/benchmarks-v1.9.7/transform.js +0 -218
  382. package/archive/benchmarks-v1.9.7/tryCatch.js +0 -108
  383. package/archive/curry.js +0 -13
  384. package/archive/examples-v1.6.11/browserModule.html +0 -31
  385. package/archive/examples-v1.6.11/browserScript.html +0 -32
  386. package/archive/examples-v1.6.11/coolTransformToConsole.js +0 -1
  387. package/archive/examples-v1.6.11/denoLargeGasMap.js +0 -85
  388. package/archive/examples-v1.6.11/denoServer.js +0 -9
  389. package/archive/examples-v1.6.11/denoServerWithMiddleware.js +0 -55
  390. package/archive/examples-v1.6.11/logTodosRange.js +0 -21
  391. package/archive/examples-v1.6.11/makeARequest.html +0 -46
  392. package/archive/examples-v1.6.11/nodeComplexTransformation.js +0 -106
  393. package/archive/examples-v1.6.11/nodeConditionallyExtractIDs.js +0 -50
  394. package/archive/examples-v1.6.11/nodeFloatingPoint.js +0 -55
  395. package/archive/examples-v1.6.11/nodeGetAllJiraBoards.js +0 -45
  396. package/archive/examples-v1.6.11/nodeGetSocketIOClientsTotalCount.js +0 -34
  397. package/archive/examples-v1.6.11/nodeKafkaConsumer.js +0 -63
  398. package/archive/examples-v1.6.11/nodeMakeMultipleRequests.js +0 -55
  399. package/archive/examples-v1.6.11/nodeOnRecordAddTask.js +0 -34
  400. package/archive/examples-v1.6.11/nodePostRequestWithAuth.js +0 -36
  401. package/archive/examples-v1.6.11/nodeSpeedbackMatchmakingAlgorithm.js +0 -96
  402. package/archive/examples-v1.6.11/nodeTireData.js +0 -36
  403. package/archive/examples-v1.6.11/nodeTripleMap.js +0 -85
  404. package/archive/examples-v1.6.11/squaredOdds.ts +0 -16
  405. package/archive/examples-v1.6.11/transducerMaxBuyer.js +0 -67
  406. package/archive/examples-v1.6.11/transformLogTodosRange.js +0 -31
  407. package/archive/examples-v1.6.11/transformStreamRandomInts.js +0 -19
  408. package/archive/genericReduceConcurrent.js +0 -277
  409. package/archive/index.v0.2.9.js +0 -1685
  410. package/archive/objectValuesGenerator.js +0 -13
  411. package/archive/test.v0.2.9.js +0 -2334
  412. package/bench +0 -65
  413. package/benchmark-output/v1.9.7 +0 -268
  414. package/benchmarks/all.async.js +0 -43
  415. package/benchmarks/all.js +0 -43
  416. package/benchmarks/always.js +0 -15
  417. package/benchmarks/and.async.js +0 -25
  418. package/benchmarks/and.js +0 -25
  419. package/benchmarks/assign.async.js +0 -27
  420. package/benchmarks/assign.js +0 -27
  421. package/benchmarks/curry.js +0 -35
  422. package/benchmarks/eq.async.js +0 -23
  423. package/benchmarks/eq.js +0 -23
  424. package/benchmarks/every.async.js +0 -19
  425. package/benchmarks/every.js +0 -19
  426. package/benchmarks/filter.async.js +0 -32
  427. package/benchmarks/filter.js +0 -38
  428. package/benchmarks/flatMap.async.js +0 -26
  429. package/benchmarks/flatMap.js +0 -38
  430. package/benchmarks/get.async.js +0 -19
  431. package/benchmarks/get.js +0 -39
  432. package/benchmarks/gt.async.js +0 -23
  433. package/benchmarks/gt.js +0 -23
  434. package/benchmarks/gte.async.js +0 -23
  435. package/benchmarks/gte.js +0 -23
  436. package/benchmarks/lt.async.js +0 -23
  437. package/benchmarks/lt.js +0 -23
  438. package/benchmarks/lte.async.js +0 -23
  439. package/benchmarks/lte.js +0 -23
  440. package/benchmarks/map.async.js +0 -43
  441. package/benchmarks/map.js +0 -40
  442. package/benchmarks/misc/Promise.js +0 -26
  443. package/benchmarks/misc/isPromise.js +0 -30
  444. package/benchmarks/misc/promiseAll.js +0 -36
  445. package/benchmarks/not.js +0 -23
  446. package/benchmarks/omit.js +0 -38
  447. package/benchmarks/or.async.js +0 -25
  448. package/benchmarks/or.js +0 -25
  449. package/benchmarks/pick.js +0 -38
  450. package/benchmarks/pipe.async.js +0 -47
  451. package/benchmarks/pipe.js +0 -47
  452. package/benchmarks/reduce.async.js +0 -32
  453. package/benchmarks/reduce.js +0 -38
  454. package/benchmarks/set.async.js +0 -19
  455. package/benchmarks/set.js +0 -41
  456. package/benchmarks/some.async.js +0 -19
  457. package/benchmarks/some.js +0 -19
  458. package/benchmarks/switchCase.async.js +0 -27
  459. package/benchmarks/switchCase.js +0 -55
  460. package/benchmarks/tap.js +0 -15
  461. package/benchmarks/thunkify.js +0 -15
  462. package/benchmarks/transform.async.js +0 -27
  463. package/benchmarks/transform.js +0 -40
  464. package/benchmarks/tryCatch.async.js +0 -25
  465. package/benchmarks/tryCatch.js +0 -32
  466. package/build +0 -472
  467. package/dist-test.js +0 -37
  468. package/examples/type-to-search-wiki/README.md +0 -19
  469. package/examples/type-to-search-wiki/package.json +0 -13
  470. package/examples/type-to-search-wiki/src/app.js +0 -46
  471. package/examples/type-to-search-wiki/src/index.html +0 -18
  472. package/import-test.html +0 -73
  473. package/memory-usage/reduce.js +0 -40
  474. package/monad/AsyncPool.js +0 -0
  475. package/monad/BrokenPromise.js +0 -63
  476. package/monad/BrokenPromise.test.js +0 -22
  477. package/monad/Cancellable.js +0 -84
  478. package/monad/Cancellable.memoryUsage.js +0 -60
  479. package/monad/Cancellable.test.js +0 -20
  480. package/monad/Function.js +0 -0
  481. package/monad/Instance.benchmark.js +0 -378
  482. package/monad/Instance.js +0 -351
  483. package/monad/Instance.test.js +0 -445
  484. package/monad/Mux.benchmark.js +0 -29
  485. package/monad/Mux.js +0 -589
  486. package/monad/Mux.test.js +0 -512
  487. package/monad/PossiblePromise.benchmark.js +0 -87
  488. package/monad/PossiblePromise.js +0 -144
  489. package/monad/PossiblePromise.test.js +0 -89
  490. package/monad/README.md +0 -75
  491. package/monad/Reducer.js +0 -0
  492. package/monad/Sequence.benchmark.js +0 -42
  493. package/monad/Sequence.js +0 -36
  494. package/monad/SpecScript.js +0 -0
  495. package/monad/Stack.js +0 -0
  496. package/monad/Struct.benchmark.js +0 -154
  497. package/monad/Struct.js +0 -249
  498. package/monad/Struct.test.js +0 -237
  499. package/rubico.js +0 -66
  500. package/test.js +0 -4242
  501. package/tmp.js +0 -1
@@ -1,34 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const { pipe, fork, map, get } = require('rubico')
4
-
5
- const requestAPI = record => {/* make API request */}
6
-
7
- const saveToDatabase = result => {/* save result to database */}
8
-
9
- const getImages = apiResult => {/* make images API request */}
10
-
11
- const flatten = arr => arr.flat(1)
12
-
13
- const uploadToS3 = image => {/* upload to s3 code */}
14
-
15
- /*
16
- const onRecordAddTask = async record => {
17
- const results = await requestAPI(record)
18
- const [arraysOfImages,] = await Promise.all([
19
- await Promise.all(results.map(getImages)),
20
- await Promise.all(results.map(saveToDatabase)),
21
- ])
22
- await Promise.all(flatten(arraysOfImages).map(uploadToS3))
23
- }
24
- */
25
-
26
- const onRecordAddTask = pipe([
27
- requestAPI,
28
- fork([
29
- map(getImages),
30
- map(saveToDatabase),
31
- ]),
32
- get(0),
33
- map(map(uploadToS3)),
34
- ])
@@ -1,36 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const fetch = require('node-fetch')
4
- const { pipe, fork, get } = require('..')
5
-
6
- const getToken = () => 'token'
7
-
8
- const getJSON = res => res.json()
9
-
10
- // expects the object { body: {...}, uuid: 'string' }
11
- const postRequestWithAuth = route => pipe([
12
- fork({
13
- method: () => 'POST',
14
- headers: pipe([
15
- get('uuid'),
16
- getToken,
17
- token => ({
18
- Authorization: `Token ${token}`,
19
- 'Content-Type': 'application/json',
20
- }),
21
- ]),
22
- body: pipe([
23
- get('body'),
24
- JSON.stringify,
25
- ]),
26
- }),
27
- payload => fetch(route, payload),
28
- getJSON,
29
- ])
30
-
31
- postRequestWithAuth('http://localhost:8001/myRoute')({
32
- uuid: 'ffda7b1c-fc6b-4949-98c4-e5cb86675f5f',
33
- body: { hello: 'world' },
34
- })
35
-
36
- // https://stackoverflow.com/questions/54852314/javascript-functional-programming-how-to-handle-fetch-for-pipes/61907662#61907662
@@ -1,96 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const {
4
- pipe, fork, tap, switchCase,
5
- map, filter, transform,
6
- and, not, eq, get,
7
- } = require('rubico')
8
-
9
- const identity = x => x
10
-
11
- // [person] => Map { person => (Set { person }) }
12
- const makeTracker = transform(
13
- map(fork([
14
- person => person,
15
- () => new Set(),
16
- ])),
17
- new Map(),
18
- )
19
-
20
- const db = new Map()
21
-
22
- const saveTracker = async tracker => { db.set('tracker', tracker) }
23
-
24
- const hasTracker = async () => db.has('tracker')
25
-
26
- const getTracker = async tracker => db.get('tracker')
27
-
28
- const isNotIn = set => x => !set.has(x)
29
-
30
- // { people, tracker } => { people, tracker, pairs }
31
- const algorithm = ({ people, tracker }) => {
32
- const matchedThisRound = new Set()
33
- return fork({
34
- people: identity,
35
- tracker: () => tracker,
36
- pairs: transform(
37
- pipe([
38
- filter(isNotIn(matchedThisRound)),
39
- map(person => {
40
- for (const other of people) {
41
- // console.log('person:other', `${person}:${other}`)
42
- if (other === person) continue
43
- if (tracker.get(person).has(other)) continue
44
- if (matchedThisRound.has(other)) continue
45
- tracker.get(person).add(other)
46
- tracker.get(other).add(person)
47
- matchedThisRound.add(person)
48
- matchedThisRound.add(other)
49
- return [person, other]
50
- }
51
- }),
52
- filter(Array.isArray),
53
- ]),
54
- [],
55
- )
56
- })(people)
57
- }
58
-
59
- // [person, person, person, person, ...] => [[person, person], [person, person], ...]
60
- const matchmake = pipe([
61
- fork({
62
- people: identity,
63
- tracker: switchCase([
64
- hasTracker, getTracker,
65
- makeTracker,
66
- ]),
67
- }),
68
- algorithm,
69
- tap(pipe([get('tracker'), saveTracker])),
70
- ])
71
-
72
- const didEveryoneMatch = (tracker, people) => {
73
- for (const [, set] of tracker) {
74
- if (set.size < people.length - 1) return false // 1 for yourself
75
- }
76
- return true
77
- }
78
-
79
- const makePeople = number => Array.from((function*() {
80
- for (let i = 0; i < number; i++) yield `${i + 1}`
81
- })())
82
-
83
- const main = async () => {
84
- const people = makePeople(99)
85
- console.log('people', people)
86
- let i = 0
87
- while (true) {
88
- const round = await matchmake(people)
89
- const { tracker, pairs } = round
90
- console.log('round', i, pairs)
91
- if (didEveryoneMatch(tracker, people)) break
92
- i += 1
93
- }
94
- }
95
-
96
- main()
@@ -1,36 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const { pipe, tap, map, transform } = require('..')
4
- const request = require('request')
5
-
6
- const urls = [
7
- 'https://firebasestorage.googleapis.com/v0/b/moberra-tire-api.appspot.com/o/tire-data-eco%2Fforceum.json?alt=media&token=ed9db67c-d744-414f-8812-21cfbba63447',
8
- 'https://firebasestorage.googleapis.com/v0/b/moberra-tire-api.appspot.com/o/tire-data-eco%2Fgood-year.json?alt=media&token=1131b553-e2e5-4ff6-87cb-f346e57e389e',
9
- 'https://firebasestorage.googleapis.com/v0/b/moberra-tire-api.appspot.com/o/tire-data-eco%2Fgt-radial.json?alt=media&token=d2ba3f51-cef7-494e-8006-61d321d677cd',
10
- 'https://firebasestorage.googleapis.com/v0/b/moberra-tire-api.appspot.com/o/tire-data-eco%2Fkpatos.json?alt=media&token=75743c44-1521-4ff4-8133-e56a474f7c3e',
11
- 'https://firebasestorage.googleapis.com/v0/b/moberra-tire-api.appspot.com/o/tire-data-eco%2Fland-spider.json?alt=media&token=22a3aa7b-18a9-4bd1-b34b-5ae48cadbc55',
12
- 'https://firebasestorage.googleapis.com/v0/b/moberra-tire-api.appspot.com/o/tire-data-eco%2Fleao-tires.json?alt=media&token=84dcc7f8-de32-46a9-9aae-854639772975',
13
- 'https://firebasestorage.googleapis.com/v0/b/moberra-tire-api.appspot.com/o/tire-data-eco%2Fwanli.json?alt=media&token=4bb13f3a-5d9a-4c2d-b558-964ee996a534',
14
- 'https://firebasestorage.googleapis.com/v0/b/moberra-tire-api.appspot.com/o/tire-data-eco%2Fzeta.json?alt=media&token=c04f973c-2577-4f06-805e-68e46480e9ae'
15
- ]
16
-
17
- const getFile = url => new Promise((resolve, reject) => {
18
- request({
19
- uri: url,
20
- method: "GET",
21
- gzip: true,
22
- qs: { format: "json" },
23
- }, (err, resp, body) => err ? reject(err) : resolve(body))
24
- })
25
-
26
- // urls => tire_json_data
27
- const download_tire_json_from_firebase = map(getFile)
28
-
29
- const main = async () => {
30
- const data = await transform(pipe([
31
- map(getFile),
32
- tap(console.log),
33
- ]), [])(urls)
34
- }
35
-
36
- main()
@@ -1,85 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const { pipe, fork, map, reduce, get } = require('..')
4
-
5
- const data = { "Office": {
6
- "California" : {
7
- "Contract1": {
8
- 1: {Price: 1000, Count: 5}, 2: {Price: 2000, Count: 11},
9
- 3: {Price: 3000, Count: 3}, 4: {Price: 2000, Count: 1},
10
- 5: {Price: 1000, Count: 5}, 6: {Price: 2000, Count: 11},
11
- 7: {Price: 3000, Count: 3}, 8: {Price: 2000, Count: 1},
12
- 9: {Price: 1000, Count: 5}, 10: {Price: 2000, Count: 11},
13
- 11: {Price: 3000, Count: 3}, 12: {Price: 2000, Count: 1},
14
- },
15
- "Contract2": {
16
- 1: {Price: 7000, Count: 6}, 2: {Price: 1000, Count: 4},
17
- 3: {Price: 67000, Count: 6}, 4: {Price: 500, Count: 2},
18
- 5: {Price: 7000, Count: 6}, 6: {Price: 1000, Count: 4},
19
- 7: {Price: 67000, Count: 6}, 8: {Price: 500, Count: 2},
20
- 9: {Price: 7000, Count: 6}, 10: {Price: 1000, Count: 4},
21
- 11: {Price: 67000, Count: 6}, 12: {Price: 500, Count: 2},
22
- },
23
- "Contract3": {
24
- 1: {Price: 4000, Count: 4}, 2: {Price: 4000, Count: 1},
25
- 3: {Price: 5000, Count: 12}, 4: {Price: 5000, Count: 2},
26
- 5: {Price: 4000, Count: 4}, 6: {Price: 4000, Count: 1},
27
- 7: {Price: 5000, Count: 12}, 8: {Price: 5000, Count: 2},
28
- 9: {Price: 4000, Count: 4}, 10: {Price: 4000, Count: 1},
29
- 11: {Price: 5000, Count: 12}, 12: {Price: 5000, Count: 2},
30
- }
31
- },
32
- "North Carolina" : {
33
- "Contract1": {
34
- 1: {Price: 7000, Count: 4}, 2: {Price: 7000, Count: 4},
35
- 3: {Price: 7000, Count: 4}, 4: {Price: 7000, Count: 4},
36
- 5: {Price: 7000, Count: 4}, 6: {Price: 7000, Count: 4},
37
- 7: {Price: 7000, Count: 4}, 8: {Price: 7000, Count: 4},
38
- 9: {Price: 7000, Count: 4}, 10: {Price: 7000, Count: 4},
39
- 11: {Price: 7000, Count: 4}, 12: {Price: 7000, Count: 4},
40
- },
41
- "Contract2": {
42
- 1: {Price: 6000, Count: 4}, 2: {Price: 2000, Count: 10},
43
- 3: {Price: 3000, Count: 3}, 4: {Price: 2000, Count: 3},
44
- 5: {Price: 6000, Count: 4}, 6: {Price: 2000, Count: 10},
45
- 7: {Price: 3000, Count: 3}, 8: {Price: 2000, Count: 3},
46
- 9: {Price: 6000, Count: 4}, 10: {Price: 2000, Count: 10},
47
- 11: {Price: 3000, Count: 3}, 12: {Price: 2000, Count: 3},
48
- },
49
- "Contract3": {
50
- 1: {Price: 4000, Count: 5}, 2: {Price: 2000, Count: 4},
51
- 3: {Price: 4000, Count: 3}, 4: {Price: 2000, Count: 4},
52
- 5: {Price: 4000, Count: 5}, 6: {Price: 2000, Count: 4},
53
- 7: {Price: 4000, Count: 3}, 8: {Price: 2000, Count: 4},
54
- 9: {Price: 4000, Count: 5}, 10: {Price: 2000, Count: 4},
55
- 11: {Price: 4000, Count: 3}, 12: {Price: 2000, Count: 4},
56
- },
57
- },
58
- } }
59
-
60
- const addContracts = (total, contract) => ({
61
- Price: total.Price + contract.Price,
62
- Count: total.Count + contract.Count,
63
- })
64
-
65
- const monthNumbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
66
-
67
- const sumMonthsToQuarters = contract => {
68
- const quartered = {
69
- 1: { Price: 0, Count: 0 },
70
- 2: { Price: 0, Count: 0 },
71
- 3: { Price: 0, Count: 0 },
72
- 4: { Price: 0, Count: 0 },
73
- }
74
- for (const monthNum of monthNumbers) {
75
- const quarterNum = Math.ceil(monthNum / 3)
76
- quartered[quarterNum] = addContracts(quartered[quarterNum], contract[monthNum])
77
- }
78
- return quartered
79
- }
80
-
81
- const x = map(map(map(sumMonthsToQuarters)))(data)
82
-
83
- console.log(JSON.stringify(x))
84
-
85
- // https://stackoverflow.com/questions/62103014/reducing-a-nested-object-in-javascript/62110877
@@ -1,16 +0,0 @@
1
- #!/usr/bin/env -S deno run
2
-
3
- import { map, filter, pipe } from '../rubico.js'
4
-
5
- const isOdd = (x: number): boolean => x % 2 === 1
6
-
7
- const square = (x: number): number => x ** 2
8
-
9
- const squaredOdds = pipe([
10
- filter(isOdd),
11
- map(square),
12
- ])
13
-
14
- console.log(
15
- squaredOdds([1, 2, 3, 4, 5]), // [1, 9, 25]
16
- )
@@ -1,67 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // from https://stackoverflow.com/questions/62074394/filter-array-and-get-max-values-of-nested-array-of-each-set-of-objects-in-javas/62077548#62077548
4
-
5
- const { transform, pipe, assign, tap, map, filter, reduce, get, gt } = require('rubico')
6
-
7
- const data = [
8
- {
9
- product: 'laptop',
10
- count_buyer: 3,
11
- buyers: [
12
- { name: 'Vins', purchase_amount: 27 },
13
- { name: 'Jan', purchase_amount: 38 },
14
- { name: 'Alex', purchase_amount: 80 },
15
- ],
16
- },
17
- {
18
- product: 'televisor',
19
- count_buyer: 2,
20
- buyers: [
21
- { name: 'Carl', purchase_amount: 25 },
22
- { name: 'Digi', purchase_amount: 40 }
23
- ],
24
- },
25
- {
26
- product: 'ropa varon',
27
- count_buyer: 0,
28
- buyers: [],
29
- }
30
- ];
31
-
32
- const getMaxBuyer = (y, xi) => y.purchase_amount > xi.purchase_amount ? y : xi
33
-
34
- const getProductsWithMaxBuyer = pipe([
35
- filter(gt(get('buyers.length'), 0)), // filter for products with buyers.length > 0
36
- tap(x => console.log('tap', x)),
37
- map(assign({
38
- buyers: pipe([
39
- get('buyers'), // product => product.buyers
40
- reduce(getMaxBuyer), // buyers => [max_buyer]
41
- ]),
42
- })),
43
- tap(x => console.log('tap', x)),
44
- ])
45
-
46
- console.log('intermediate arrays, should see 2 arrays')
47
-
48
- getProductsWithMaxBuyer(data) /* > [
49
- {
50
- product: 'laptop',
51
- count_buyer: 3,
52
- buyers: { name: 'Alex', purchase_amount: 80 }
53
- },
54
- {
55
- product: 'televisor',
56
- count_buyer: 2,
57
- buyers: { name: 'Digi', purchase_amount: 40 }
58
- }
59
- ]
60
- */
61
-
62
- console.log('one pass, should see 4 products individually')
63
-
64
- transform(
65
- getProductsWithMaxBuyer,
66
- [],
67
- )(data)
@@ -1,31 +0,0 @@
1
- const { pipe, map, transform } = require('rubico')
2
- const fetch = require('node-fetch')
3
-
4
- const toTodosUrl = id => 'https://jsonplaceholder.typicode.com/todos/' + id
5
-
6
- const fetchedToJson = fetched => fetched.json()
7
-
8
- const fetchTodo = pipe([
9
- toTodosUrl,
10
- fetch,
11
- fetchedToJson,
12
- ])
13
-
14
- const Stdout = {
15
- concat(...args) {
16
- console.log(...args)
17
- return this
18
- }
19
- }
20
-
21
- const todoIDsRange = function* (from, to) {
22
- for (let id = from; id <= to; id++) {
23
- yield id
24
- }
25
- }
26
-
27
- const logTodosRange = transform(
28
- map(fetchTodo), Stdout,
29
- )(todoIDsRange)
30
-
31
- logTodosRange(1, 100)
@@ -1,19 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const { pipe, map, transform } = require('..')
4
-
5
- const square = number => number ** 2
6
-
7
- const toString = value => value.toString()
8
-
9
- const randomInt = () => Math.ceil(Math.random() * 100)
10
-
11
- const streamRandomInts = async function* () {
12
- while (true) {
13
- yield randomInt()
14
- }
15
- }
16
-
17
- transform(
18
- map(pipe([square, toString])), process.stdout,
19
- )(streamRandomInts())
@@ -1,277 +0,0 @@
1
- /**
2
- * @name callChain
3
- *
4
- * @synopsis
5
- * Monad = { chain: function }
6
- *
7
- * callChain(monad Monad, resolver)
8
- const callChain = (monad, resolver) => monad.chain(resolver)
9
- */
10
-
11
- /**
12
- * @name arrayPushIf
13
- *
14
- * @synopsis
15
- * arrayPushIf(predicate, any=>boolean, array Array, item any) -> ()
16
- */
17
- const arrayPushIf = function (predicate, array, item) {
18
- if (predicate(item)) {
19
- array.push(item)
20
- }
21
- }
22
-
23
- /**
24
- * @name forEachReduceConcurrent
25
- *
26
- * @synopsis
27
- * forEachReduceConcurrent(
28
- * collection { forEach: function },
29
- * reducer (any, T)=>Promise|any,
30
- * result any,
31
- * ) -> Promise|result
32
- */
33
- const forEachReduceConcurrent = function (collection, reducer, result) {
34
- const promises = [],
35
- getResult = () => result
36
- collection.forEach(funcConcatSync(
37
- curry2(reducer, result, __),
38
- curry3(arrayPushIf, isPromise, promises, __)))
39
-
40
- /*
41
- collection.forEach([
42
- tap(item => console.log('heyo', reducer, result, item)),
43
- curry2(reducer, result, __),
44
- curry3(arrayPushIf, isPromise, promises, __),
45
- ].reduce(funcConcatSync))
46
- */
47
-
48
- return promises.length == 0
49
- ? result
50
- : promiseAll(promises).then(getResult)
51
- }
52
-
53
- /**
54
- * @name iterableReduceConcurrent
55
- *
56
- * @synopsis
57
- * iterableReduceConcurrent(
58
- * iterable { [Symbol.iterator]: function },
59
- * reducer (any, T)=>Promise|any,
60
- * result any,
61
- * ) -> Promise|result
62
- */
63
- const iterableReduceConcurrent = function (iterable, reducer, result) {
64
- const promises = [],
65
- getResult = () => result,
66
- pipeline = funcConcatSync(
67
- curry2(reducer, result, __),
68
- curry3(arrayPushIf, isPromise, promises, __))
69
-
70
- for (const item of iterable) {
71
- pipeline(item)
72
- }
73
- return promises.length == 0
74
- ? result
75
- : promiseAll(promises).then(getResult)
76
- }
77
-
78
- /**
79
- * @name asyncIterableReduceConcurrent
80
- *
81
- * @synopsis
82
- * asyncIterableReduceConcurrent(
83
- * asyncIterable { [Symbol.iterator]: function },
84
- * reducer (any, T)=>Promise|any,
85
- * result any,
86
- * ) -> Promise|result
87
- */
88
- const asyncIterableReduceConcurrent = async function (asyncIterable, reducer, result) {
89
- const promises = [],
90
- getResult = () => result,
91
- pipeline = funcConcatSync(
92
- curry2(reducer, result, __),
93
- curry3(arrayPushIf, isPromise, promises, __))
94
-
95
- for await (const item of asyncIterable) {
96
- pipeline(item)
97
- }
98
- return promises.length == 0
99
- ? result
100
- : promiseAll(promises).then(getResult)
101
- }
102
-
103
- /**
104
- * @name objectReduceConcurrent
105
- *
106
- * @synopsis
107
- * objectReduceConcurrent(
108
- * object Object,
109
- * reducer (any, T)=>Promise|any,
110
- * result any,
111
- * ) -> Promise|result
112
- *
113
- * @related objectFlatMap
114
- */
115
- const objectReduceConcurrent = function (object, reducer, result) {
116
- const promises = [],
117
- getResult = () => result,
118
- pipeline = funcConcatSync(
119
- curry2(reducer, result, __),
120
- curry3(arrayPushIf, isPromise, promises, __))
121
-
122
- for (const key in object) {
123
- pipeline(object[key])
124
- }
125
- return promises.length == 0
126
- ? result
127
- : promiseAll(promises).then(getResult)
128
- }
129
-
130
- /**
131
- * @name getArg1
132
- *
133
- * @synopsis
134
- * getArg1(arg0 any, arg1 any) -> arg1
135
- */
136
- const getArg1 = function (arg0, arg1) {
137
- return arg1
138
- }
139
-
140
- /**
141
- * @name foldableReduceConcurrent
142
- *
143
- * @synopsis
144
- * foldableReduceConcurrent(
145
- * foldable { reduce: function },
146
- * reducer (any, T)=>Promise|any,
147
- * result any,
148
- * ) -> Promise|result
149
- */
150
- const foldableReduceConcurrent = function (foldable, reducer, result) {
151
- const promises = [],
152
- getResult = () => result,
153
- pipeline = [
154
- getArg1,
155
- curry2(reducer, result, __),
156
- curry3(arrayPushIf, isPromise, promises, __),
157
- ].reduce(funcConcatSync)
158
-
159
- foldable.reduce(tapSync(pipeline), null)
160
- return promises.length == 0
161
- ? result
162
- : promiseAll(promises).then(getResult)
163
- }
164
-
165
- /**
166
- * @name tacitGenericReduceConcurrent
167
- *
168
- * @synopsis
169
- * any -> T
170
- *
171
- * tacitGenericReduceConcurrent(
172
- * reducer (any, T)=>any,
173
- * result any,
174
- * ) -> reducing ...any=>result
175
- */
176
- const tacitGenericReduceConcurrent = (
177
- reducer, result,
178
- ) => function reducing(...args) {
179
- return genericReduceConcurrent(args, reducer, result)
180
- }
181
-
182
- /**
183
- * @name genericReduceConcurrent
184
- *
185
- * @synopsis
186
- * genericReduceConcurrent(
187
- * args Array,
188
- * reducer function,
189
- * result any,
190
- * ) -> result
191
- *
192
- * @related
193
- * genericReduce
194
- *
195
- * @NOTE
196
- * concurrency is only possible because result is never reassigned. in that regard, `result` is required.
197
- */
198
- const genericReduceConcurrent = function (args, reducer, result) {
199
- const collection = args[0]
200
- if (collection == null) {
201
- reducer(result, collection)
202
- return result
203
- }
204
- if (typeof collection.forEach == 'function') {
205
- return forEachReduceConcurrent(collection, reducer, result)
206
- }
207
- if (typeof collection[symbolIterator] == 'function') {
208
- return iterableReduceConcurrent(collection, reducer, result)
209
- }
210
- if (typeof collection[symbolAsyncIterator] == 'function') {
211
- return asyncIterableReduceConcurrent(collection, reducer, result)
212
- }
213
- if (typeof collection.reduce == 'function') {
214
- return foldableReduceConcurrent(collection, reducer, result)
215
- }
216
- if (typeof collection.chain == 'function') {
217
- return collection.chain(curry2(reducer, result, __))
218
- }
219
- if (typeof collection.flatMap == 'function') {
220
- return collection.flatMap(curry2(reducer, result, __))
221
- }
222
- if (collection.constructor == Object) {
223
- return objectReduceConcurrent(collection, reducer, result)
224
- }
225
- reducer(result, collection)
226
- return result
227
- }
228
-
229
- /**
230
- * @name flatteningTransducerConcurrent
231
- *
232
- * @synopsis
233
- * flatteningTransducerConcurrent(concat Reducer) -> flatteningReducer Reducer
234
- *
235
- * DuplexStream = { read: function, write: function }
236
- *
237
- * Monad = Array|String|Set
238
- * |TypedArray|DuplexStream|Iterator|AsyncIterator
239
- * |{ chain: function }|{ flatMap: function }|Object
240
- *
241
- * Foldable = Iterable|AsyncIterable|{ reduce: function }
242
- *
243
- * FlatteningReducer<T> = (any, T)=>Promise|Monad|Foldable|any
244
- *
245
- * Reducer<T> = (any, T)=>Promise|any
246
- *
247
- * flatteningTransducerConcurrent(concat Reducer) -> flatteningReducer FlatteningReducer
248
- *
249
- * @execution concurrent
250
- */
251
- const flatteningTransducerConcurrent = concat => function flatteningReducer(
252
- result, item,
253
- ) {
254
- return genericReduceConcurrent([item], concat, result)
255
- }
256
-
257
- /**
258
- * @name objectMapToArray
259
- *
260
- * @synopsis
261
- * objectMapToArray(
262
- * object Object, mapper function,
263
- * ) -> Promise|Array
264
- *
265
- * @note order not guaranteed
266
- */
267
- const objectMapToArray = function (object, mapper) {
268
- const result = []
269
- let isAsync = false
270
-
271
- for (const key in object) {
272
- const resultItem = mapper(object[key])
273
- if (isPromise(resultItem)) isAsync = true
274
- result.push(resultItem)
275
- }
276
- return isAsync ? promiseAll(result) : result
277
- }