rubico 2.8.6 → 2.10.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 (378) hide show
  1. package/README.md +1 -1
  2. package/_internal/FlatMappingAsyncIterator.js +41 -30
  3. package/_internal/LinkedList.js +54 -0
  4. package/_internal/LinkedList.test.js +34 -0
  5. package/_internal/MappingAsyncIterator.js +65 -15
  6. package/_internal/SerialMappingAsyncIterator.js +79 -0
  7. package/_internal/iteratorFind.js +0 -2
  8. package/_internal/iteratorForEachSeries.js +1 -1
  9. package/_internal/objectFlatten.js +4 -1
  10. package/all.js +7 -8
  11. package/and.js +1 -1
  12. package/assign.js +1 -1
  13. package/compose.js +1 -1
  14. package/curry.js +1 -1
  15. package/dist/Transducer.es.js +1 -1
  16. package/dist/Transducer.es.min.js +1 -1
  17. package/dist/Transducer.js +1 -1
  18. package/dist/Transducer.min.js +1 -1
  19. package/dist/Transducer.mjs +1 -1
  20. package/dist/__.es.js +1 -1
  21. package/dist/__.es.min.js +1 -1
  22. package/dist/__.js +1 -1
  23. package/dist/__.min.js +1 -1
  24. package/dist/__.mjs +1 -1
  25. package/dist/all.es.js +1 -1
  26. package/dist/all.es.min.js +1 -1
  27. package/dist/all.js +1 -1
  28. package/dist/all.min.js +1 -1
  29. package/dist/all.mjs +1 -1
  30. package/dist/always.es.js +1 -1
  31. package/dist/always.es.min.js +1 -1
  32. package/dist/always.js +1 -1
  33. package/dist/always.min.js +1 -1
  34. package/dist/always.mjs +1 -1
  35. package/dist/and.es.js +1 -1
  36. package/dist/and.es.min.js +1 -1
  37. package/dist/and.js +1 -1
  38. package/dist/and.min.js +1 -1
  39. package/dist/and.mjs +1 -1
  40. package/dist/assign.es.js +1 -1
  41. package/dist/assign.es.min.js +1 -1
  42. package/dist/assign.js +1 -1
  43. package/dist/assign.min.js +1 -1
  44. package/dist/assign.mjs +1 -1
  45. package/dist/compose.es.js +1 -1
  46. package/dist/compose.es.min.js +1 -1
  47. package/dist/compose.js +1 -1
  48. package/dist/compose.min.js +1 -1
  49. package/dist/compose.mjs +1 -1
  50. package/dist/curry.es.js +1 -1
  51. package/dist/curry.es.min.js +1 -1
  52. package/dist/curry.js +1 -1
  53. package/dist/curry.min.js +1 -1
  54. package/dist/curry.mjs +1 -1
  55. package/dist/eq.es.js +1 -1
  56. package/dist/eq.es.min.js +1 -1
  57. package/dist/eq.js +1 -1
  58. package/dist/eq.min.js +1 -1
  59. package/dist/eq.mjs +1 -1
  60. package/dist/every.es.js +1 -1
  61. package/dist/every.es.min.js +1 -1
  62. package/dist/every.js +1 -1
  63. package/dist/every.min.js +1 -1
  64. package/dist/every.mjs +1 -1
  65. package/dist/filter.es.js +4 -4
  66. package/dist/filter.es.min.js +2 -2
  67. package/dist/filter.js +4 -4
  68. package/dist/filter.min.js +2 -2
  69. package/dist/filter.mjs +4 -4
  70. package/dist/flatMap.es.js +44 -28
  71. package/dist/flatMap.es.min.js +2 -2
  72. package/dist/flatMap.js +44 -28
  73. package/dist/flatMap.min.js +2 -2
  74. package/dist/flatMap.mjs +44 -28
  75. package/dist/forEach.es.js +6 -6
  76. package/dist/forEach.es.min.js +2 -2
  77. package/dist/forEach.js +6 -6
  78. package/dist/forEach.min.js +2 -2
  79. package/dist/forEach.mjs +6 -6
  80. package/dist/get.es.js +1 -1
  81. package/dist/get.es.min.js +1 -1
  82. package/dist/get.js +1 -1
  83. package/dist/get.min.js +1 -1
  84. package/dist/get.mjs +1 -1
  85. package/dist/gt.es.js +1 -1
  86. package/dist/gt.es.min.js +1 -1
  87. package/dist/gt.js +1 -1
  88. package/dist/gt.min.js +1 -1
  89. package/dist/gt.mjs +1 -1
  90. package/dist/gte.es.js +1 -1
  91. package/dist/gte.es.min.js +1 -1
  92. package/dist/gte.js +1 -1
  93. package/dist/gte.min.js +1 -1
  94. package/dist/gte.mjs +1 -1
  95. package/dist/lt.es.js +1 -1
  96. package/dist/lt.es.min.js +1 -1
  97. package/dist/lt.js +1 -1
  98. package/dist/lt.min.js +1 -1
  99. package/dist/lt.mjs +1 -1
  100. package/dist/lte.es.js +1 -1
  101. package/dist/lte.es.min.js +1 -1
  102. package/dist/lte.js +1 -1
  103. package/dist/lte.min.js +1 -1
  104. package/dist/lte.mjs +1 -1
  105. package/dist/map.es.js +187 -39
  106. package/dist/map.es.min.js +2 -2
  107. package/dist/map.js +187 -39
  108. package/dist/map.min.js +2 -2
  109. package/dist/map.mjs +187 -39
  110. package/dist/not.es.js +1 -1
  111. package/dist/not.es.min.js +1 -1
  112. package/dist/not.js +1 -1
  113. package/dist/not.min.js +1 -1
  114. package/dist/not.mjs +1 -1
  115. package/dist/omit.es.js +1 -1
  116. package/dist/omit.es.min.js +1 -1
  117. package/dist/omit.js +1 -1
  118. package/dist/omit.min.js +1 -1
  119. package/dist/omit.mjs +1 -1
  120. package/dist/or.es.js +1 -1
  121. package/dist/or.es.min.js +1 -1
  122. package/dist/or.js +1 -1
  123. package/dist/or.min.js +1 -1
  124. package/dist/or.mjs +1 -1
  125. package/dist/pick.es.js +1 -1
  126. package/dist/pick.es.min.js +1 -1
  127. package/dist/pick.js +1 -1
  128. package/dist/pick.min.js +1 -1
  129. package/dist/pick.mjs +1 -1
  130. package/dist/pipe.es.js +1 -1
  131. package/dist/pipe.es.min.js +1 -1
  132. package/dist/pipe.js +1 -1
  133. package/dist/pipe.min.js +1 -1
  134. package/dist/pipe.mjs +1 -1
  135. package/dist/reduce.es.js +1 -1
  136. package/dist/reduce.es.min.js +1 -1
  137. package/dist/reduce.js +1 -1
  138. package/dist/reduce.min.js +1 -1
  139. package/dist/reduce.mjs +1 -1
  140. package/dist/rubico.es.js +233 -78
  141. package/dist/rubico.es.min.js +2 -2
  142. package/dist/rubico.global.js +233 -78
  143. package/dist/rubico.global.min.js +2 -2
  144. package/dist/rubico.js +233 -78
  145. package/dist/rubico.min.js +2 -2
  146. package/dist/rubico.mjs +233 -78
  147. package/dist/set.es.js +1 -1
  148. package/dist/set.es.min.js +1 -1
  149. package/dist/set.js +1 -1
  150. package/dist/set.min.js +1 -1
  151. package/dist/set.mjs +1 -1
  152. package/dist/some.es.js +1 -1
  153. package/dist/some.es.min.js +1 -1
  154. package/dist/some.js +1 -1
  155. package/dist/some.min.js +1 -1
  156. package/dist/some.mjs +1 -1
  157. package/dist/switchCase.es.js +1 -1
  158. package/dist/switchCase.es.min.js +1 -1
  159. package/dist/switchCase.js +1 -1
  160. package/dist/switchCase.min.js +1 -1
  161. package/dist/switchCase.mjs +1 -1
  162. package/dist/tap.es.js +1 -1
  163. package/dist/tap.es.min.js +1 -1
  164. package/dist/tap.js +1 -1
  165. package/dist/tap.min.js +1 -1
  166. package/dist/tap.mjs +1 -1
  167. package/dist/thunkify.es.js +1 -1
  168. package/dist/thunkify.es.min.js +1 -1
  169. package/dist/thunkify.js +1 -1
  170. package/dist/thunkify.min.js +1 -1
  171. package/dist/thunkify.mjs +1 -1
  172. package/dist/transform.es.js +1 -1
  173. package/dist/transform.es.min.js +1 -1
  174. package/dist/transform.js +1 -1
  175. package/dist/transform.min.js +1 -1
  176. package/dist/transform.mjs +1 -1
  177. package/dist/tryCatch.es.js +1 -1
  178. package/dist/tryCatch.es.min.js +1 -1
  179. package/dist/tryCatch.js +1 -1
  180. package/dist/tryCatch.min.js +1 -1
  181. package/dist/tryCatch.mjs +1 -1
  182. package/dist/x/append.es.js +1 -1
  183. package/dist/x/append.es.min.js +1 -1
  184. package/dist/x/append.js +1 -1
  185. package/dist/x/append.min.js +1 -1
  186. package/dist/x/append.mjs +1 -1
  187. package/dist/x/callProp.es.js +1 -1
  188. package/dist/x/callProp.es.min.js +1 -1
  189. package/dist/x/callProp.js +1 -1
  190. package/dist/x/callProp.min.js +1 -1
  191. package/dist/x/callProp.mjs +1 -1
  192. package/dist/x/defaultsDeep.es.js +1 -1
  193. package/dist/x/defaultsDeep.es.min.js +1 -1
  194. package/dist/x/defaultsDeep.js +1 -1
  195. package/dist/x/defaultsDeep.min.js +1 -1
  196. package/dist/x/defaultsDeep.mjs +1 -1
  197. package/dist/x/differenceWith.es.js +1 -1
  198. package/dist/x/differenceWith.es.min.js +1 -1
  199. package/dist/x/differenceWith.js +1 -1
  200. package/dist/x/differenceWith.min.js +1 -1
  201. package/dist/x/differenceWith.mjs +1 -1
  202. package/dist/x/filterOut.es.js +4 -4
  203. package/dist/x/filterOut.es.min.js +2 -2
  204. package/dist/x/filterOut.js +4 -4
  205. package/dist/x/filterOut.min.js +2 -2
  206. package/dist/x/filterOut.mjs +4 -4
  207. package/dist/x/find.es.js +1 -3
  208. package/dist/x/find.es.min.js +1 -1
  209. package/dist/x/find.js +1 -3
  210. package/dist/x/find.min.js +1 -1
  211. package/dist/x/find.mjs +1 -3
  212. package/dist/x/findIndex.es.js +1 -1
  213. package/dist/x/findIndex.es.min.js +1 -1
  214. package/dist/x/findIndex.js +1 -1
  215. package/dist/x/findIndex.min.js +1 -1
  216. package/dist/x/findIndex.mjs +1 -1
  217. package/dist/x/first.es.js +1 -1
  218. package/dist/x/first.es.min.js +1 -1
  219. package/dist/x/first.js +1 -1
  220. package/dist/x/first.min.js +1 -1
  221. package/dist/x/first.mjs +1 -1
  222. package/dist/x/flatten.es.js +44 -28
  223. package/dist/x/flatten.es.min.js +2 -2
  224. package/dist/x/flatten.js +44 -28
  225. package/dist/x/flatten.min.js +2 -2
  226. package/dist/x/flatten.mjs +44 -28
  227. package/dist/x/groupBy.es.js +1 -1
  228. package/dist/x/groupBy.es.min.js +1 -1
  229. package/dist/x/groupBy.js +1 -1
  230. package/dist/x/groupBy.min.js +1 -1
  231. package/dist/x/groupBy.mjs +1 -1
  232. package/dist/x/has.es.js +1 -1
  233. package/dist/x/has.es.min.js +1 -1
  234. package/dist/x/has.js +1 -1
  235. package/dist/x/has.min.js +1 -1
  236. package/dist/x/has.mjs +1 -1
  237. package/dist/x/identity.es.js +1 -1
  238. package/dist/x/identity.es.min.js +1 -1
  239. package/dist/x/identity.js +1 -1
  240. package/dist/x/identity.min.js +1 -1
  241. package/dist/x/identity.mjs +1 -1
  242. package/dist/x/includes.es.js +1 -1
  243. package/dist/x/includes.es.min.js +1 -1
  244. package/dist/x/includes.js +1 -1
  245. package/dist/x/includes.min.js +1 -1
  246. package/dist/x/includes.mjs +1 -1
  247. package/dist/x/isDeepEqual.es.js +1 -1
  248. package/dist/x/isDeepEqual.es.min.js +1 -1
  249. package/dist/x/isDeepEqual.js +1 -1
  250. package/dist/x/isDeepEqual.min.js +1 -1
  251. package/dist/x/isDeepEqual.mjs +1 -1
  252. package/dist/x/isEmpty.es.js +1 -1
  253. package/dist/x/isEmpty.es.min.js +1 -1
  254. package/dist/x/isEmpty.js +1 -1
  255. package/dist/x/isEmpty.min.js +1 -1
  256. package/dist/x/isEmpty.mjs +1 -1
  257. package/dist/x/isEqual.es.js +1 -1
  258. package/dist/x/isEqual.es.min.js +1 -1
  259. package/dist/x/isEqual.js +1 -1
  260. package/dist/x/isEqual.min.js +1 -1
  261. package/dist/x/isEqual.mjs +1 -1
  262. package/dist/x/isFunction.es.js +1 -1
  263. package/dist/x/isFunction.es.min.js +1 -1
  264. package/dist/x/isFunction.js +1 -1
  265. package/dist/x/isFunction.min.js +1 -1
  266. package/dist/x/isFunction.mjs +1 -1
  267. package/dist/x/isIn.es.js +1 -1
  268. package/dist/x/isIn.es.min.js +1 -1
  269. package/dist/x/isIn.js +1 -1
  270. package/dist/x/isIn.min.js +1 -1
  271. package/dist/x/isIn.mjs +1 -1
  272. package/dist/x/isObject.es.js +1 -1
  273. package/dist/x/isObject.es.min.js +1 -1
  274. package/dist/x/isObject.js +1 -1
  275. package/dist/x/isObject.min.js +1 -1
  276. package/dist/x/isObject.mjs +1 -1
  277. package/dist/x/isString.es.js +1 -1
  278. package/dist/x/isString.es.min.js +1 -1
  279. package/dist/x/isString.js +1 -1
  280. package/dist/x/isString.min.js +1 -1
  281. package/dist/x/isString.mjs +1 -1
  282. package/dist/x/keys.es.js +1 -1
  283. package/dist/x/keys.es.min.js +1 -1
  284. package/dist/x/keys.js +1 -1
  285. package/dist/x/keys.min.js +1 -1
  286. package/dist/x/keys.mjs +1 -1
  287. package/dist/x/last.es.js +1 -1
  288. package/dist/x/last.es.min.js +1 -1
  289. package/dist/x/last.js +1 -1
  290. package/dist/x/last.min.js +1 -1
  291. package/dist/x/last.mjs +1 -1
  292. package/dist/x/maxBy.es.js +1 -1
  293. package/dist/x/maxBy.es.min.js +1 -1
  294. package/dist/x/maxBy.js +1 -1
  295. package/dist/x/maxBy.min.js +1 -1
  296. package/dist/x/maxBy.mjs +1 -1
  297. package/dist/x/noop.es.js +1 -1
  298. package/dist/x/noop.es.min.js +1 -1
  299. package/dist/x/noop.js +1 -1
  300. package/dist/x/noop.min.js +1 -1
  301. package/dist/x/noop.mjs +1 -1
  302. package/dist/x/pluck.es.js +187 -39
  303. package/dist/x/pluck.es.min.js +2 -2
  304. package/dist/x/pluck.js +187 -39
  305. package/dist/x/pluck.min.js +2 -2
  306. package/dist/x/pluck.mjs +187 -39
  307. package/dist/x/prepend.es.js +1 -1
  308. package/dist/x/prepend.es.min.js +1 -1
  309. package/dist/x/prepend.js +1 -1
  310. package/dist/x/prepend.min.js +1 -1
  311. package/dist/x/prepend.mjs +1 -1
  312. package/dist/x/size.es.js +1 -1
  313. package/dist/x/size.es.min.js +1 -1
  314. package/dist/x/size.js +1 -1
  315. package/dist/x/size.min.js +1 -1
  316. package/dist/x/size.mjs +1 -1
  317. package/dist/x/trace.es.js +1 -1
  318. package/dist/x/trace.es.min.js +1 -1
  319. package/dist/x/trace.js +1 -1
  320. package/dist/x/trace.min.js +1 -1
  321. package/dist/x/trace.mjs +1 -1
  322. package/dist/x/unionWith.es.js +1 -1
  323. package/dist/x/unionWith.es.min.js +1 -1
  324. package/dist/x/unionWith.js +1 -1
  325. package/dist/x/unionWith.min.js +1 -1
  326. package/dist/x/unionWith.mjs +1 -1
  327. package/dist/x/uniq.es.js +1 -1
  328. package/dist/x/uniq.es.min.js +1 -1
  329. package/dist/x/uniq.js +1 -1
  330. package/dist/x/uniq.min.js +1 -1
  331. package/dist/x/uniq.mjs +1 -1
  332. package/dist/x/unless.es.js +1 -1
  333. package/dist/x/unless.es.min.js +1 -1
  334. package/dist/x/unless.js +1 -1
  335. package/dist/x/unless.min.js +1 -1
  336. package/dist/x/unless.mjs +1 -1
  337. package/dist/x/values.es.js +1 -1
  338. package/dist/x/values.es.min.js +1 -1
  339. package/dist/x/values.js +1 -1
  340. package/dist/x/values.min.js +1 -1
  341. package/dist/x/values.mjs +1 -1
  342. package/dist/x/when.es.js +1 -1
  343. package/dist/x/when.es.min.js +1 -1
  344. package/dist/x/when.js +1 -1
  345. package/dist/x/when.min.js +1 -1
  346. package/dist/x/when.mjs +1 -1
  347. package/eq.js +2 -2
  348. package/es.js +233 -78
  349. package/every.js +2 -2
  350. package/filter.js +4 -4
  351. package/flatMap.js +61 -54
  352. package/forEach.js +33 -56
  353. package/get.js +5 -3
  354. package/gt.js +2 -2
  355. package/gte.js +2 -2
  356. package/index.js +233 -78
  357. package/lt.js +2 -2
  358. package/lte.js +2 -2
  359. package/map.js +115 -151
  360. package/monad/README.md +1 -1
  361. package/not.js +1 -1
  362. package/omit.js +22 -19
  363. package/or.js +1 -1
  364. package/package.json +1 -1
  365. package/pick.js +14 -11
  366. package/pipe.js +1 -1
  367. package/reduce.js +1 -1
  368. package/set.js +17 -18
  369. package/some.js +2 -2
  370. package/switchCase.js +12 -4
  371. package/tap.js +6 -4
  372. package/transform.js +1 -1
  373. package/tryCatch.js +1 -1
  374. package/x/defaultsDeep.js +1 -1
  375. package/x/defaultsDeep.test.js +1 -1
  376. package/_internal/NextIteration.js +0 -12
  377. package/_internal/generatorFunctionFilter.js +0 -28
  378. package/_internal/iterationMap.js +0 -27
package/lte.js CHANGED
@@ -58,7 +58,7 @@ const lessThanOrEqual = require('./_internal/lessThanOrEqual')
58
58
  * asyncIsLessThanOrEqualTo3(5).then(console.log) // false
59
59
  * ```
60
60
  *
61
- * `lte` supports a lazy API for composability.
61
+ * `lte` supports a lazy interface for composability.
62
62
  *
63
63
  * ```javascript [playground]
64
64
  * pipe({ value: 1 }, [
@@ -67,7 +67,7 @@ const lessThanOrEqual = require('./_internal/lessThanOrEqual')
67
67
  * ])
68
68
  * ```
69
69
  *
70
- * Any promises passed in argument position are resolved for their values before further execution.
70
+ * Any promises passed in data argument position are resolved for their values before further execution.
71
71
  *
72
72
  * ```javascript [playground]
73
73
  * lte(Promise.resolve({ a: 1, b: 1 }), get('a'), get('b')).then(console.log) // true
package/map.js CHANGED
@@ -1,6 +1,7 @@
1
1
  const isPromise = require('./_internal/isPromise')
2
2
  const MappingIterator = require('./_internal/MappingIterator')
3
3
  const MappingAsyncIterator = require('./_internal/MappingAsyncIterator')
4
+ const SerialMappingAsyncIterator = require('./_internal/SerialMappingAsyncIterator')
4
5
  const __ = require('./_internal/placeholder')
5
6
  const curry2 = require('./_internal/curry2')
6
7
  const curry3 = require('./_internal/curry3')
@@ -64,9 +65,6 @@ const _map = function (value, f) {
64
65
  if (typeof value.then == 'function') {
65
66
  return value.then(f)
66
67
  }
67
- if (typeof value.map == 'function') {
68
- return value.map(f)
69
- }
70
68
  if (typeof value == 'string' || value.constructor == String) {
71
69
  return stringMap(value, f)
72
70
  }
@@ -82,6 +80,9 @@ const _map = function (value, f) {
82
80
  if (typeof value[symbolAsyncIterator] == 'function') {
83
81
  return MappingAsyncIterator(value[symbolAsyncIterator](), f)
84
82
  }
83
+ if (typeof value.map == 'function') {
84
+ return value.map(f)
85
+ }
85
86
  if (value.constructor == Object) {
86
87
  return objectMap(value, f)
87
88
  }
@@ -96,17 +97,17 @@ const _map = function (value, f) {
96
97
  * type Functor = Array|Set|Map|Generator|AsyncGenerator|{ map: function }|Object
97
98
  *
98
99
  * type SyncOrAsyncMapper = (
99
- * element any,
100
+ * item any,
100
101
  * indexOrKey number|string|any,
101
102
  * functor Functor
102
- * )=>(resultElement Promise|any)
103
+ * )=>(mappedItem Promise|any)
103
104
  *
104
- * map(functor Promise|Functor, mapper SyncOrAsyncMapper) -> result Promise|Functor
105
- * map(mapper SyncOrAsyncMapper)(functor Functor) -> result Promise|Functor
105
+ * map(functor Promise|Functor, mapper SyncOrAsyncMapper) -> mappedFunctor Promise|Functor
106
+ * map(mapper SyncOrAsyncMapper)(functor Functor) -> mappedFunctor Promise|Functor
106
107
  * ```
107
108
  *
108
109
  * @description
109
- * Applies a mapper function to each element of a functor, returning a functor of the same type with the mapped elements. The order of the elements is maintained.
110
+ * Applies a mapper function to each item of a functor, returning a mapped functor of the same type with the mapped items. The order of the elements is maintained.
110
111
  *
111
112
  * The following data types are considered to be functors:
112
113
  * * `array`
@@ -117,12 +118,13 @@ const _map = function (value, f) {
117
118
  * * `object with .map method`
118
119
  * * `object`
119
120
  *
120
- * The mapper function defines a mapping between a given element in the functor to a resulting element in the returned functor.
121
+ * The mapper function defines a mapping between a given item and an item in the returned functor.
121
122
  *
122
123
  * ```javascript
123
- * const mapper = function (element) {
124
- * // resultElement is the result of a mapping from element
125
- * return resultElement
124
+ * const mapper = function (item) {
125
+ * // ...
126
+ * // mappedItem is mapped from item
127
+ * return mappedItem
126
128
  * }
127
129
  * ```
128
130
  *
@@ -130,48 +132,52 @@ const _map = function (value, f) {
130
132
  *
131
133
  * If the functor is an array:
132
134
  * ```coffeescript [specscript]
133
- * mapper(element any, index number, ftor Array) -> resultElement Promise|any
135
+ * mapper(item any, index number, functor Array) -> mappedItem Promise|any
134
136
  * ```
135
137
  *
136
138
  * If the functor is a set:
137
139
  * ```coffeescript [specscript]
138
- * mapper(element any, element any, ftor Set) -> resultElement Promise|any
140
+ * mapper(item any, item any, functor Set) -> mappedItem Promise|any
139
141
  * ```
140
142
  *
141
143
  * If the functor is a map:
142
144
  * ```coffeescript [specscript]
143
- * mapper(element any, key any, ftor Map) -> resultElement Promise|any
145
+ * mapper(item any, key any, functor Map) -> mappedItem Promise|any
144
146
  * ```
145
147
  *
146
148
  * If the functor is a generator:
147
149
  * ```coffeescript [specscript]
148
- * mapper(element any) -> resultElement Promise|any
150
+ * mapper(item any) -> mappedItem any
149
151
  * ```
150
152
  *
151
153
  * If the functor is an async generator:
152
154
  * ```coffeescript [specscript]
153
- * mapper(element any) -> resultElement Promise|any
155
+ * mapper(item any) -> mappedItem Promise|any
154
156
  * ```
155
157
  *
156
- * If the functor is an object with a `.map` method, the mapper function signature is defined externally.
157
- *
158
158
  * If the functor is a plain object:
159
159
  * ```coffeescript [specscript]
160
- * mapper(element any, key string, ftor Object) -> resultElement Promise|any
160
+ * mapper(item any, key string, functor Object) -> mappedItem Promise|any
161
161
  * ```
162
162
  *
163
- * `map` works for arrays.
164
- *
165
163
  * ```javascript [playground]
166
164
  * const square = number => number ** 2
167
165
  *
168
166
  * const array = [1, 2, 3, 4, 5]
167
+ * const object = { a: 1, b: 2, c: 3 }
168
+ *
169
+ * const mappedArray = map(array, square)
170
+ * const mappedObject = map(object, square)
169
171
  *
170
- * const result = map(array, square)
171
- * console.log(result) // [1, 4, 9, 16, 25]
172
+ * console.log(mappedArray)
173
+ * console.log(mappedObject)
172
174
  * ```
173
175
  *
174
- * The mapper function may be asynchronous, in which case it is applied concurrently.
176
+ * If the functor is an object with a `.map` method, the mapper function signature is defined externally.
177
+ *
178
+ * If the mapper function is asynchronous, it is executed concurrently.
179
+ *
180
+ * If the functor is a generator, the mapper function must be synchronous.
175
181
  *
176
182
  * ```javascript [playground]
177
183
  * const asyncSquare = async number => number ** 2
@@ -179,84 +185,56 @@ const _map = function (value, f) {
179
185
  * const array = [1, 2, 3, 4, 5]
180
186
  *
181
187
  * const promise = map(array, asyncSquare)
182
- * promise.then(console.log) // [1, 4, 9, 16, 25]
183
- * ```
184
- *
185
- * `map` applies the mapper function to just the values of an object.
186
188
  *
187
- * ```javascript [playground]
188
- * const square = number => number ** 2
189
- *
190
- * const obj = { a: 1, b: 2, c: 3, d: 4, e: 5 }
191
- *
192
- * const result = map(obj, square)
193
- * console.log(result) // { a: 1, b: 4, c: 9, d: 16, e: 25 }
189
+ * promise.then(console.log)
194
190
  * ```
195
191
  *
196
- * `map` applies the mapper function to the values of the entries of a map.
192
+ * `map` applies the mapper function to just the values of objects and maps.
197
193
  *
198
194
  * ```javascript [playground]
199
195
  * const square = number => number ** 2
200
196
  *
197
+ * const object = { a: 1, b: 2, c: 3, d: 4, e: 5 }
201
198
  * const m = new Map([['a', 1], ['b', 2], ['c', 3], ['d', 4], ['e', 5]])
202
199
  *
203
- * const result = map(m, square)
204
- * console.log(result) // Map { 'a' => 1, 'b' => 4, 'c' => 9, 'd' => 16, 'e' => 25 }
205
- * ```
206
- *
207
- * `map` applies the mapper function lazily to each value of a generator, creating a new generator with mapped elements.
200
+ * const mappedObject = map(object, square)
201
+ * const mappedMap = map(m, square)
208
202
  *
209
- * ```javascript [playground]
210
- * const capitalize = string => string.toUpperCase()
211
- *
212
- * const abcGeneratorFunc = function* () {
213
- * yield 'a'; yield 'b'; yield 'c'
214
- * }
215
- *
216
- * const abcGenerator = abcGeneratorFunc()
217
- * const ABCGenerator = map(abcGeneratorFunc(), capitalize)
218
- *
219
- * console.log([...abcGenerator]) // ['a', 'b', 'c']
220
- *
221
- * console.log([...ABCGenerator]) // ['A', 'B', 'C']
203
+ * console.log(mappedObject)
204
+ * console.log(mappedMap)
222
205
  * ```
223
206
  *
224
- * `map` applies the mapper function lazily to each value of an async generator, creating a new async generator with mapped elements.
207
+ * `map` maps each value of a generator, creating a new generator with mapped elements.
225
208
  *
226
209
  * ```javascript [playground]
227
210
  * const capitalize = string => string.toUpperCase()
228
211
  *
229
- * const abcAsyncGeneratorFunc = async function* () {
230
- * yield 'a'; yield 'b'; yield 'c'
212
+ * async function* generateAlphabet() {
213
+ * for (let i = 0; i < 26; i++) {
214
+ * yield String.fromCharCode(97 + i)
215
+ * }
231
216
  * }
232
217
  *
233
- * const abcAsyncGenerator = abcAsyncGeneratorFunc()
234
- * const ABCGenerator = map(abcAsyncGeneratorFunc(), capitalize)
218
+ * const alphabet = generateAlphabet()
219
+ * const uppercaseAlphabet = map(generateAlphabet(), capitalize)
235
220
  *
236
- * ;(async function () {
237
- * for await (const letter of abcAsyncGenerator) {
238
- * console.log(letter)
239
- * // a
240
- * // b
241
- * // c
242
- * }
221
+ * console.log('alphabet')
222
+ * for await (const letter of alphabet) {
223
+ * console.log(letter)
224
+ * }
243
225
  *
244
- * for await (const letter of ABCGenerator) {
245
- * console.log(letter)
246
- * // A
247
- * // B
248
- * // C
249
- * }
250
- * })()
226
+ * console.log('uppercase alphabet')
227
+ * for await (const letter of uppercaseAlphabet) {
228
+ * console.log(letter)
229
+ * }
251
230
  * ```
252
231
  *
253
- * Any promises passed in argument position are resolved for their values before further execution.
232
+ * If the functor is a promise, it is resolved for its value before further execution for the eager interface only.
254
233
  *
255
234
  * ```javascript [playground]
256
235
  * const asyncSquare = async n => n ** 2
257
236
  *
258
237
  * map(Promise.resolve([1, 2, 3, 4, 5]), asyncSquare).then(console.log)
259
- * // [1, 4, 9, 16, 25]
260
238
  * ```
261
239
  *
262
240
  * See also:
@@ -302,23 +280,23 @@ const _mapEntries = (value, f) => {
302
280
  *
303
281
  * @synopsis
304
282
  * ```coffeescript [specscript]
305
- * type FunctorWithEntries = Map|Object
283
+ * type FunctorOfEntries = Map|Object
306
284
  *
307
285
  * type EntryMapper = (
308
- * entry [key string|any, value any],
309
- * )=>(resultEntry Promise|[resultKey string|any, resultElement any])
286
+ * entry [key any, value any],
287
+ * )=>(mappedEntry Promise|[mappedKey any, mappedValue any])
310
288
  *
311
289
  * map.entries(
312
- * value Promise|FunctorWithEntries,
290
+ * functorOfEntries Promise|FunctorOfEntries,
313
291
  * mapper EntryMapper
314
- * ) -> Promise|FunctorWithEntries
292
+ * ) -> mappedFunctorWithEntries Promise|FunctorOfEntries
315
293
  *
316
- * map.entries(mapper EntryMapper)(value FunctorWithEntries)
317
- * -> Promise|FunctorWithEntries
294
+ * map.entries(mapper EntryMapper)(functorOfEntries FunctorOfEntries)
295
+ * -> mappedFunctorWithEntries Promise|FunctorOfEntries
318
296
  * ```
319
297
  *
320
298
  * @description
321
- * `map` over the entries of a functor as opposed to the values.
299
+ * [map](/docs/map) that applies the mapper function to the entries of a functor as opposed to the values.
322
300
  *
323
301
  * The following data types are considered to be functors with entries:
324
302
  * * `map`
@@ -327,46 +305,39 @@ const _mapEntries = (value, f) => {
327
305
  * The signature of the mapper function changes depending on the provided functor:
328
306
  *
329
307
  * If the functor is a map:
330
- *
331
308
  * ```coffeescript [specscript]
332
- * mapper(entry [key any, value any]) -> resultEntry Promise|[
333
- * resultKey any,
334
- * resultValue any,
335
- * ]
309
+ * mapper(entry [key any, value any]) ->
310
+ * mappedEntry Promise|[mappedKey any, mappedValue any]
336
311
  * ```
337
312
  *
338
313
  * If the functor is an object:
339
- *
340
314
  * ```coffeescript [specscript]
341
- * mapper(entry [key string, value any]) -> resultEntry Promise|[
342
- * resultKey string,
343
- * resultValue any,
344
- * ]
315
+ * mapper(entry [key string, value any]) ->
316
+ * mappedEntry Promise|[mappedKey string, mappedValue any]
345
317
  * ```
346
318
  *
347
- * `map.entries` works for objects and maps.
348
- *
349
319
  * ```javascript [playground]
350
320
  * const upperCaseKeysAndSquareValues =
351
321
  * map.entries(([key, value]) => [key.toUpperCase(), value ** 2])
352
322
  *
353
- * console.log(upperCaseKeysAndSquareValues({ a: 1, b: 2, c: 3 }))
354
- * // { A: 1, B: 4, C: 9 }
323
+ * const object = { a: 1, b: 2, c: 3 }
324
+ *
325
+ * console.log(upperCaseKeysAndSquareValues(object))
355
326
  *
356
- * console.log(upperCaseKeysAndSquareValues(new Map([['a', 1], ['b', 2], ['c', 3]])))
357
- * // Map(3) { 'A' => 1, 'B' => 4, 'C' => 9 }
327
+ * const m = new Map([['a', 1], ['b', 2], ['c', 3]])
328
+ *
329
+ * console.log(upperCaseKeysAndSquareValues(m))
358
330
  * ```
359
331
  *
360
- * Any promises passed in argument position are resolved for their values before further execution.
332
+ * If the functor with entries is a promise, it is resolved for its value before further execution for the eager interface only.
361
333
  *
362
334
  * ```javascript [playground]
363
335
  * const asyncSquareEntries = async ([k, v]) => [k, v ** 2]
364
336
  *
365
337
  * map.entries(
366
338
  * Promise.resolve({ a: 1, b: 2, c: 3 }),
367
- * asyncSquareEntries,
339
+ * asyncSquareEntries
368
340
  * ).then(console.log)
369
- * // { a: 1, b: 4, c: 9 }
370
341
  * ```
371
342
  *
372
343
  * See also:
@@ -407,27 +378,36 @@ map.entries = function mapEntries(arg0, arg1) {
407
378
  * _mapSeries(f Functor, f SyncOrAsyncMapper) -> result Promise|Functor
408
379
  * ```
409
380
  */
410
- const _mapSeries = function (collection, f) {
411
- if (isArray(collection)) {
412
- return arrayMapSeries(collection, f)
381
+ const _mapSeries = function (functor, f) {
382
+ if (isArray(functor)) {
383
+ return arrayMapSeries(functor, f)
413
384
  }
414
- if (collection == null) {
415
- throw new TypeError(`invalid collection ${collection}`)
385
+ if (functor == null) {
386
+ throw new TypeError(`invalid functor ${functor}`)
416
387
  }
417
388
 
418
- if (typeof collection == 'string' || collection.constructor == String) {
419
- return stringMapSeries(collection, f)
389
+ if (typeof functor == 'string' || functor.constructor == String) {
390
+ return stringMapSeries(functor, f)
391
+ }
392
+ if (functor.constructor == Set) {
393
+ return setMapSeries(functor, f)
394
+ }
395
+ if (functor.constructor == Map) {
396
+ return mapMapSeries(functor, f)
397
+ }
398
+ if (typeof functor[symbolIterator] == 'function') {
399
+ return MappingIterator(functor[symbolIterator](), f)
420
400
  }
421
- if (collection.constructor == Set) {
422
- return setMapSeries(collection, f)
401
+ if (typeof functor[symbolAsyncIterator] == 'function') {
402
+ return SerialMappingAsyncIterator(functor[symbolAsyncIterator](), f)
423
403
  }
424
- if (collection.constructor == Map) {
425
- return mapMapSeries(collection, f)
404
+ if (typeof functor.map == 'function') {
405
+ return functor.map(f)
426
406
  }
427
- if (collection.constructor == Object) {
428
- return objectMapSeries(collection, f)
407
+ if (functor.constructor == Object) {
408
+ return objectMapSeries(functor, f)
429
409
  }
430
- throw new TypeError(`invalid collection ${collection}`)
410
+ throw new TypeError(`invalid functor ${functor}`)
431
411
  }
432
412
 
433
413
  /**
@@ -435,21 +415,22 @@ const _mapSeries = function (collection, f) {
435
415
  *
436
416
  * @synopsis
437
417
  * ```coffeescript [specscript]
438
- * type MapSeriesFunctor = Array|Object|Set|Map
418
+ * type Functor = Array|Set|Map|Generator|AsyncGenerator|{ map: function }|Object
439
419
  *
440
420
  * type SyncOrAsyncMapper = (
441
421
  * value any,
442
422
  * indexOrKey number|string|any,
443
- * ftor MapSeriesFunctor,
423
+ * functor Functor,
444
424
  * )=>(mappedElement Promise|any)
445
425
  *
446
426
  * map.series(
447
- * ftor Promise|MapSeriesFunctor,
427
+ * functor Promise|Functor,
448
428
  * mapper SyncOrAsyncMapper
449
- * ) -> result MapSeriesFunctor
429
+ * ) -> mappedFunctor Promise|Functor
450
430
  *
451
- * map.series(mapper SyncOrAsyncMapper)(ftor MapSeriesFunctor)
452
- * -> result MapSeriesFunctor
431
+ * map.series(
432
+ * mapper SyncOrAsyncMapper
433
+ * )(functor Functor) -> mappedFunctor Promise|Functor
453
434
  * ```
454
435
  *
455
436
  * @description
@@ -467,13 +448,16 @@ const _mapSeries = function (collection, f) {
467
448
  * map.series([1, 2, 3, 4, 5], delayedLog)
468
449
  * ```
469
450
  *
470
- * Any promises passed in argument position are resolved for their values before further execution.
451
+ * If the functor is an object with a `.map` method, the mapper function signature is defined externally. Serial execution is not guaranteed in this case.
452
+ *
453
+ * If the functor is a generator, the mapper function must be synchronous.
454
+ *
455
+ * If the functor is a promise, it is resolved for its value before further execution for the eager interface only.
471
456
  *
472
457
  * ```javascript [playground]
473
458
  * const asyncSquare = async n => n ** 2
474
459
  *
475
460
  * map.series(Promise.resolve([1, 2, 3, 4, 5]), asyncSquare).then(console.log)
476
- * // [1, 4, 9, 16, 25]
477
461
  * ```
478
462
  *
479
463
  * See also:
@@ -538,13 +522,13 @@ const _mapPool = function (f, concurrency, mapper) {
538
522
  * type MapPoolFunctor = Array|Object|Set|Map
539
523
  *
540
524
  * type SyncOrAsyncMapper = (
541
- * element any,
525
+ * item any,
542
526
  * indexOrKey number|string|any,
543
- * ftor Functor
544
- * )=>(resultElement Promise|any)
527
+ * functor Functor
528
+ * )=>(mappedItem Promise|any)
545
529
  *
546
530
  * map.pool(
547
- * ftor MapPoolFunctor,
531
+ * functor MapPoolFunctor,
548
532
  * concurrency number,
549
533
  * mapper SyncOrAsyncMapper
550
534
  * ) -> result Promise|Array
@@ -552,7 +536,7 @@ const _mapPool = function (f, concurrency, mapper) {
552
536
  * map.pool(
553
537
  * concurrency number,
554
538
  * mapper SyncOrAsyncMapper
555
- * )(ftor MapPoolFunctor) -> result Promise|Array
539
+ * )(functor MapPoolFunctor) -> result Promise|Array
556
540
  * ```
557
541
  *
558
542
  * @description
@@ -574,7 +558,7 @@ const _mapPool = function (f, concurrency, mapper) {
574
558
  * ]))(ids)
575
559
  * ```
576
560
  *
577
- * Any promises passed in argument position are resolved for their values before further execution.
561
+ * Any promises passed in data argument position are resolved for their values before further execution.
578
562
  *
579
563
  * ```javascript [playground]
580
564
  * const asyncSquare = async n => n ** 2
@@ -607,24 +591,4 @@ map.pool = function mapPool(arg0, arg1, arg2) {
607
591
  : _mapPool(arg0, arg1, arg2)
608
592
  }
609
593
 
610
- /**
611
- * @name map.rate
612
- *
613
- * @synopsis
614
- * ```coffeescript [specscript]
615
- * type Functor = Array|Object|Set|Map
616
- *
617
- * map.rate(
618
- * rate number,
619
- * f (value any)=>Promise|any,
620
- * )(f Functor) -> result Promise|Array
621
- *
622
- * map.rate(
623
- * f Functor,
624
- * rate number,
625
- * f (value any)=>Promise|any,
626
- * ) -> result Promise|Array
627
- * ```
628
- */
629
-
630
594
  module.exports = map
package/monad/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  This is a place for JavaScript monads.
4
4
 
5
- Warning: this entire directory is experimental; APIs here are subject to change.
5
+ Warning: this entire directory is experimental; interfaces here are subject to change.
6
6
 
7
7
  # Specification
8
8
 
package/not.js CHANGED
@@ -59,7 +59,7 @@ const _not = function (args, predicate) {
59
59
  * not(promise).then(console.log) // true
60
60
  * ```
61
61
  *
62
- * Any promises passed in argument position are resolved for their values before further execution.
62
+ * Any promises passed in data argument position are resolved for their values before further execution.
63
63
  *
64
64
  * ```javascript [playground]
65
65
  * const isOdd = number => number % 2 == 1
package/omit.js CHANGED
@@ -20,17 +20,21 @@ const _omit = function (source, paths) {
20
20
  *
21
21
  * @synopsis
22
22
  * ```coffeescript [specscript]
23
- * omit(source Promise|Object, paths Array<string>) -> result Object
24
- * omit(paths Array<string>)(source Object) -> result Object
23
+ * paths Array<string>
24
+ *
25
+ * omit(Promise|Object, paths) -> Object
26
+ * omit(paths)(Object) -> Object
25
27
  * ```
26
28
  *
27
29
  * @description
28
- * Create a new object by excluding provided paths on a source object.
30
+ * Object constructor. Creates a new object by excluding provided paths on an argument object.
29
31
  *
30
32
  * ```javascript [playground]
31
- * console.log(
32
- * omit({ _id: '1', name: 'John' }, ['_id']),
33
- * ) // { name: 'John' }
33
+ * const argumentObject = { _id: '1', name: 'John' }
34
+ *
35
+ * const newObject = omit(argumentObject, ['_id'])
36
+ *
37
+ * console.log(newObject)
34
38
  * ```
35
39
  *
36
40
  * `omit` supports three types of path patterns for nested property access
@@ -40,33 +44,32 @@ const _omit = function (source, paths) {
40
44
  * * an array of keys or indices - `['a', 0, 'value']`
41
45
  *
42
46
  * ```javascript [playground]
43
- * console.log(
44
- * omit(['a.b.d'])({
45
- * a: {
46
- * b: {
47
- * c: 'hello',
48
- * d: 'goodbye',
49
- * },
47
+ * const omittedABD = omit(['a.b.d'])({
48
+ * a: {
49
+ * b: {
50
+ * c: 'hello',
51
+ * d: 'goodbye',
50
52
  * },
51
- * }),
52
- * ) // { a: { b: { c: 'hello' } } }
53
+ * },
54
+ * })
55
+ *
56
+ * console.log(omittedABD)
53
57
  * ```
54
58
  *
55
- * Compose `omit` inside a `pipe` with its lazy API
59
+ * `omit` supports a lazy interface for composability.
56
60
  *
57
61
  * ```javascript [playground]
58
62
  * pipe({ a: 1, b: 2, c: 3 }, [
59
63
  * map(number => number ** 2),
60
64
  * omit(['a', 'b']),
61
- * console.log, // { c: 9 }
65
+ * console.log,
62
66
  * ])
63
67
  * ```
64
68
  *
65
- * Any promises passed in argument position are resolved for their values before further execution.
69
+ * If the argument object is a promise, it is resolved for its value before further execution for the eager interface only.
66
70
  *
67
71
  * ```javascript [playground]
68
72
  * omit(Promise.resolve({ a: 1, b: 2, c: 3 }), ['a', 'b']).then(console.log)
69
- * // { c: 3 }
70
73
  * ```
71
74
  *
72
75
  * See also:
package/or.js CHANGED
@@ -145,7 +145,7 @@ const areAnyPredicatesTruthy = function (args, predicates) {
145
145
  * console.log(condition) // false
146
146
  * ```
147
147
  *
148
- * Any promises passed in argument position are resolved for their values before further execution.
148
+ * Any promises passed in data argument position are resolved for their values before further execution.
149
149
  *
150
150
  * ```javascript [playground]
151
151
  * or(Promise.resolve('aaa'), [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rubico",
3
- "version": "2.8.6",
3
+ "version": "2.10.0",
4
4
  "description": "[a]synchronous functional programming",
5
5
  "author": "Richard Tong",
6
6
  "license": "CFOSS",