rubico 2.10.0 → 2.12.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 (362) hide show
  1. package/README.md +16 -20
  2. package/Transducer.js +37 -58
  3. package/__.js +3 -3
  4. package/_internal/FilteringAsyncIterator.js +74 -23
  5. package/always.js +4 -4
  6. package/and.js +34 -26
  7. package/assign.js +2 -2
  8. package/compose.js +1 -0
  9. package/curry.js +48 -28
  10. package/dist/Transducer.es.js +1 -1
  11. package/dist/Transducer.es.min.js +1 -1
  12. package/dist/Transducer.js +1 -1
  13. package/dist/Transducer.min.js +1 -1
  14. package/dist/Transducer.mjs +1 -1
  15. package/dist/__.es.js +1 -1
  16. package/dist/__.es.min.js +1 -1
  17. package/dist/__.js +1 -1
  18. package/dist/__.min.js +1 -1
  19. package/dist/__.mjs +1 -1
  20. package/dist/all.es.js +1 -1
  21. package/dist/all.es.min.js +1 -1
  22. package/dist/all.js +1 -1
  23. package/dist/all.min.js +1 -1
  24. package/dist/all.mjs +1 -1
  25. package/dist/always.es.js +1 -1
  26. package/dist/always.es.min.js +1 -1
  27. package/dist/always.js +1 -1
  28. package/dist/always.min.js +1 -1
  29. package/dist/always.mjs +1 -1
  30. package/dist/and.es.js +1 -1
  31. package/dist/and.es.min.js +1 -1
  32. package/dist/and.js +1 -1
  33. package/dist/and.min.js +1 -1
  34. package/dist/and.mjs +1 -1
  35. package/dist/assign.es.js +1 -1
  36. package/dist/assign.es.min.js +1 -1
  37. package/dist/assign.js +1 -1
  38. package/dist/assign.min.js +1 -1
  39. package/dist/assign.mjs +1 -1
  40. package/dist/compose.es.js +1 -1
  41. package/dist/compose.es.min.js +1 -1
  42. package/dist/compose.js +1 -1
  43. package/dist/compose.min.js +1 -1
  44. package/dist/compose.mjs +1 -1
  45. package/dist/curry.es.js +1 -1
  46. package/dist/curry.es.min.js +1 -1
  47. package/dist/curry.js +1 -1
  48. package/dist/curry.min.js +1 -1
  49. package/dist/curry.mjs +1 -1
  50. package/dist/eq.es.js +1 -1
  51. package/dist/eq.es.min.js +1 -1
  52. package/dist/eq.js +1 -1
  53. package/dist/eq.min.js +1 -1
  54. package/dist/eq.mjs +1 -1
  55. package/dist/every.es.js +1 -1
  56. package/dist/every.es.min.js +1 -1
  57. package/dist/every.js +1 -1
  58. package/dist/every.min.js +1 -1
  59. package/dist/every.mjs +1 -1
  60. package/dist/filter.es.js +113 -19
  61. package/dist/filter.es.min.js +2 -2
  62. package/dist/filter.js +113 -19
  63. package/dist/filter.min.js +2 -2
  64. package/dist/filter.mjs +113 -19
  65. package/dist/flatMap.es.js +1 -1
  66. package/dist/flatMap.es.min.js +1 -1
  67. package/dist/flatMap.js +1 -1
  68. package/dist/flatMap.min.js +1 -1
  69. package/dist/flatMap.mjs +1 -1
  70. package/dist/forEach.es.js +1 -1
  71. package/dist/forEach.es.min.js +1 -1
  72. package/dist/forEach.js +1 -1
  73. package/dist/forEach.min.js +1 -1
  74. package/dist/forEach.mjs +1 -1
  75. package/dist/get.es.js +1 -1
  76. package/dist/get.es.min.js +1 -1
  77. package/dist/get.js +1 -1
  78. package/dist/get.min.js +1 -1
  79. package/dist/get.mjs +1 -1
  80. package/dist/gt.es.js +1 -1
  81. package/dist/gt.es.min.js +1 -1
  82. package/dist/gt.js +1 -1
  83. package/dist/gt.min.js +1 -1
  84. package/dist/gt.mjs +1 -1
  85. package/dist/gte.es.js +1 -1
  86. package/dist/gte.es.min.js +1 -1
  87. package/dist/gte.js +1 -1
  88. package/dist/gte.min.js +1 -1
  89. package/dist/gte.mjs +1 -1
  90. package/dist/lt.es.js +1 -1
  91. package/dist/lt.es.min.js +1 -1
  92. package/dist/lt.js +1 -1
  93. package/dist/lt.min.js +1 -1
  94. package/dist/lt.mjs +1 -1
  95. package/dist/lte.es.js +1 -1
  96. package/dist/lte.es.min.js +1 -1
  97. package/dist/lte.js +1 -1
  98. package/dist/lte.min.js +1 -1
  99. package/dist/lte.mjs +1 -1
  100. package/dist/map.es.js +1 -1
  101. package/dist/map.es.min.js +1 -1
  102. package/dist/map.js +1 -1
  103. package/dist/map.min.js +1 -1
  104. package/dist/map.mjs +1 -1
  105. package/dist/not.es.js +1 -1
  106. package/dist/not.es.min.js +1 -1
  107. package/dist/not.js +1 -1
  108. package/dist/not.min.js +1 -1
  109. package/dist/not.mjs +1 -1
  110. package/dist/omit.es.js +1 -1
  111. package/dist/omit.es.min.js +1 -1
  112. package/dist/omit.js +1 -1
  113. package/dist/omit.min.js +1 -1
  114. package/dist/omit.mjs +1 -1
  115. package/dist/or.es.js +1 -1
  116. package/dist/or.es.min.js +1 -1
  117. package/dist/or.js +1 -1
  118. package/dist/or.min.js +1 -1
  119. package/dist/or.mjs +1 -1
  120. package/dist/pick.es.js +1 -1
  121. package/dist/pick.es.min.js +1 -1
  122. package/dist/pick.js +1 -1
  123. package/dist/pick.min.js +1 -1
  124. package/dist/pick.mjs +1 -1
  125. package/dist/pipe.es.js +1 -1
  126. package/dist/pipe.es.min.js +1 -1
  127. package/dist/pipe.js +1 -1
  128. package/dist/pipe.min.js +1 -1
  129. package/dist/pipe.mjs +1 -1
  130. package/dist/reduce.es.js +1 -1
  131. package/dist/reduce.es.min.js +1 -1
  132. package/dist/reduce.js +1 -1
  133. package/dist/reduce.min.js +1 -1
  134. package/dist/reduce.mjs +1 -1
  135. package/dist/rubico.es.js +57 -19
  136. package/dist/rubico.es.min.js +2 -2
  137. package/dist/rubico.global.js +57 -19
  138. package/dist/rubico.global.min.js +2 -2
  139. package/dist/rubico.js +57 -19
  140. package/dist/rubico.min.js +2 -2
  141. package/dist/rubico.mjs +57 -19
  142. package/dist/set.es.js +1 -1
  143. package/dist/set.es.min.js +1 -1
  144. package/dist/set.js +1 -1
  145. package/dist/set.min.js +1 -1
  146. package/dist/set.mjs +1 -1
  147. package/dist/some.es.js +1 -1
  148. package/dist/some.es.min.js +1 -1
  149. package/dist/some.js +1 -1
  150. package/dist/some.min.js +1 -1
  151. package/dist/some.mjs +1 -1
  152. package/dist/switchCase.es.js +1 -1
  153. package/dist/switchCase.es.min.js +1 -1
  154. package/dist/switchCase.js +1 -1
  155. package/dist/switchCase.min.js +1 -1
  156. package/dist/switchCase.mjs +1 -1
  157. package/dist/tap.es.js +1 -1
  158. package/dist/tap.es.min.js +1 -1
  159. package/dist/tap.js +1 -1
  160. package/dist/tap.min.js +1 -1
  161. package/dist/tap.mjs +1 -1
  162. package/dist/thunkify.es.js +1 -1
  163. package/dist/thunkify.es.min.js +1 -1
  164. package/dist/thunkify.js +1 -1
  165. package/dist/thunkify.min.js +1 -1
  166. package/dist/thunkify.mjs +1 -1
  167. package/dist/transform.es.js +1 -1
  168. package/dist/transform.es.min.js +1 -1
  169. package/dist/transform.js +1 -1
  170. package/dist/transform.min.js +1 -1
  171. package/dist/transform.mjs +1 -1
  172. package/dist/tryCatch.es.js +1 -1
  173. package/dist/tryCatch.es.min.js +1 -1
  174. package/dist/tryCatch.js +1 -1
  175. package/dist/tryCatch.min.js +1 -1
  176. package/dist/tryCatch.mjs +1 -1
  177. package/dist/x/append.es.js +1 -1
  178. package/dist/x/append.es.min.js +1 -1
  179. package/dist/x/append.js +1 -1
  180. package/dist/x/append.min.js +1 -1
  181. package/dist/x/append.mjs +1 -1
  182. package/dist/x/callProp.es.js +1 -1
  183. package/dist/x/callProp.es.min.js +1 -1
  184. package/dist/x/callProp.js +1 -1
  185. package/dist/x/callProp.min.js +1 -1
  186. package/dist/x/callProp.mjs +1 -1
  187. package/dist/x/defaultsDeep.es.js +1 -1
  188. package/dist/x/defaultsDeep.es.min.js +1 -1
  189. package/dist/x/defaultsDeep.js +1 -1
  190. package/dist/x/defaultsDeep.min.js +1 -1
  191. package/dist/x/defaultsDeep.mjs +1 -1
  192. package/dist/x/differenceWith.es.js +1 -1
  193. package/dist/x/differenceWith.es.min.js +1 -1
  194. package/dist/x/differenceWith.js +1 -1
  195. package/dist/x/differenceWith.min.js +1 -1
  196. package/dist/x/differenceWith.mjs +1 -1
  197. package/dist/x/filterOut.es.js +113 -19
  198. package/dist/x/filterOut.es.min.js +2 -2
  199. package/dist/x/filterOut.js +113 -19
  200. package/dist/x/filterOut.min.js +2 -2
  201. package/dist/x/filterOut.mjs +113 -19
  202. package/dist/x/find.es.js +1 -1
  203. package/dist/x/find.es.min.js +1 -1
  204. package/dist/x/find.js +1 -1
  205. package/dist/x/find.min.js +1 -1
  206. package/dist/x/find.mjs +1 -1
  207. package/dist/x/findIndex.es.js +1 -1
  208. package/dist/x/findIndex.es.min.js +1 -1
  209. package/dist/x/findIndex.js +1 -1
  210. package/dist/x/findIndex.min.js +1 -1
  211. package/dist/x/findIndex.mjs +1 -1
  212. package/dist/x/first.es.js +1 -1
  213. package/dist/x/first.es.min.js +1 -1
  214. package/dist/x/first.js +1 -1
  215. package/dist/x/first.min.js +1 -1
  216. package/dist/x/first.mjs +1 -1
  217. package/dist/x/flatten.es.js +1 -1
  218. package/dist/x/flatten.es.min.js +1 -1
  219. package/dist/x/flatten.js +1 -1
  220. package/dist/x/flatten.min.js +1 -1
  221. package/dist/x/flatten.mjs +1 -1
  222. package/dist/x/groupBy.es.js +1 -1
  223. package/dist/x/groupBy.es.min.js +1 -1
  224. package/dist/x/groupBy.js +1 -1
  225. package/dist/x/groupBy.min.js +1 -1
  226. package/dist/x/groupBy.mjs +1 -1
  227. package/dist/x/has.es.js +1 -1
  228. package/dist/x/has.es.min.js +1 -1
  229. package/dist/x/has.js +1 -1
  230. package/dist/x/has.min.js +1 -1
  231. package/dist/x/has.mjs +1 -1
  232. package/dist/x/identity.es.js +1 -1
  233. package/dist/x/identity.es.min.js +1 -1
  234. package/dist/x/identity.js +1 -1
  235. package/dist/x/identity.min.js +1 -1
  236. package/dist/x/identity.mjs +1 -1
  237. package/dist/x/includes.es.js +1 -1
  238. package/dist/x/includes.es.min.js +1 -1
  239. package/dist/x/includes.js +1 -1
  240. package/dist/x/includes.min.js +1 -1
  241. package/dist/x/includes.mjs +1 -1
  242. package/dist/x/isDeepEqual.es.js +1 -1
  243. package/dist/x/isDeepEqual.es.min.js +1 -1
  244. package/dist/x/isDeepEqual.js +1 -1
  245. package/dist/x/isDeepEqual.min.js +1 -1
  246. package/dist/x/isDeepEqual.mjs +1 -1
  247. package/dist/x/isEmpty.es.js +1 -1
  248. package/dist/x/isEmpty.es.min.js +1 -1
  249. package/dist/x/isEmpty.js +1 -1
  250. package/dist/x/isEmpty.min.js +1 -1
  251. package/dist/x/isEmpty.mjs +1 -1
  252. package/dist/x/isEqual.es.js +1 -1
  253. package/dist/x/isEqual.es.min.js +1 -1
  254. package/dist/x/isEqual.js +1 -1
  255. package/dist/x/isEqual.min.js +1 -1
  256. package/dist/x/isEqual.mjs +1 -1
  257. package/dist/x/isFunction.es.js +1 -1
  258. package/dist/x/isFunction.es.min.js +1 -1
  259. package/dist/x/isFunction.js +1 -1
  260. package/dist/x/isFunction.min.js +1 -1
  261. package/dist/x/isFunction.mjs +1 -1
  262. package/dist/x/isIn.es.js +1 -1
  263. package/dist/x/isIn.es.min.js +1 -1
  264. package/dist/x/isIn.js +1 -1
  265. package/dist/x/isIn.min.js +1 -1
  266. package/dist/x/isIn.mjs +1 -1
  267. package/dist/x/isObject.es.js +1 -1
  268. package/dist/x/isObject.es.min.js +1 -1
  269. package/dist/x/isObject.js +1 -1
  270. package/dist/x/isObject.min.js +1 -1
  271. package/dist/x/isObject.mjs +1 -1
  272. package/dist/x/isString.es.js +1 -1
  273. package/dist/x/isString.es.min.js +1 -1
  274. package/dist/x/isString.js +1 -1
  275. package/dist/x/isString.min.js +1 -1
  276. package/dist/x/isString.mjs +1 -1
  277. package/dist/x/keys.es.js +1 -1
  278. package/dist/x/keys.es.min.js +1 -1
  279. package/dist/x/keys.js +1 -1
  280. package/dist/x/keys.min.js +1 -1
  281. package/dist/x/keys.mjs +1 -1
  282. package/dist/x/last.es.js +1 -1
  283. package/dist/x/last.es.min.js +1 -1
  284. package/dist/x/last.js +1 -1
  285. package/dist/x/last.min.js +1 -1
  286. package/dist/x/last.mjs +1 -1
  287. package/dist/x/maxBy.es.js +1 -1
  288. package/dist/x/maxBy.es.min.js +1 -1
  289. package/dist/x/maxBy.js +1 -1
  290. package/dist/x/maxBy.min.js +1 -1
  291. package/dist/x/maxBy.mjs +1 -1
  292. package/dist/x/noop.es.js +1 -1
  293. package/dist/x/noop.es.min.js +1 -1
  294. package/dist/x/noop.js +1 -1
  295. package/dist/x/noop.min.js +1 -1
  296. package/dist/x/noop.mjs +1 -1
  297. package/dist/x/pluck.es.js +1 -1
  298. package/dist/x/pluck.es.min.js +1 -1
  299. package/dist/x/pluck.js +1 -1
  300. package/dist/x/pluck.min.js +1 -1
  301. package/dist/x/pluck.mjs +1 -1
  302. package/dist/x/prepend.es.js +1 -1
  303. package/dist/x/prepend.es.min.js +1 -1
  304. package/dist/x/prepend.js +1 -1
  305. package/dist/x/prepend.min.js +1 -1
  306. package/dist/x/prepend.mjs +1 -1
  307. package/dist/x/size.es.js +1 -1
  308. package/dist/x/size.es.min.js +1 -1
  309. package/dist/x/size.js +1 -1
  310. package/dist/x/size.min.js +1 -1
  311. package/dist/x/size.mjs +1 -1
  312. package/dist/x/trace.es.js +1 -1
  313. package/dist/x/trace.es.min.js +1 -1
  314. package/dist/x/trace.js +1 -1
  315. package/dist/x/trace.min.js +1 -1
  316. package/dist/x/trace.mjs +1 -1
  317. package/dist/x/unionWith.es.js +1 -1
  318. package/dist/x/unionWith.es.min.js +1 -1
  319. package/dist/x/unionWith.js +1 -1
  320. package/dist/x/unionWith.min.js +1 -1
  321. package/dist/x/unionWith.mjs +1 -1
  322. package/dist/x/uniq.es.js +1 -1
  323. package/dist/x/uniq.es.min.js +1 -1
  324. package/dist/x/uniq.js +1 -1
  325. package/dist/x/uniq.min.js +1 -1
  326. package/dist/x/uniq.mjs +1 -1
  327. package/dist/x/unless.es.js +1 -1
  328. package/dist/x/unless.es.min.js +1 -1
  329. package/dist/x/unless.js +1 -1
  330. package/dist/x/unless.min.js +1 -1
  331. package/dist/x/unless.mjs +1 -1
  332. package/dist/x/values.es.js +1 -1
  333. package/dist/x/values.es.min.js +1 -1
  334. package/dist/x/values.js +1 -1
  335. package/dist/x/values.min.js +1 -1
  336. package/dist/x/values.mjs +1 -1
  337. package/dist/x/when.es.js +1 -1
  338. package/dist/x/when.es.min.js +1 -1
  339. package/dist/x/when.js +1 -1
  340. package/dist/x/when.min.js +1 -1
  341. package/dist/x/when.mjs +1 -1
  342. package/eq.js +29 -30
  343. package/es.js +57 -19
  344. package/every.js +14 -20
  345. package/filter.js +48 -86
  346. package/flatMap.js +13 -13
  347. package/forEach.js +8 -8
  348. package/get.js +3 -3
  349. package/gt.js +18 -25
  350. package/gte.js +22 -29
  351. package/index.js +57 -19
  352. package/lt.js +33 -31
  353. package/lte.js +24 -31
  354. package/map.js +37 -41
  355. package/not.js +12 -17
  356. package/or.js +34 -26
  357. package/package.json +1 -1
  358. package/reduce.js +60 -67
  359. package/some.js +11 -34
  360. package/switchCase.js +3 -3
  361. package/thunkify.js +42 -12
  362. package/transform.js +57 -56
package/every.js CHANGED
@@ -51,18 +51,22 @@ const _every = function (collection, predicate) {
51
51
  * ```
52
52
  *
53
53
  * @description
54
- * Test a predicate concurrently across all elements of a foldable, returning true if all executions return true.
54
+ * Tests a predicate concurrently across all items of a foldable. Returns true if every item tests true by the predicate.
55
55
  *
56
56
  * ```javascript [playground]
57
57
  * const isOdd = number => number % 2 == 1
58
58
  *
59
- * console.log(
60
- * every([1, 2, 3, 4, 5], isOdd),
61
- * ) // false
59
+ * {
60
+ * const array = [1, 2, 3, 4, 5]
61
+ * const isEveryNumberOdd = every(array, isOdd)
62
+ * console.log(isEveryNumberOdd)
63
+ * }
62
64
  *
63
- * console.log(
64
- * every([1, 3, 5], isOdd),
65
- * ) // true
65
+ * {
66
+ * const array = [1, 3, 5]
67
+ * const isEveryNumberOdd = every(array, isOdd)
68
+ * console.log(isEveryNumberOdd)
69
+ * }
66
70
  * ```
67
71
  *
68
72
  * The following data types are considered to be foldables:
@@ -74,29 +78,19 @@ const _every = function (collection, predicate) {
74
78
  * * `object with .reduce method`
75
79
  * * `object`
76
80
  *
77
- * `every` works for async generators.
78
- *
79
- * ```javascript [playground]
80
- * const asyncNumbers = async function* () {
81
- * yield 1; yield 2; yield 3; yield 4; yield 5
82
- * }
83
- *
84
- * every(asyncNumbers(), async number => number < 6).then(console.log) // true
85
- * ```
86
- *
87
81
  * `every` supports a lazy interface for composability.
88
82
  *
89
83
  * ```javascript [playground]
90
84
  * pipe([1, 2, 3], [
91
85
  * every(number => number < 5),
92
- * console.log, // true
86
+ * console.log,
93
87
  * ])
94
88
  * ```
95
89
  *
96
- * Any promises passed in data argument position are resolved for their values before further execution.
90
+ * If the foldable is a promise, it is resolved for its value before further execution for the eager interface only.
97
91
  *
98
92
  * ```javascript [playground]
99
- * every(Promise.resolve([1, 2, 3, 4, 5]), n => n < 6).then(console.log) // true
93
+ * every(Promise.resolve([1, 2, 3, 4, 5]), n => n < 6).then(console.log)
100
94
  * ```
101
95
  *
102
96
  * See also:
package/filter.js CHANGED
@@ -96,14 +96,24 @@ const _filter = function (value, predicate) {
96
96
  * value any,
97
97
  * indexOrKey number|string|any,
98
98
  * filterable Filterable,
99
- * )=>(condition Promise|boolean)
99
+ * )=>(booleanResult Promise|boolean|any)
100
100
  *
101
- * filter(filterable Promise|Filterable, predicate SyncOrAsyncPredicate) -> result Promise|Filterable
102
- * filter(predicate SyncOrAsyncPredicate)(filterable Filterable) -> result Promise|Filterable
101
+ * filter(filterable Promise|Filterable, predicate SyncOrAsyncPredicate) -> filteredFilterable Promise|Filterable
102
+ * filter(predicate SyncOrAsyncPredicate)(filterable Filterable) -> filteredFilterable Promise|Filterable
103
103
  * ```
104
104
  *
105
105
  * @description
106
- * Filters out elements from a filterable. Returns a filterable of the same type. The order of the elements in the filterable is preserved.
106
+ * Filters out items from a filterable, returning a filtered filterable of the same type. The order of the items of the filterable is preserved.
107
+ *
108
+ * ```javascript [playground]
109
+ * const isOdd = number => number % 2 == 1
110
+ *
111
+ * const array = [1, 2, 3, 4, 5]
112
+ *
113
+ * const filteredArray = filter(array, isOdd)
114
+ *
115
+ * console.log(filteredArray)
116
+ * ```
107
117
  *
108
118
  * The following data types are considered to be filterables:
109
119
  * * `array`
@@ -114,12 +124,12 @@ const _filter = function (value, predicate) {
114
124
  * * `object with .filter method`
115
125
  * * `object`
116
126
  *
117
- * The filtering operation is defined by a given predicate function. The predicate function dictates whether a given element from the filterable should be included in the returned filterable.
127
+ * The filtering operation is defined by the predicate function, which determines whether a given item from the filterable should be included in the filtered filterable.
118
128
  *
119
129
  * ```javascript
120
- * const predicate = function (element) {
121
- * // condition is the boolean result of the predicate test on element
122
- * return condition
130
+ * const predicate = function (item) {
131
+ * // booleanResult is the boolean result of the predicate
132
+ * return booleanResult
123
133
  * }
124
134
  * ```
125
135
  *
@@ -127,142 +137,94 @@ const _filter = function (value, predicate) {
127
137
  *
128
138
  * If the filterable is an array:
129
139
  * ```coffeescript [specscript]
130
- * predicate(element any, index number, filt Array) -> condition Promise|boolean|any
140
+ * predicate(item any, index number, filterable Array) -> booleanResult Promise|boolean|any
131
141
  * ```
132
142
  *
133
143
  * If the filterable is a set:
134
144
  * ```coffeescript [specscript]
135
- * predicate(element any, element any, filt Set) -> condition Promise|boolean|any
145
+ * predicate(item any, item any, filterable Set) -> booleanResult Promise|boolean|any
136
146
  * ```
137
147
  *
138
148
  * If the filterable is a map:
139
149
  * ```coffeescript [specscript]
140
- * predicate(element any, key any, filt Map) -> condition Promise|boolean|any
150
+ * predicate(item any, key any, filterable Map) -> booleanResult Promise|boolean|any
141
151
  * ```
142
152
  *
143
153
  * If the filterable is a generator:
144
154
  * ```coffeescript [specscript]
145
- * predicate(element any) -> condition Promise|boolean|any
155
+ * predicate(item any) -> booleanResult Promise|boolean|any
146
156
  * ```
147
157
  *
148
158
  * If the filterable is an async generator:
149
159
  * ```coffeescript [specscript]
150
- * predicate(element any) -> condition Promise|boolean|any
160
+ * predicate(item any) -> booleanResult Promise|boolean|any
151
161
  * ```
152
162
  *
153
- * If the filterable is an object with a `.filter` method, the predicate function signature is defined externally.
154
- *
155
163
  * If the filterable is a plain object:
156
164
  * ```coffeescript [specscript]
157
- * predicate(element any, key string, filt Object) -> condition Promise|boolean|any
165
+ * predicate(item any, key string, filterable Object) -> booleanResult Promise|boolean|any
158
166
  * ```
159
167
  *
160
- * `filter` works for arrays.
161
- *
162
- * ```javascript [playground]
163
- * const isOdd = number => number % 2 == 1
164
- *
165
- * const array = [1, 2, 3, 4, 5]
168
+ * If the filterable is an object with a `.filter` method, the predicate function signature is defined externally.
166
169
  *
167
- * const result = filter(array, isOdd)
168
- * console.log(result) // [1, 3, 5]
169
- * ```
170
+ * If the filterable is a generator, the predicate function must be synchronous.
170
171
  *
171
- * If the predicate is asynchronous, the returned promise is concurrently resolved for its boolean condition before continuing with the filtering operation.
172
+ * If the predicate function is asynchronous, it is executed concurrently.
172
173
  *
173
174
  * ```javascript [playground]
174
175
  * const asyncIsOdd = async number => number % 2 == 1
175
176
  *
176
177
  * const array = [1, 2, 3, 4, 5]
177
178
  *
178
- * const promise = filter(array, asyncIsOdd)
179
- * promise.then(console.log) // [1, 3, 5]
180
- * ```
181
- *
182
- * `filter` applies the predicate function to just the values of an object.
179
+ * const result = await filter(array, asyncIsOdd)
183
180
  *
184
- * ```javascript [playground]
185
- * const isOdd = number => number % 2 == 1
186
- *
187
- * const obj = { a: 1, b: 2, c: 3, d: 4, e: 5 }
188
- *
189
- * const result = filter(obj, isOdd)
190
- * console.log(result) // { a: 1, c: 3, e: 5 }
181
+ * console.log(result)
191
182
  * ```
192
183
  *
193
- * `filter` applies the predicate to the values of the entries of a map.
184
+ * `filter` applies the predicate function to just the values of objects and maps.
194
185
  *
195
186
  * ```javascript [playground]
196
187
  * const isOdd = number => number % 2 == 1
197
188
  *
198
- * const myMap = new Map([['a', 1], ['b', 2], ['c', 3], ['d', 4], ['e', 5]])
199
- *
200
- * const result = filter(myMap, isOdd)
201
- * console.log(result) // Map(3) { 'a' => 1, 'c' => 3, 'e' => 5 }
202
- * ```
189
+ * const object = { a: 1, b: 2, c: 3, d: 4, e: 5 }
190
+ * const map = new Map([['a', 1], ['b', 2], ['c', 3], ['d', 4], ['e', 5]])
203
191
  *
204
- * For generators, `filter` returns a lazily filtered generator. All values that are normally yielded by the generator that test false by the predicate are excluded from the returned generator.
192
+ * const filteredObject = filter(object, isOdd)
193
+ * const filteredMap = filter(map, isOdd)
205
194
  *
206
- * ```javascript [playground]
207
- * const isOdd = number => number % 2 == 1
208
- *
209
- * const numbersGeneratorFunction = function* () {
210
- * yield 1; yield 2; yield 3; yield 4; yield 5
211
- * }
212
- *
213
- * const numbersGenerator = numbersGeneratorFunction()
214
- * const oddNumbersGenerator = filter(numbersGeneratorFunction(), isOdd)
215
- *
216
- * for (const number of numbersGenerator) {
217
- * console.log(number) // 1
218
- * // 2
219
- * // 3
220
- * // 4
221
- * // 5
222
- * }
223
- *
224
- * for (const number of oddNumbersGenerator) {
225
- * console.log(number) // 1
226
- * // 3
227
- * // 5
228
- * }
195
+ * console.log(filteredObject)
196
+ * console.log(filteredMap)
229
197
  * ```
230
198
  *
231
- * For async generators, `filter` returns a lazily filtered async generator. All values that are normally yielded by the async generator that test falsy by the predicate are excluded from the returned async generator.
199
+ * For generators, `filter` returns a filtered generator.
232
200
  *
233
201
  * ```javascript [playground]
234
- * const asyncIsOdd = async number => number % 2 == 1
202
+ * const isOdd = number => number % 2 == 1
235
203
  *
236
- * const asyncNumbersGeneratorFunction = async function* () {
204
+ * const generateNumbers = function* () {
237
205
  * yield 1; yield 2; yield 3; yield 4; yield 5
238
206
  * }
239
207
  *
240
- * const asyncNumbersGenerator = asyncNumbersGeneratorFunction()
241
- *
242
- * const asyncOddNumbersGenerator = filter(asyncNumbersGeneratorFunction(), asyncIsOdd)
208
+ * const numbers = generateNumbers()
209
+ * const oddNumbers = filter(generateNumbers(), isOdd)
243
210
  *
244
- * for await (const number of asyncNumbersGenerator) {
245
- * console.log(number) // 1
246
- * // 2
247
- * // 3
248
- * // 4
249
- * // 5
211
+ * console.log('numbers')
212
+ * for (const number of numbers) {
213
+ * console.log(number)
250
214
  * }
251
215
  *
252
- * for await (const number of asyncOddNumbersGenerator) {
253
- * console.log(number) // 1
254
- * // 3
255
- * // 5
216
+ * console.log('odd numbers')
217
+ * for (const number of oddNumbers) {
218
+ * console.log(number)
256
219
  * }
257
220
  * ```
258
221
  *
259
- * Any promises passed in data argument position are resolved for their values before further execution.
222
+ * If the filterable is a promise, it is resolved for its value before further execution for the eager interface only.
260
223
  *
261
224
  * ```javascript [playground]
262
225
  * const isOdd = number => number % 2 == 1
263
226
  *
264
227
  * filter(Promise.resolve([1, 2, 3, 4, 5]), isOdd).then(console.log)
265
- * // [1, 3, 5]
266
228
  * ```
267
229
  *
268
230
  * See also:
package/flatMap.js CHANGED
@@ -79,9 +79,17 @@ const _flatMap = function (value, flatMapper) {
79
79
  * @description
80
80
  * Applies a flat-mapper function to each item of a monad, returning a flat-mapped monad of the same type.
81
81
  *
82
- * A flat-mapping operation iterates through each item of a monad and applies the flat-mapper function to each item, flattening the result of the execution into the returned monad.
82
+ * ```javascript [playground]
83
+ * const duplicate = value => [value, value]
84
+ *
85
+ * const duplicated = flatMap([1, 2, 3, 4, 5], duplicate)
86
+ *
87
+ * console.log(duplicated)
88
+ * ```
89
+ *
90
+ * `flatMap` iterates through each item of a monad and applies the flat-mapper function to each item, concatenating the execution result (flat-mapped item) into the flat-mapped monad. If the execution result is a promise, it is resolved for its value before being concatenated into the flat-mapped monad. If the execution result is asynchronously iterable, it is muxed into the flat-mapped monad.
83
91
  *
84
- * If the flat-mapper is asynchronous, it is executed concurrently. The execution result may be asynchronously iterable, in which case it is muxed into the returned monad.
92
+ * If the flat-mapper function is asynchronous, it is executed concurrently.
85
93
  *
86
94
  * The following data types are considered to be monads:
87
95
  * * `array`
@@ -125,15 +133,7 @@ const _flatMap = function (value, flatMapper) {
125
133
  * flatMapper(item any, key string, monad Object) -> flatMappedItem Promise|Monad|any
126
134
  * ```
127
135
  *
128
- * ```javascript [playground]
129
- * const duplicate = value => [value, value]
130
- *
131
- * const duplicated = flatMap([1, 2, 3, 4, 5], duplicate)
132
- *
133
- * console.log(duplicated)
134
- * ```
135
- *
136
- * If the iterable is an object with a `.flatMap` or `.chain` method, the flat-mapper function signature is defined externally.
136
+ * If the iterable is an object with a `flatMap` or `chain` method, the flat-mapper function signature is defined externally.
137
137
  *
138
138
  * Values from async generators are muxed. Muxing, or asynchronously "mixing", is the process of combining multiple asynchronous sources into one source, with order determined by the asynchronous resolution of the individual promise elements.
139
139
  *
@@ -153,7 +153,7 @@ const _flatMap = function (value, flatMapper) {
153
153
  * // values from async generators are muxed
154
154
  * const muxed = await flatMap(['foo', 'bar', 'baz'], asyncRepeat3)
155
155
  *
156
- * console.log(muxed)
156
+ * console.log('muxed:', muxed)
157
157
  *
158
158
  * const repeat3 = function* (message) {
159
159
  * yield message; yield message; yield message
@@ -162,7 +162,7 @@ const _flatMap = function (value, flatMapper) {
162
162
  * // values from generators and other monads are concatenated
163
163
  * const repeated = flatMap(['foo', 'bar', 'baz'], repeat3)
164
164
  *
165
- * console.log(repeated)
165
+ * console.log('repeated:', repeated)
166
166
  * ```
167
167
  *
168
168
  * If the monad is a promise, it is resolved for its value before further execution for the eager interface only.
package/forEach.js CHANGED
@@ -60,6 +60,14 @@ const _forEach = function (collection, callback) {
60
60
  * @description
61
61
  * Executes a callback function for each item of an iterable, returning the original iterable unmodified.
62
62
  *
63
+ * ```javascript [playground]
64
+ * console.log('array')
65
+ * forEach([1, 2, 3, 4, 5], num => console.log(num))
66
+ *
67
+ * console.log('object')
68
+ * forEach({ a: 1, b: 2, c: 3 }, num => console.log(num))
69
+ * ```
70
+ *
63
71
  * The following data types are considered to be iterable:
64
72
  * * `array`
65
73
  * * `set`
@@ -101,14 +109,6 @@ const _forEach = function (collection, callback) {
101
109
  * callback(item any, key string, iterable Object) -> Promise|undefined
102
110
  * ```
103
111
  *
104
- * ```javascript [playground]
105
- * console.log('array')
106
- * forEach([1, 2, 3, 4, 5], num => console.log(num))
107
- *
108
- * console.log('object')
109
- * forEach({ a: 1, b: 2, c: 3 }, num => console.log(num))
110
- * ```
111
- *
112
112
  * If the iterable is an object with a `.forEach` method, the callback function signature is defined externally.
113
113
  *
114
114
  * If the callback function is asynchronous, it is executed concurrently.
package/get.js CHANGED
@@ -74,9 +74,9 @@ const _get = function (object, path, defaultValue) {
74
74
  * ```javascript [playground]
75
75
  * const asyncDefaultResolver = async object => object.a
76
76
  *
77
- * const promise = get({ a: 1 }, 'notfound', asyncDefaultResolver)
77
+ * const result = await get({ a: 1 }, 'notfound', asyncDefaultResolver)
78
78
  *
79
- * promise.then(console.log)
79
+ * console.log(result)
80
80
  * ```
81
81
  *
82
82
  * `get` supports three types of path patterns for nested property access.
@@ -96,7 +96,7 @@ const _get = function (object, path, defaultValue) {
96
96
  * const get00000BracketNotation = get('[0][0][0][0][0]')
97
97
  * const get00000ArrayNotation = get([0, 0, 0, 0, 0])
98
98
  *
99
- * const nested = [[[[['foo']]]]]
99
+ * const nested = [[[[[1]]]]]
100
100
  *
101
101
  * console.log(get00000DotNotation(nested))
102
102
  * console.log(get00000BracketNotation(nested))
package/gt.js CHANGED
@@ -6,44 +6,37 @@ const greaterThan = require('./_internal/greaterThan')
6
6
  *
7
7
  * @synopsis
8
8
  * ```coffeescript [specscript]
9
- * args Array<any>
10
- * argsOrPromises Array<Promise|any>
11
- *
12
- * type SyncOrAsyncResolver = (...args)=>Promise|any
13
- *
14
- * leftValue Promise|any
15
- * rightValue Promise|any
16
- * leftResolver SyncOrAsyncResolver
17
- * rightResolver SyncOrAsyncResolver
18
- *
19
- * gt(leftValue, rightValue) -> Promise|boolean
20
- * gt(...argsOrPromises, leftResolver, rightValue) -> Promise|boolean
21
- * gt(...argsOrPromises, leftValue, rightResolver) -> Promise|boolean
22
- * gt(...argsOrPromises, leftResolver, rightResolver) -> Promise|boolean
23
- * gt(leftResolver, rightValue)(...args) -> Promise|boolean
24
- * gt(leftValue, rightResolver)(...args) -> Promise|boolean
25
- * gt(leftResolver, rightResolver)(...args) -> Promise|boolean
9
+ * type SyncOrAsyncResolver = (...arguments)=>Promise|any
10
+ *
11
+ * gt(leftValue Promise|any, rightValue Promise|any) -> Promise|boolean
12
+ * gt(...arguments, leftResolver SyncOrAsyncResolver, rightValue Promise|any) -> Promise|boolean
13
+ * gt(...arguments, leftValue Promise|any, rightResolver SyncOrAsyncResolver) -> Promise|boolean
14
+ * gt(...arguments, leftResolver SyncOrAsyncResolver, rightResolver SyncOrAsyncResolver) -> Promise|boolean
15
+ *
16
+ * gt(leftResolver SyncOrAsyncResolver, rightValue Promise|any)(...arguments) -> Promise|boolean
17
+ * gt(leftValue Promise|any, rightResolver SyncOrAsyncResolver)(...arguments) -> Promise|boolean
18
+ * gt(leftResolver SyncOrAsyncResolver, rightResolver SyncOrAsyncResolver)(...arguments) -> Promise|boolean
26
19
  * ```
27
20
  *
28
21
  * @description
29
- * Functional equivalent of the [Greater than (>)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Greater_than) operator. Tests if a value is greater than (`>`) another value.
22
+ * Comparison operator. Tests if a value is greater than (`>`) another value.
30
23
  *
31
24
  * ```javascript [playground]
32
25
  * const age = 40
33
26
  *
34
27
  * const isAgeGreaterThan21 = gt(age, 21)
35
28
  *
36
- * console.log(isAgeGreaterThan21) // true
29
+ * console.log(isAgeGreaterThan21)
37
30
  * ```
38
31
  *
39
- * If either of the two values are resolver functions, `gt` returns a function that resolves the value(s) to compare.
32
+ * If either of the two values are resolver functions, `gt` returns a function that resolves the values to compare.
40
33
  *
41
34
  * ```javascript [playground]
42
35
  * const isOfLegalAge = gt(get('age'), 21)
43
36
  *
44
37
  * const juvenile = { age: 16 }
45
38
  *
46
- * console.log(isOfLegalAge(juvenile)) // false
39
+ * console.log(isOfLegalAge(juvenile))
47
40
  * ```
48
41
  *
49
42
  * If either of the resolver functions is asynchronous, `gt` returns an asynchronous function.
@@ -53,7 +46,7 @@ const greaterThan = require('./_internal/greaterThan')
53
46
  *
54
47
  * const juvenile = { age: 16 }
55
48
  *
56
- * asyncIsOfLegalAge(juvenile).then(console.log) // false
49
+ * asyncIsOfLegalAge(juvenile).then(console.log)
57
50
  * ```
58
51
  *
59
52
  * `gt` supports a lazy interface for composability.
@@ -61,14 +54,14 @@ const greaterThan = require('./_internal/greaterThan')
61
54
  * ```javascript [playground]
62
55
  * pipe({ value: 1 }, [
63
56
  * gt(5, get('value')),
64
- * console.log, // true
57
+ * console.log,
65
58
  * ])
66
59
  * ```
67
60
  *
68
- * Any promises passed in data argument position are resolved for their values before further execution.
61
+ * Any promises in `arguments` are resolved for their values before further execution for the eager interface only.
69
62
  *
70
63
  * ```javascript [playground]
71
- * gt(Promise.resolve({ a: 2, b: 1 }), get('a'), get('b')).then(console.log) // true
64
+ * gt(Promise.resolve({ a: 2, b: 1 }), get('a'), get('b')).then(console.log)
72
65
  * ```
73
66
  *
74
67
  * See also:
package/gte.js CHANGED
@@ -6,46 +6,39 @@ const greaterThanOrEqual = require('./_internal/greaterThanOrEqual')
6
6
  *
7
7
  * @synopsis
8
8
  * ```coffeescript [specscript]
9
- * args Array<any>
10
- * argsOrPromises Array<Promise|any>
11
- *
12
- * type SyncOrAsyncResolver = (...args)=>Promise|any
13
- *
14
- * leftValue Promise|any
15
- * rightValue Promise|any
16
- * leftResolver SyncOrAsyncResolver
17
- * rightResolver SyncOrAsyncResolver
18
- *
19
- * gte(leftValue, rightValue) -> Promise|boolean
20
- * gte(...argsOrPromises, leftResolver, rightValue) -> Promise|boolean
21
- * gte(...argsOrPromises, leftValue, rightResolver) -> Promise|boolean
22
- * gte(...argsOrPromises, leftResolver, rightResolver) -> Promise|boolean
23
- * gte(leftResolver, rightValue)(...args) -> Promise|boolean
24
- * gte(leftValue, rightResolver)(...args) -> Promise|boolean
25
- * gte(leftResolver, rightResolver)(...args) -> Promise|boolean
9
+ * type SyncOrAsyncResolver = (...arguments)=>Promise|any
10
+ *
11
+ * gte(leftValue Promise|any, rightValue Promise|any) -> Promise|boolean
12
+ * gte(...arguments, leftResolver SyncOrAsyncResolver, rightValue Promise|any) -> Promise|boolean
13
+ * gte(...arguments, leftValue Promise|any, rightResolver SyncOrAsyncResolver) -> Promise|boolean
14
+ * gte(...arguments, leftResolver SyncOrAsyncResolver, rightResolver SyncOrAsyncResolver) -> Promise|boolean
15
+ *
16
+ * gte(leftResolver SyncOrAsyncResolver, rightValue Promise|any)(...arguments) -> Promise|boolean
17
+ * gte(leftValue Promise|any, rightResolver SyncOrAsyncResolver)(...arguments) -> Promise|boolean
18
+ * gte(leftResolver SyncOrAsyncResolver, rightResolver SyncOrAsyncResolver)(...arguments) -> Promise|boolean
26
19
  * ```
27
20
  *
28
21
  * @description
29
- * Functional equivalent of the [Greater than or equal (>=)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Greater_than_or_equal) operator. Tests if a value is greater than or equal (`>=`) to another value.
22
+ * Comparison operator. Tests if a value is greater than or equal (`>=`) to another value.
30
23
  *
31
24
  * ```javascript [playground]
32
25
  * const age = 20
33
26
  *
34
27
  * const isAdultAge = gte(age, 18)
35
28
  *
36
- * console.log(isAdultAge) // true
29
+ * console.log(isAdultAge)
37
30
  * ```
38
31
  *
39
- * If either of the two values are resolver functions, `gte` returns a function that resolves the value(s) to compare.
32
+ * If either of the two values are resolver functions, `gte` returns a function that resolves the values to compare.
40
33
  *
41
34
  * ```javascript [playground]
42
35
  * const identity = value => value
43
36
  *
44
37
  * const isAtLeast100 = gte(identity, 100)
45
38
  *
46
- * console.log(isAtLeast100(99)) // false
47
- * console.log(isAtLeast100(100)) // true
48
- * console.log(isAtLeast100(101)) // true
39
+ * console.log(isAtLeast100(99))
40
+ * console.log(isAtLeast100(100))
41
+ * console.log(isAtLeast100(101))
49
42
  * ```
50
43
  *
51
44
  * If either of the two resolver functions is asynchronous, `gte` returns an asynchronous function.
@@ -55,9 +48,9 @@ const greaterThanOrEqual = require('./_internal/greaterThanOrEqual')
55
48
  *
56
49
  * const asyncIsAtLeast100 = gte(asyncIdentity, 100)
57
50
  *
58
- * asyncIsAtLeast100(99).then(console.log) // false
59
- * asyncIsAtLeast100(100).then(console.log) // true
60
- * asyncIsAtLeast100(101).then(console.log) // true
51
+ * asyncIsAtLeast100(99).then(console.log)
52
+ * asyncIsAtLeast100(100).then(console.log)
53
+ * asyncIsAtLeast100(101).then(console.log)
61
54
  * ```
62
55
  *
63
56
  * `gte` supports a lazy interface for composability.
@@ -65,14 +58,14 @@ const greaterThanOrEqual = require('./_internal/greaterThanOrEqual')
65
58
  * ```javascript [playground]
66
59
  * pipe({ value: 1 }, [
67
60
  * gte(1, get('value')),
68
- * console.log, // true
61
+ * console.log,
69
62
  * ])
70
63
  * ```
71
64
  *
72
- * Any promises passed in data argument position are resolved for their values before further execution.
65
+ * Any promises in `arguments` are resolved for their values before further execution for the eager interface only.
73
66
  *
74
67
  * ```javascript [playground]
75
- * gte(Promise.resolve({ a: 1, b: 1 }), get('a'), get('b')).then(console.log) // true
68
+ * gte(Promise.resolve({ a: 1, b: 1 }), get('a'), get('b')).then(console.log)
76
69
  * ```
77
70
  *
78
71
  * See also:
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Rubico v2.10.0
2
+ * Rubico v2.12.1
3
3
  * https://rubico.land/
4
4
  *
5
5
  * © Richard Yufei Tong, King of Software
@@ -1480,26 +1480,64 @@ const FilteringIterator = (iterator, predicate) => ({
1480
1480
  },
1481
1481
  })
1482
1482
 
1483
- const FilteringAsyncIterator = (asyncIterator, predicate) => ({
1484
- isAsyncIteratorDone: false,
1485
- [symbolAsyncIterator]() {
1486
- return this
1487
- },
1488
- async next() {
1489
- while (!this.isAsyncIteratorDone) {
1490
- const { value, done } = await asyncIterator.next()
1491
- if (done) {
1492
- this.isAsyncIteratorDone = true
1493
- } else {
1494
- const predication = predicate(value)
1495
- if (isPromise(predication) ? await predication : predication) {
1496
- return { value, done: false }
1483
+ const FilteringAsyncIterator = (asyncIterator, predicate) => {
1484
+ const buffer = new LinkedList()
1485
+
1486
+ let index = -1
1487
+ let consumingAsyncIterator = false
1488
+ let isAsyncIteratorDone = false
1489
+
1490
+ return {
1491
+ [symbolAsyncIterator]() {
1492
+ return this
1493
+ },
1494
+
1495
+ // _consumeAsyncIterator() -> Promise<>
1496
+ async _consumeAsyncIterator() {
1497
+ for await (const item of asyncIterator) {
1498
+ index += 1
1499
+ const booleanResult = predicate(item)
1500
+ buffer.append([booleanResult, item])
1501
+ }
1502
+ isAsyncIteratorDone = true
1503
+ },
1504
+
1505
+
1506
+ async next() {
1507
+ if (!consumingAsyncIterator) {
1508
+ this._consumeAsyncIterator()
1509
+ consumingAsyncIterator = true
1510
+ }
1511
+
1512
+ while (!isAsyncIteratorDone) {
1513
+ if (buffer.length > 0) {
1514
+ let [booleanResult, item] = buffer.popFirst()
1515
+ if (isPromise(booleanResult)) {
1516
+ booleanResult = await booleanResult
1517
+ }
1518
+ if (booleanResult) {
1519
+ return { value: item, done: false }
1520
+ }
1521
+ continue
1497
1522
  }
1523
+ await sleep(10)
1498
1524
  }
1499
- }
1500
- return { value: undefined, done: true }
1501
- },
1502
- })
1525
+
1526
+ while (buffer.length > 0) {
1527
+ let [booleanResult, item] = buffer.popFirst()
1528
+ if (isPromise(booleanResult)) {
1529
+ booleanResult = await booleanResult
1530
+ }
1531
+ if (booleanResult) {
1532
+ return { value: item, done: false }
1533
+ }
1534
+ }
1535
+
1536
+ return { value: undefined, done: true }
1537
+ },
1538
+
1539
+ }
1540
+ }
1503
1541
 
1504
1542
  const arrayExtendMap = function (
1505
1543
  array, values, valuesMapper, valuesIndex,