rubico 2.8.0 → 2.8.2

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 (341) hide show
  1. package/LICENSE +5 -17
  2. package/README.md +1 -1
  3. package/_internal/curryArity.js +21 -1
  4. package/_internal/funcApply2.js +18 -0
  5. package/curry.js +38 -11
  6. package/dist/Transducer.es.js +5 -4
  7. package/dist/Transducer.es.min.js +5 -4
  8. package/dist/Transducer.js +5 -4
  9. package/dist/Transducer.min.js +5 -4
  10. package/dist/Transducer.mjs +5 -4
  11. package/dist/__.es.js +5 -4
  12. package/dist/__.es.min.js +5 -4
  13. package/dist/__.js +5 -4
  14. package/dist/__.min.js +5 -4
  15. package/dist/__.mjs +5 -4
  16. package/dist/all.es.js +5 -4
  17. package/dist/all.es.min.js +5 -4
  18. package/dist/all.js +5 -4
  19. package/dist/all.min.js +5 -4
  20. package/dist/all.mjs +5 -4
  21. package/dist/always.es.js +5 -4
  22. package/dist/always.es.min.js +5 -4
  23. package/dist/always.js +5 -4
  24. package/dist/always.min.js +5 -4
  25. package/dist/always.mjs +5 -4
  26. package/dist/and.es.js +5 -4
  27. package/dist/and.es.min.js +5 -4
  28. package/dist/and.js +5 -4
  29. package/dist/and.min.js +5 -4
  30. package/dist/and.mjs +5 -4
  31. package/dist/assign.es.js +5 -4
  32. package/dist/assign.es.min.js +5 -4
  33. package/dist/assign.js +5 -4
  34. package/dist/assign.min.js +5 -4
  35. package/dist/assign.mjs +5 -4
  36. package/dist/compose.es.js +5 -4
  37. package/dist/compose.es.min.js +5 -4
  38. package/dist/compose.js +5 -4
  39. package/dist/compose.min.js +5 -4
  40. package/dist/compose.mjs +5 -4
  41. package/dist/curry.es.js +136 -6
  42. package/dist/curry.es.min.js +6 -5
  43. package/dist/curry.js +136 -6
  44. package/dist/curry.min.js +6 -5
  45. package/dist/curry.mjs +136 -6
  46. package/dist/eq.es.js +5 -4
  47. package/dist/eq.es.min.js +5 -4
  48. package/dist/eq.js +5 -4
  49. package/dist/eq.min.js +5 -4
  50. package/dist/eq.mjs +5 -4
  51. package/dist/every.es.js +5 -4
  52. package/dist/every.es.min.js +5 -4
  53. package/dist/every.js +5 -4
  54. package/dist/every.min.js +5 -4
  55. package/dist/every.mjs +5 -4
  56. package/dist/filter.es.js +5 -4
  57. package/dist/filter.es.min.js +5 -4
  58. package/dist/filter.js +5 -4
  59. package/dist/filter.min.js +5 -4
  60. package/dist/filter.mjs +5 -4
  61. package/dist/flatMap.es.js +5 -4
  62. package/dist/flatMap.es.min.js +5 -4
  63. package/dist/flatMap.js +5 -4
  64. package/dist/flatMap.min.js +5 -4
  65. package/dist/flatMap.mjs +5 -4
  66. package/dist/forEach.es.js +5 -4
  67. package/dist/forEach.es.min.js +5 -4
  68. package/dist/forEach.js +5 -4
  69. package/dist/forEach.min.js +5 -4
  70. package/dist/forEach.mjs +5 -4
  71. package/dist/get.es.js +5 -4
  72. package/dist/get.es.min.js +5 -4
  73. package/dist/get.js +5 -4
  74. package/dist/get.min.js +5 -4
  75. package/dist/get.mjs +5 -4
  76. package/dist/gt.es.js +5 -4
  77. package/dist/gt.es.min.js +5 -4
  78. package/dist/gt.js +5 -4
  79. package/dist/gt.min.js +5 -4
  80. package/dist/gt.mjs +5 -4
  81. package/dist/gte.es.js +5 -4
  82. package/dist/gte.es.min.js +5 -4
  83. package/dist/gte.js +5 -4
  84. package/dist/gte.min.js +5 -4
  85. package/dist/gte.mjs +5 -4
  86. package/dist/lt.es.js +5 -4
  87. package/dist/lt.es.min.js +5 -4
  88. package/dist/lt.js +5 -4
  89. package/dist/lt.min.js +5 -4
  90. package/dist/lt.mjs +5 -4
  91. package/dist/lte.es.js +5 -4
  92. package/dist/lte.es.min.js +5 -4
  93. package/dist/lte.js +5 -4
  94. package/dist/lte.min.js +5 -4
  95. package/dist/lte.mjs +5 -4
  96. package/dist/map.es.js +45 -5
  97. package/dist/map.es.min.js +6 -5
  98. package/dist/map.js +45 -5
  99. package/dist/map.min.js +6 -5
  100. package/dist/map.mjs +45 -5
  101. package/dist/not.es.js +5 -4
  102. package/dist/not.es.min.js +5 -4
  103. package/dist/not.js +5 -4
  104. package/dist/not.min.js +5 -4
  105. package/dist/not.mjs +5 -4
  106. package/dist/omit.es.js +5 -4
  107. package/dist/omit.es.min.js +5 -4
  108. package/dist/omit.js +5 -4
  109. package/dist/omit.min.js +5 -4
  110. package/dist/omit.mjs +5 -4
  111. package/dist/or.es.js +5 -4
  112. package/dist/or.es.min.js +5 -4
  113. package/dist/or.js +5 -4
  114. package/dist/or.min.js +5 -4
  115. package/dist/or.mjs +5 -4
  116. package/dist/pick.es.js +5 -4
  117. package/dist/pick.es.min.js +5 -4
  118. package/dist/pick.js +5 -4
  119. package/dist/pick.min.js +5 -4
  120. package/dist/pick.mjs +5 -4
  121. package/dist/pipe.es.js +5 -4
  122. package/dist/pipe.es.min.js +5 -4
  123. package/dist/pipe.js +5 -4
  124. package/dist/pipe.min.js +5 -4
  125. package/dist/pipe.mjs +5 -4
  126. package/dist/reduce.es.js +5 -4
  127. package/dist/reduce.es.min.js +5 -4
  128. package/dist/reduce.js +5 -4
  129. package/dist/reduce.min.js +5 -4
  130. package/dist/reduce.mjs +5 -4
  131. package/dist/rubico.es.js +51 -9
  132. package/dist/rubico.es.min.js +6 -5
  133. package/dist/rubico.global.js +51 -9
  134. package/dist/rubico.global.min.js +6 -5
  135. package/dist/rubico.js +51 -9
  136. package/dist/rubico.min.js +6 -5
  137. package/dist/rubico.mjs +51 -9
  138. package/dist/set.es.js +5 -4
  139. package/dist/set.es.min.js +5 -4
  140. package/dist/set.js +5 -4
  141. package/dist/set.min.js +5 -4
  142. package/dist/set.mjs +5 -4
  143. package/dist/some.es.js +5 -4
  144. package/dist/some.es.min.js +5 -4
  145. package/dist/some.js +5 -4
  146. package/dist/some.min.js +5 -4
  147. package/dist/some.mjs +5 -4
  148. package/dist/switchCase.es.js +5 -4
  149. package/dist/switchCase.es.min.js +5 -4
  150. package/dist/switchCase.js +5 -4
  151. package/dist/switchCase.min.js +5 -4
  152. package/dist/switchCase.mjs +5 -4
  153. package/dist/tap.es.js +5 -4
  154. package/dist/tap.es.min.js +5 -4
  155. package/dist/tap.js +5 -4
  156. package/dist/tap.min.js +5 -4
  157. package/dist/tap.mjs +5 -4
  158. package/dist/thunkify.es.js +45 -20
  159. package/dist/thunkify.es.min.js +6 -5
  160. package/dist/thunkify.js +45 -20
  161. package/dist/thunkify.min.js +6 -5
  162. package/dist/thunkify.mjs +45 -20
  163. package/dist/transform.es.js +5 -4
  164. package/dist/transform.es.min.js +5 -4
  165. package/dist/transform.js +5 -4
  166. package/dist/transform.min.js +5 -4
  167. package/dist/transform.mjs +5 -4
  168. package/dist/tryCatch.es.js +5 -4
  169. package/dist/tryCatch.es.min.js +5 -4
  170. package/dist/tryCatch.js +5 -4
  171. package/dist/tryCatch.min.js +5 -4
  172. package/dist/tryCatch.mjs +5 -4
  173. package/dist/x/append.es.js +5 -4
  174. package/dist/x/append.es.min.js +5 -4
  175. package/dist/x/append.js +5 -4
  176. package/dist/x/append.min.js +5 -4
  177. package/dist/x/append.mjs +5 -4
  178. package/dist/x/callProp.es.js +5 -4
  179. package/dist/x/callProp.es.min.js +5 -4
  180. package/dist/x/callProp.js +5 -4
  181. package/dist/x/callProp.min.js +5 -4
  182. package/dist/x/callProp.mjs +5 -4
  183. package/dist/x/defaultsDeep.es.js +5 -4
  184. package/dist/x/defaultsDeep.es.min.js +5 -4
  185. package/dist/x/defaultsDeep.js +5 -4
  186. package/dist/x/defaultsDeep.min.js +5 -4
  187. package/dist/x/defaultsDeep.mjs +5 -4
  188. package/dist/x/differenceWith.es.js +5 -4
  189. package/dist/x/differenceWith.es.min.js +5 -4
  190. package/dist/x/differenceWith.js +5 -4
  191. package/dist/x/differenceWith.min.js +5 -4
  192. package/dist/x/differenceWith.mjs +5 -4
  193. package/dist/x/filterOut.es.js +5 -4
  194. package/dist/x/filterOut.es.min.js +5 -4
  195. package/dist/x/filterOut.js +5 -4
  196. package/dist/x/filterOut.min.js +5 -4
  197. package/dist/x/filterOut.mjs +5 -4
  198. package/dist/x/find.es.js +5 -4
  199. package/dist/x/find.es.min.js +5 -4
  200. package/dist/x/find.js +5 -4
  201. package/dist/x/find.min.js +5 -4
  202. package/dist/x/find.mjs +5 -4
  203. package/dist/x/findIndex.es.js +5 -4
  204. package/dist/x/findIndex.es.min.js +5 -4
  205. package/dist/x/findIndex.js +5 -4
  206. package/dist/x/findIndex.min.js +5 -4
  207. package/dist/x/findIndex.mjs +5 -4
  208. package/dist/x/first.es.js +5 -4
  209. package/dist/x/first.es.min.js +5 -4
  210. package/dist/x/first.js +5 -4
  211. package/dist/x/first.min.js +5 -4
  212. package/dist/x/first.mjs +5 -4
  213. package/dist/x/flatten.es.js +5 -4
  214. package/dist/x/flatten.es.min.js +5 -4
  215. package/dist/x/flatten.js +5 -4
  216. package/dist/x/flatten.min.js +5 -4
  217. package/dist/x/flatten.mjs +5 -4
  218. package/dist/x/groupBy.es.js +5 -4
  219. package/dist/x/groupBy.es.min.js +5 -4
  220. package/dist/x/groupBy.js +5 -4
  221. package/dist/x/groupBy.min.js +5 -4
  222. package/dist/x/groupBy.mjs +5 -4
  223. package/dist/x/has.es.js +5 -4
  224. package/dist/x/has.es.min.js +5 -4
  225. package/dist/x/has.js +5 -4
  226. package/dist/x/has.min.js +5 -4
  227. package/dist/x/has.mjs +5 -4
  228. package/dist/x/identity.es.js +5 -4
  229. package/dist/x/identity.es.min.js +5 -4
  230. package/dist/x/identity.js +5 -4
  231. package/dist/x/identity.min.js +5 -4
  232. package/dist/x/identity.mjs +5 -4
  233. package/dist/x/includes.es.js +5 -4
  234. package/dist/x/includes.es.min.js +5 -4
  235. package/dist/x/includes.js +5 -4
  236. package/dist/x/includes.min.js +5 -4
  237. package/dist/x/includes.mjs +5 -4
  238. package/dist/x/isDeepEqual.es.js +5 -4
  239. package/dist/x/isDeepEqual.es.min.js +5 -4
  240. package/dist/x/isDeepEqual.js +5 -4
  241. package/dist/x/isDeepEqual.min.js +5 -4
  242. package/dist/x/isDeepEqual.mjs +5 -4
  243. package/dist/x/isEmpty.es.js +5 -4
  244. package/dist/x/isEmpty.es.min.js +5 -4
  245. package/dist/x/isEmpty.js +5 -4
  246. package/dist/x/isEmpty.min.js +5 -4
  247. package/dist/x/isEmpty.mjs +5 -4
  248. package/dist/x/isEqual.es.js +5 -4
  249. package/dist/x/isEqual.es.min.js +5 -4
  250. package/dist/x/isEqual.js +5 -4
  251. package/dist/x/isEqual.min.js +5 -4
  252. package/dist/x/isEqual.mjs +5 -4
  253. package/dist/x/isFunction.es.js +5 -4
  254. package/dist/x/isFunction.es.min.js +5 -4
  255. package/dist/x/isFunction.js +5 -4
  256. package/dist/x/isFunction.min.js +5 -4
  257. package/dist/x/isFunction.mjs +5 -4
  258. package/dist/x/isIn.es.js +5 -4
  259. package/dist/x/isIn.es.min.js +5 -4
  260. package/dist/x/isIn.js +5 -4
  261. package/dist/x/isIn.min.js +5 -4
  262. package/dist/x/isIn.mjs +5 -4
  263. package/dist/x/isObject.es.js +5 -4
  264. package/dist/x/isObject.es.min.js +5 -4
  265. package/dist/x/isObject.js +5 -4
  266. package/dist/x/isObject.min.js +5 -4
  267. package/dist/x/isObject.mjs +5 -4
  268. package/dist/x/isString.es.js +5 -4
  269. package/dist/x/isString.es.min.js +5 -4
  270. package/dist/x/isString.js +5 -4
  271. package/dist/x/isString.min.js +5 -4
  272. package/dist/x/isString.mjs +5 -4
  273. package/dist/x/keys.es.js +5 -4
  274. package/dist/x/keys.es.min.js +5 -4
  275. package/dist/x/keys.js +5 -4
  276. package/dist/x/keys.min.js +5 -4
  277. package/dist/x/keys.mjs +5 -4
  278. package/dist/x/last.es.js +5 -4
  279. package/dist/x/last.es.min.js +5 -4
  280. package/dist/x/last.js +5 -4
  281. package/dist/x/last.min.js +5 -4
  282. package/dist/x/last.mjs +5 -4
  283. package/dist/x/maxBy.es.js +5 -4
  284. package/dist/x/maxBy.es.min.js +5 -4
  285. package/dist/x/maxBy.js +5 -4
  286. package/dist/x/maxBy.min.js +5 -4
  287. package/dist/x/maxBy.mjs +5 -4
  288. package/dist/x/noop.es.js +5 -4
  289. package/dist/x/noop.es.min.js +5 -4
  290. package/dist/x/noop.js +5 -4
  291. package/dist/x/noop.min.js +5 -4
  292. package/dist/x/noop.mjs +5 -4
  293. package/dist/x/pluck.es.js +45 -5
  294. package/dist/x/pluck.es.min.js +6 -5
  295. package/dist/x/pluck.js +45 -5
  296. package/dist/x/pluck.min.js +6 -5
  297. package/dist/x/pluck.mjs +45 -5
  298. package/dist/x/prepend.es.js +5 -4
  299. package/dist/x/prepend.es.min.js +5 -4
  300. package/dist/x/prepend.js +5 -4
  301. package/dist/x/prepend.min.js +5 -4
  302. package/dist/x/prepend.mjs +5 -4
  303. package/dist/x/size.es.js +5 -4
  304. package/dist/x/size.es.min.js +5 -4
  305. package/dist/x/size.js +5 -4
  306. package/dist/x/size.min.js +5 -4
  307. package/dist/x/size.mjs +5 -4
  308. package/dist/x/trace.es.js +5 -4
  309. package/dist/x/trace.es.min.js +5 -4
  310. package/dist/x/trace.js +5 -4
  311. package/dist/x/trace.min.js +5 -4
  312. package/dist/x/trace.mjs +5 -4
  313. package/dist/x/unionWith.es.js +5 -4
  314. package/dist/x/unionWith.es.min.js +5 -4
  315. package/dist/x/unionWith.js +5 -4
  316. package/dist/x/unionWith.min.js +5 -4
  317. package/dist/x/unionWith.mjs +5 -4
  318. package/dist/x/uniq.es.js +5 -4
  319. package/dist/x/uniq.es.min.js +5 -4
  320. package/dist/x/uniq.js +5 -4
  321. package/dist/x/uniq.min.js +5 -4
  322. package/dist/x/uniq.mjs +5 -4
  323. package/dist/x/unless.es.js +5 -4
  324. package/dist/x/unless.es.min.js +5 -4
  325. package/dist/x/unless.js +5 -4
  326. package/dist/x/unless.min.js +5 -4
  327. package/dist/x/unless.mjs +5 -4
  328. package/dist/x/values.es.js +5 -4
  329. package/dist/x/values.es.min.js +5 -4
  330. package/dist/x/values.js +5 -4
  331. package/dist/x/values.min.js +5 -4
  332. package/dist/x/values.mjs +5 -4
  333. package/dist/x/when.es.js +5 -4
  334. package/dist/x/when.es.min.js +5 -4
  335. package/dist/x/when.js +5 -4
  336. package/dist/x/when.min.js +5 -4
  337. package/dist/x/when.mjs +5 -4
  338. package/es.js +51 -9
  339. package/index.js +51 -9
  340. package/package.json +1 -1
  341. package/thunkify.js +66 -6
package/es.js CHANGED
@@ -1,8 +1,9 @@
1
1
  /**
2
- * rubico v2.8.0
3
- * https://github.com/a-synchronous/rubico
4
- * (c) 2019-2026 Richard Tong
5
- * rubico may be freely distributed under the MIT license.
2
+ * Rubico v2.8.2
3
+ * https://rubico.land/
4
+ *
5
+ * © Richard Yufei Tong, King of Software
6
+ * Rubico may be freely distributed under the CFOSS license.
6
7
  */
7
8
 
8
9
  const isArray = Array.isArray
@@ -1062,6 +1063,8 @@ const objectMapPool = function (o, concurrency, f) {
1062
1063
  return result
1063
1064
  }
1064
1065
 
1066
+ const funcApply2 = (func, context, args) => func.apply(context, args)
1067
+
1065
1068
  const _curryArity = (arity, func, context, args) => function curried(...curriedArgs) {
1066
1069
  const argsLength = args.length,
1067
1070
  curriedArgsLength = curriedArgs.length,
@@ -1081,7 +1084,13 @@ const _curryArity = (arity, func, context, args) => function curried(...curriedA
1081
1084
  } else {
1082
1085
  nextArgs.push(arg)
1083
1086
  }
1087
+
1084
1088
  if (nextArgs.length == arity) {
1089
+ if (areAnyValuesPromises(nextArgs)) {
1090
+ return numCurriedPlaceholders == 0
1091
+ ? promiseAll(nextArgs).then(curry3(funcApply2, func, context, __))
1092
+ : promiseAll(nextArgs).then(curry4(curryArity, arity, func, context, __))
1093
+ }
1085
1094
  return numCurriedPlaceholders == 0
1086
1095
  ? func.apply(context, nextArgs)
1087
1096
  : curryArity(arity, func, context, nextArgs)
@@ -1094,13 +1103,22 @@ const _curryArity = (arity, func, context, args) => function curried(...curriedA
1094
1103
  numCurriedPlaceholders += 1
1095
1104
  }
1096
1105
  nextArgs.push(curriedArg)
1106
+
1097
1107
  if (nextArgs.length == arity) {
1108
+ if (areAnyValuesPromises(nextArgs)) {
1109
+ return numCurriedPlaceholders == 0
1110
+ ? promiseAll(nextArgs).then(curry3(funcApply2, func, context, __))
1111
+ : promiseAll(nextArgs).then(curry4(curryArity, arity, func, context, __))
1112
+ }
1098
1113
  return numCurriedPlaceholders == 0
1099
1114
  ? func.apply(context, nextArgs)
1100
1115
  : curryArity(arity, func, context, nextArgs)
1101
1116
  }
1102
1117
  }
1103
- return curryArity(arity, func, context, nextArgs)
1118
+
1119
+ return areAnyValuesPromises(nextArgs)
1120
+ ? promiseAll(nextArgs).then(curry4(curryArity, arity, func, context, __))
1121
+ : curryArity(arity, func, context, nextArgs)
1104
1122
  }
1105
1123
 
1106
1124
  const curryArity = function (arity, func, context, args) {
@@ -3278,20 +3296,44 @@ const omit = function (arg0, arg1) {
3278
3296
  return _omit(arg0, arg1)
3279
3297
  }
3280
3298
 
3281
- const thunkify = (func, ...args) => function thunk() {
3299
+ function _thunkifyArgs(func, context, args) {
3300
+ return function thunk() {
3301
+ return func.apply(context, args)
3302
+ }
3303
+ }
3304
+
3305
+ const thunkify = function thunkify(func, ...args) {
3282
3306
  if (areAnyValuesPromises(args)) {
3283
- return promiseAll(args).then(curry2(funcApply, func, __))
3307
+ return promiseAll(args).then(curry3(_thunkifyArgs, func, this, __))
3284
3308
  }
3285
- return func(...args)
3309
+ return _thunkifyArgs(func, this, args)
3286
3310
  }
3287
3311
 
3288
- const curry = (func, ...args) => curryArity(func.length, func, this, args)
3312
+ thunkify.call = function thunkifyCall(func, context, ...args) {
3313
+ if (areAnyValuesPromises(args)) {
3314
+ return promiseAll(args).then(curry3(_thunkifyArgs, func, context, __))
3315
+ }
3316
+ return _thunkifyArgs(func, context, args)
3317
+ }
3318
+
3319
+ const curry = (func, ...args) => {
3320
+ if (areAnyValuesPromises(args)) {
3321
+ return promiseAll(args).then(curry4(curryArity, func.length, func, this, __))
3322
+ }
3323
+ return curryArity(func.length, func, this, args)
3324
+ }
3289
3325
 
3290
3326
  curry.arity = function curryArity_(arity, func, ...args) {
3327
+ if (areAnyValuesPromises(args)) {
3328
+ return promiseAll(args).then(curry4(curryArity, arity, func, this, __))
3329
+ }
3291
3330
  return curryArity(arity, func, this, args)
3292
3331
  }
3293
3332
 
3294
3333
  curry.call = function call(func, context, ...args) {
3334
+ if (areAnyValuesPromises(args)) {
3335
+ return promiseAll(args).then(curry4(curryArity, func.length, func, context, __))
3336
+ }
3295
3337
  return curryArity(func.length, func, context, args)
3296
3338
  }
3297
3339
 
package/index.js CHANGED
@@ -1,8 +1,9 @@
1
1
  /**
2
- * rubico v2.8.0
3
- * https://github.com/a-synchronous/rubico
4
- * (c) 2019-2026 Richard Tong
5
- * rubico may be freely distributed under the MIT license.
2
+ * Rubico v2.8.2
3
+ * https://rubico.land/
4
+ *
5
+ * © Richard Yufei Tong, King of Software
6
+ * Rubico may be freely distributed under the CFOSS license.
6
7
  */
7
8
 
8
9
  (function (root, rubico) {
@@ -1068,6 +1069,8 @@ const objectMapPool = function (o, concurrency, f) {
1068
1069
  return result
1069
1070
  }
1070
1071
 
1072
+ const funcApply2 = (func, context, args) => func.apply(context, args)
1073
+
1071
1074
  const _curryArity = (arity, func, context, args) => function curried(...curriedArgs) {
1072
1075
  const argsLength = args.length,
1073
1076
  curriedArgsLength = curriedArgs.length,
@@ -1087,7 +1090,13 @@ const _curryArity = (arity, func, context, args) => function curried(...curriedA
1087
1090
  } else {
1088
1091
  nextArgs.push(arg)
1089
1092
  }
1093
+
1090
1094
  if (nextArgs.length == arity) {
1095
+ if (areAnyValuesPromises(nextArgs)) {
1096
+ return numCurriedPlaceholders == 0
1097
+ ? promiseAll(nextArgs).then(curry3(funcApply2, func, context, __))
1098
+ : promiseAll(nextArgs).then(curry4(curryArity, arity, func, context, __))
1099
+ }
1091
1100
  return numCurriedPlaceholders == 0
1092
1101
  ? func.apply(context, nextArgs)
1093
1102
  : curryArity(arity, func, context, nextArgs)
@@ -1100,13 +1109,22 @@ const _curryArity = (arity, func, context, args) => function curried(...curriedA
1100
1109
  numCurriedPlaceholders += 1
1101
1110
  }
1102
1111
  nextArgs.push(curriedArg)
1112
+
1103
1113
  if (nextArgs.length == arity) {
1114
+ if (areAnyValuesPromises(nextArgs)) {
1115
+ return numCurriedPlaceholders == 0
1116
+ ? promiseAll(nextArgs).then(curry3(funcApply2, func, context, __))
1117
+ : promiseAll(nextArgs).then(curry4(curryArity, arity, func, context, __))
1118
+ }
1104
1119
  return numCurriedPlaceholders == 0
1105
1120
  ? func.apply(context, nextArgs)
1106
1121
  : curryArity(arity, func, context, nextArgs)
1107
1122
  }
1108
1123
  }
1109
- return curryArity(arity, func, context, nextArgs)
1124
+
1125
+ return areAnyValuesPromises(nextArgs)
1126
+ ? promiseAll(nextArgs).then(curry4(curryArity, arity, func, context, __))
1127
+ : curryArity(arity, func, context, nextArgs)
1110
1128
  }
1111
1129
 
1112
1130
  const curryArity = function (arity, func, context, args) {
@@ -3284,20 +3302,44 @@ const omit = function (arg0, arg1) {
3284
3302
  return _omit(arg0, arg1)
3285
3303
  }
3286
3304
 
3287
- const thunkify = (func, ...args) => function thunk() {
3305
+ function _thunkifyArgs(func, context, args) {
3306
+ return function thunk() {
3307
+ return func.apply(context, args)
3308
+ }
3309
+ }
3310
+
3311
+ const thunkify = function thunkify(func, ...args) {
3288
3312
  if (areAnyValuesPromises(args)) {
3289
- return promiseAll(args).then(curry2(funcApply, func, __))
3313
+ return promiseAll(args).then(curry3(_thunkifyArgs, func, this, __))
3290
3314
  }
3291
- return func(...args)
3315
+ return _thunkifyArgs(func, this, args)
3292
3316
  }
3293
3317
 
3294
- const curry = (func, ...args) => curryArity(func.length, func, this, args)
3318
+ thunkify.call = function thunkifyCall(func, context, ...args) {
3319
+ if (areAnyValuesPromises(args)) {
3320
+ return promiseAll(args).then(curry3(_thunkifyArgs, func, context, __))
3321
+ }
3322
+ return _thunkifyArgs(func, context, args)
3323
+ }
3324
+
3325
+ const curry = (func, ...args) => {
3326
+ if (areAnyValuesPromises(args)) {
3327
+ return promiseAll(args).then(curry4(curryArity, func.length, func, this, __))
3328
+ }
3329
+ return curryArity(func.length, func, this, args)
3330
+ }
3295
3331
 
3296
3332
  curry.arity = function curryArity_(arity, func, ...args) {
3333
+ if (areAnyValuesPromises(args)) {
3334
+ return promiseAll(args).then(curry4(curryArity, arity, func, this, __))
3335
+ }
3297
3336
  return curryArity(arity, func, this, args)
3298
3337
  }
3299
3338
 
3300
3339
  curry.call = function call(func, context, ...args) {
3340
+ if (areAnyValuesPromises(args)) {
3341
+ return promiseAll(args).then(curry4(curryArity, func.length, func, context, __))
3342
+ }
3301
3343
  return curryArity(func.length, func, context, args)
3302
3344
  }
3303
3345
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rubico",
3
- "version": "2.8.0",
3
+ "version": "2.8.2",
4
4
  "description": "[a]synchronous functional programming",
5
5
  "author": "Richard Tong",
6
6
  "license": "MIT",
package/thunkify.js CHANGED
@@ -1,8 +1,22 @@
1
1
  const areAnyValuesPromises = require('./_internal/areAnyValuesPromises')
2
2
  const promiseAll = require('./_internal/promiseAll')
3
- const curry2 = require('./_internal/curry2')
3
+ const curry3 = require('./_internal/curry3')
4
4
  const __ = require('./_internal/placeholder')
5
- const funcApply = require('./_internal/funcApply')
5
+ const funcApply2 = require('./_internal/funcApply2')
6
+
7
+ /**
8
+ * @name _thunkifyArgs
9
+ *
10
+ * @synopsis
11
+ * ```coffeescript [specscript]
12
+ * _thunkifyArgs(func function, context object, args Array) -> thunk
13
+ * ```
14
+ */
15
+ function _thunkifyArgs(func, context, args) {
16
+ return function thunk() {
17
+ return func.apply(context, args)
18
+ }
19
+ }
6
20
 
7
21
  /**
8
22
  * @name thunkify
@@ -15,7 +29,7 @@ const funcApply = require('./_internal/funcApply')
15
29
  * ```
16
30
  *
17
31
  * @description
18
- * Create a thunk function from another function and any number of arguments. The thunk function takes no arguments, and when called, executes the other function with the provided arguments. The other function is said to be "thunkified".
32
+ * Creates a thunk from a function and arguments. A thunk takes no arguments, and when called, executes the other function with the arguments. The other function is said to be "thunkified".
19
33
  *
20
34
  * ```javascript [playground]
21
35
  * const add = (a, b) => a + b
@@ -27,17 +41,63 @@ const funcApply = require('./_internal/funcApply')
27
41
  *
28
42
  * See also:
29
43
  * * [eq](/docs/eq)
44
+ * * [thunkify.call](/docs/thunkify.call)
45
+ * * [always](/docs/always)
46
+ * * [curry](/docs/curry)
47
+ * * [__](/docs/__)
48
+ * * [Transducer.map](/docs/Transducer.map)
49
+ *
50
+ */
51
+ const thunkify = function thunkify(func, ...args) {
52
+ if (areAnyValuesPromises(args)) {
53
+ return promiseAll(args).then(curry3(_thunkifyArgs, func, this, __))
54
+ }
55
+ return _thunkifyArgs(func, this, args)
56
+ }
57
+
58
+ /**
59
+ * @name thunkify.call
60
+ *
61
+ * @synopsis
62
+ * ```coffeescript [specscript]
63
+ * args Array<any>
64
+ *
65
+ * thunkify.call(func function, context object, ...args) -> thunk ()=>func(...args)
66
+ * ```
67
+ *
68
+ * Creates a thunk that calls a function with the specified context and arguments.
69
+ *
70
+ * ```javascript [playground]
71
+ * class Point {
72
+ * constructor(x, y) {
73
+ * this.x = x
74
+ * this.y = y
75
+ * }
76
+ *
77
+ * toString() {
78
+ * return `(${this.x}, ${this.y})`
79
+ * }
80
+ * }
81
+ *
82
+ * const thunk = thunkify.call(toString, point)
83
+ *
84
+ * console.log(thunk())
85
+ * ```
86
+ *
87
+ * See also:
88
+ * * [eq](/docs/eq)
89
+ * * [thunkify](/docs/thunkify)
30
90
  * * [always](/docs/always)
31
91
  * * [curry](/docs/curry)
32
92
  * * [__](/docs/__)
33
93
  * * [Transducer.map](/docs/Transducer.map)
34
94
  *
35
95
  */
36
- const thunkify = (func, ...args) => function thunk() {
96
+ thunkify.call = function thunkifyCall(func, context, ...args) {
37
97
  if (areAnyValuesPromises(args)) {
38
- return promiseAll(args).then(curry2(funcApply, func, __))
98
+ return promiseAll(args).then(curry3(_thunkifyArgs, func, context, __))
39
99
  }
40
- return func(...args)
100
+ return _thunkifyArgs(func, context, args)
41
101
  }
42
102
 
43
103
  module.exports = thunkify