rambda 9.4.2 → 10.0.0-beta.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 (271) hide show
  1. package/CHANGELOG.md +177 -1
  2. package/README.md +6799 -11799
  3. package/dist/rambda.cjs +1795 -0
  4. package/dist/rambda.js +1162 -2234
  5. package/dist/rambda.umd.js +1801 -1
  6. package/immutable.d.ts +1154 -1403
  7. package/index.d.ts +1154 -1403
  8. package/package.json +102 -94
  9. package/rambda.js +24 -137
  10. package/src/_internals/baseSlice.js +5 -7
  11. package/src/_internals/createPath.js +4 -6
  12. package/src/_internals/includes.js +8 -4
  13. package/src/_internals/set.js +11 -11
  14. package/src/addProp.js +3 -0
  15. package/src/all.js +8 -6
  16. package/src/allPass.js +4 -4
  17. package/src/any.js +10 -10
  18. package/src/anyPass.js +4 -4
  19. package/src/append.js +6 -8
  20. package/src/ascend.js +8 -15
  21. package/src/checkObjectWithSpec.js +16 -0
  22. package/src/compact.js +12 -0
  23. package/src/complement.js +1 -1
  24. package/src/concat.js +2 -4
  25. package/src/count.js +7 -6
  26. package/src/countBy.js +13 -14
  27. package/src/createObjectFromKeys.js +10 -0
  28. package/src/defaultTo.js +4 -6
  29. package/src/descend.js +6 -13
  30. package/src/drop.js +4 -2
  31. package/src/dropLast.js +2 -8
  32. package/src/dropLastWhile.js +17 -26
  33. package/src/dropWhile.js +14 -22
  34. package/src/eqBy.js +3 -8
  35. package/src/eqProps.js +3 -9
  36. package/src/equals.js +99 -58
  37. package/src/evolve.js +3 -57
  38. package/src/excludes.js +5 -0
  39. package/src/filter.js +13 -43
  40. package/src/filterObject.js +13 -0
  41. package/src/find.js +10 -10
  42. package/src/findIndex.js +10 -10
  43. package/src/findLast.js +9 -9
  44. package/src/findLastIndex.js +9 -9
  45. package/src/findNth.js +16 -0
  46. package/src/flatMap.js +3 -0
  47. package/src/flatten.js +5 -5
  48. package/src/groupBy.js +14 -11
  49. package/src/head.js +5 -3
  50. package/src/includes.js +13 -11
  51. package/src/indexOf.js +2 -6
  52. package/src/init.js +6 -8
  53. package/src/innerJoin.js +11 -19
  54. package/src/interpolate.js +29 -0
  55. package/src/intersection.js +2 -4
  56. package/src/intersperse.js +13 -13
  57. package/src/join.js +2 -4
  58. package/src/last.js +4 -4
  59. package/src/lastIndexOf.js +2 -6
  60. package/src/map.js +9 -49
  61. package/src/mapAsync.js +11 -0
  62. package/src/mapKeys.js +11 -0
  63. package/src/mapObject.js +18 -0
  64. package/src/mapObjectAsync.js +10 -0
  65. package/src/mapParallelAsync.js +3 -0
  66. package/src/match.js +5 -5
  67. package/src/maxBy.js +2 -8
  68. package/src/merge.js +4 -1
  69. package/src/mergeTypes.js +3 -0
  70. package/src/minBy.js +2 -8
  71. package/src/modifyProp.js +20 -0
  72. package/src/none.js +8 -6
  73. package/src/objOf.js +2 -6
  74. package/src/objectIncludes.js +12 -0
  75. package/src/omit.js +26 -11
  76. package/src/partition.js +15 -42
  77. package/src/partitionObject.js +15 -0
  78. package/src/path.js +14 -15
  79. package/src/permutations.js +40 -0
  80. package/src/pick.js +15 -15
  81. package/src/pipe.js +70 -13
  82. package/src/pipeAsync.js +11 -0
  83. package/src/pluck.js +12 -14
  84. package/src/prepend.js +2 -6
  85. package/src/prop.js +2 -10
  86. package/src/propEq.js +8 -10
  87. package/src/propOr.js +7 -8
  88. package/src/propSatisfies.js +2 -9
  89. package/src/range.js +34 -11
  90. package/src/reduce.js +15 -30
  91. package/src/reject.js +2 -4
  92. package/src/rejectObject.js +13 -0
  93. package/src/replace.js +2 -8
  94. package/src/replaceItemAtIndex.js +15 -0
  95. package/src/shuffle.js +13 -0
  96. package/src/sort.js +2 -4
  97. package/src/sortBy.js +12 -10
  98. package/src/sortObject.js +15 -0
  99. package/src/sortWith.js +12 -16
  100. package/src/split.js +2 -4
  101. package/src/splitEvery.js +11 -13
  102. package/src/symmetricDifference.js +5 -8
  103. package/src/tail.js +2 -2
  104. package/src/take.js +11 -9
  105. package/src/takeLast.js +14 -14
  106. package/src/takeLastWhile.js +15 -16
  107. package/src/takeWhile.js +12 -21
  108. package/src/tap.js +5 -5
  109. package/src/test.js +2 -8
  110. package/src/tryCatch.js +5 -14
  111. package/src/type.js +6 -5
  112. package/src/union.js +10 -8
  113. package/src/uniq.js +2 -2
  114. package/src/uniqBy.js +5 -6
  115. package/src/uniqWith.js +15 -19
  116. package/src/unless.js +7 -9
  117. package/src/unwind.js +6 -14
  118. package/src/update.js +8 -11
  119. package/src/when.js +7 -9
  120. package/src/zip.js +8 -8
  121. package/src/zipWith.js +5 -7
  122. package/src/F.js +0 -3
  123. package/src/T.js +0 -3
  124. package/src/_internals/_arity.js +0 -64
  125. package/src/_internals/compare.js +0 -3
  126. package/src/_internals/constants.js +0 -1
  127. package/src/_internals/createPathInput.js +0 -7
  128. package/src/_internals/isFalsy.js +0 -13
  129. package/src/_internals/isInteger.js +0 -10
  130. package/src/_internals/isIterable.js +0 -5
  131. package/src/_internals/isObject.js +0 -5
  132. package/src/_internals/isTruthy.js +0 -13
  133. package/src/_internals/objectIs.js +0 -9
  134. package/src/_internals/utils.js +0 -21
  135. package/src/add.js +0 -5
  136. package/src/addIndex.js +0 -23
  137. package/src/addIndexRight.js +0 -9
  138. package/src/adjust.js +0 -16
  139. package/src/always.js +0 -3
  140. package/src/and.js +0 -5
  141. package/src/ap.js +0 -7
  142. package/src/aperture.js +0 -15
  143. package/src/apply.js +0 -7
  144. package/src/applySpec.js +0 -132
  145. package/src/applyTo.js +0 -7
  146. package/src/assoc.js +0 -11
  147. package/src/assocPath.js +0 -46
  148. package/src/binary.js +0 -5
  149. package/src/bind.js +0 -9
  150. package/src/both.js +0 -5
  151. package/src/call.js +0 -1
  152. package/src/chain.js +0 -7
  153. package/src/clamp.js +0 -15
  154. package/src/clone.js +0 -18
  155. package/src/collectBy.js +0 -27
  156. package/src/comparator.js +0 -5
  157. package/src/compose.js +0 -9
  158. package/src/composeWith.js +0 -33
  159. package/src/cond.js +0 -14
  160. package/src/converge.js +0 -18
  161. package/src/curry.js +0 -7
  162. package/src/curryN.js +0 -40
  163. package/src/dec.js +0 -1
  164. package/src/difference.js +0 -8
  165. package/src/differenceWith.js +0 -20
  166. package/src/dissoc.js +0 -13
  167. package/src/dissocPath.js +0 -47
  168. package/src/divide.js +0 -5
  169. package/src/dropRepeats.js +0 -20
  170. package/src/dropRepeatsBy.js +0 -21
  171. package/src/dropRepeatsWith.js +0 -28
  172. package/src/either.js +0 -8
  173. package/src/empty.js +0 -15
  174. package/src/endsWith.js +0 -23
  175. package/src/flip.js +0 -23
  176. package/src/forEach.js +0 -19
  177. package/src/forEachObjIndexed.js +0 -24
  178. package/src/fromPairs.js +0 -6
  179. package/src/groupWith.js +0 -46
  180. package/src/gt.js +0 -6
  181. package/src/gte.js +0 -6
  182. package/src/has.js +0 -7
  183. package/src/hasIn.js +0 -9
  184. package/src/hasPath.js +0 -9
  185. package/src/identical.js +0 -7
  186. package/src/identity.js +0 -3
  187. package/src/ifElse.js +0 -17
  188. package/src/inc.js +0 -1
  189. package/src/indexBy.js +0 -29
  190. package/src/insert.js +0 -11
  191. package/src/insertAll.js +0 -7
  192. package/src/is.js +0 -8
  193. package/src/isEmpty.js +0 -18
  194. package/src/isNil.js +0 -3
  195. package/src/isNotEmpty.js +0 -5
  196. package/src/isNotNil.js +0 -3
  197. package/src/isPromise.js +0 -5
  198. package/src/juxt.js +0 -3
  199. package/src/keys.js +0 -3
  200. package/src/length.js +0 -8
  201. package/src/lens.js +0 -7
  202. package/src/lensIndex.js +0 -7
  203. package/src/lensPath.js +0 -7
  204. package/src/lensProp.js +0 -7
  205. package/src/lt.js +0 -6
  206. package/src/lte.js +0 -6
  207. package/src/mathMod.js +0 -8
  208. package/src/max.js +0 -5
  209. package/src/maybe.js +0 -13
  210. package/src/mean.js +0 -5
  211. package/src/median.js +0 -17
  212. package/src/mergeAll.js +0 -11
  213. package/src/mergeDeepLeft.js +0 -5
  214. package/src/mergeDeepRight.js +0 -24
  215. package/src/mergeLeft.js +0 -7
  216. package/src/mergeRight.js +0 -8
  217. package/src/mergeWith.js +0 -25
  218. package/src/min.js +0 -5
  219. package/src/modify.js +0 -23
  220. package/src/modifyPath.js +0 -33
  221. package/src/modulo.js +0 -5
  222. package/src/move.js +0 -19
  223. package/src/multiply.js +0 -5
  224. package/src/negate.js +0 -3
  225. package/src/not.js +0 -3
  226. package/src/nth.js +0 -9
  227. package/src/of.js +0 -3
  228. package/src/on.js +0 -16
  229. package/src/once.js +0 -24
  230. package/src/or.js +0 -5
  231. package/src/over.js +0 -14
  232. package/src/partial.js +0 -17
  233. package/src/partialObject.js +0 -5
  234. package/src/pathEq.js +0 -11
  235. package/src/pathOr.js +0 -11
  236. package/src/pathSatisfies.js +0 -9
  237. package/src/paths.js +0 -9
  238. package/src/pickAll.js +0 -23
  239. package/src/pickBy.js +0 -11
  240. package/src/product.js +0 -4
  241. package/src/propIs.js +0 -10
  242. package/src/props.js +0 -13
  243. package/src/reduceBy.js +0 -29
  244. package/src/removeIndex.js +0 -7
  245. package/src/repeat.js +0 -7
  246. package/src/reverse.js +0 -9
  247. package/src/set.js +0 -9
  248. package/src/slice.js +0 -9
  249. package/src/splitAt.js +0 -21
  250. package/src/splitWhen.js +0 -25
  251. package/src/startsWith.js +0 -23
  252. package/src/subtract.js +0 -5
  253. package/src/sum.js +0 -3
  254. package/src/swap.js +0 -42
  255. package/src/times.js +0 -12
  256. package/src/toLower.js +0 -3
  257. package/src/toPairs.js +0 -3
  258. package/src/toString.js +0 -3
  259. package/src/toUpper.js +0 -3
  260. package/src/transpose.js +0 -10
  261. package/src/trim.js +0 -3
  262. package/src/unapply.js +0 -5
  263. package/src/unnest.js +0 -9
  264. package/src/values.js +0 -6
  265. package/src/view.js +0 -10
  266. package/src/where.js +0 -15
  267. package/src/whereAny.js +0 -12
  268. package/src/whereEq.js +0 -14
  269. package/src/without.js +0 -15
  270. package/src/xor.js +0 -5
  271. package/src/zipObj.js +0 -13
@@ -0,0 +1,10 @@
1
+ export function mapObjectAsync(fn) {
2
+ return async obj => {
3
+ const willReturn = {}
4
+ for (const prop in obj) {
5
+ willReturn[prop] = await fn(obj[prop], prop)
6
+ }
7
+
8
+ return willReturn
9
+ }
10
+ }
@@ -0,0 +1,3 @@
1
+ export function mapParallelAsync(fn) {
2
+ return async list => Promise.all(list.map((x, i) => fn(x, i)))
3
+ }
package/src/match.js CHANGED
@@ -1,7 +1,7 @@
1
- export function match(pattern, input){
2
- if (arguments.length === 1) return _input => match(pattern, _input)
1
+ export function match(pattern) {
2
+ return input => {
3
+ const willReturn = input.match(pattern)
3
4
 
4
- const willReturn = input.match(pattern)
5
-
6
- return willReturn === null ? [] : willReturn
5
+ return willReturn === null ? [] : willReturn
6
+ }
7
7
  }
package/src/maxBy.js CHANGED
@@ -1,9 +1,3 @@
1
- import { curry } from './curry.js'
2
-
3
- export function maxByFn(
4
- compareFn, x, y
5
- ){
6
- return compareFn(y) > compareFn(x) ? y : x
1
+ export function maxBy(compareFn, x) {
2
+ return y => (compareFn(y) > compareFn(x) ? y : x)
7
3
  }
8
-
9
- export const maxBy = curry(maxByFn)
package/src/merge.js CHANGED
@@ -1 +1,4 @@
1
- export { mergeRight as merge } from './mergeRight.js'
1
+ export function merge(target) {
2
+ return objectWithNewProps =>
3
+ Object.assign({}, target || {}, objectWithNewProps || {})
4
+ }
@@ -0,0 +1,3 @@
1
+ export function mergeTypes(x) {
2
+ return x
3
+ }
package/src/minBy.js CHANGED
@@ -1,9 +1,3 @@
1
- import { curry } from './curry.js'
2
-
3
- export function minByFn(
4
- compareFn, x, y
5
- ){
6
- return compareFn(y) < compareFn(x) ? y : x
1
+ export function minBy(compareFn, x) {
2
+ return y => (compareFn(y) < compareFn(x) ? y : x)
7
3
  }
8
-
9
- export const minBy = curry(minByFn)
@@ -0,0 +1,20 @@
1
+ import { isArray } from './_internals/isArray.js'
2
+ import { update } from './update.js'
3
+
4
+ function modifyFn(property, fn, list) {
5
+ if (list[property] === undefined) {
6
+ return list
7
+ }
8
+ if (isArray(list)) {
9
+ return update(property, fn(list[property]))(list)
10
+ }
11
+
12
+ return {
13
+ ...list,
14
+ [property]: fn(list[property]),
15
+ }
16
+ }
17
+
18
+ export function modifyProp(property, fn) {
19
+ return obj => modifyFn(property, fn, obj)
20
+ }
package/src/none.js CHANGED
@@ -1,9 +1,11 @@
1
- export function none(predicate, list){
2
- if (arguments.length === 1) return _list => none(predicate, _list)
1
+ export function none(predicate) {
2
+ return list => {
3
+ for (let i = 0; i < list.length; i++) {
4
+ if (predicate(list[i])) {
5
+ return false
6
+ }
7
+ }
3
8
 
4
- for (let i = 0; i < list.length; i++){
5
- if (predicate(list[ i ])) return false
9
+ return true
6
10
  }
7
-
8
- return true
9
11
  }
package/src/objOf.js CHANGED
@@ -1,7 +1,3 @@
1
- export function objOf(key, value){
2
- if (arguments.length === 1){
3
- return _value => objOf(key, _value)
4
- }
5
-
6
- return { [ key ] : value }
1
+ export function objOf(key) {
2
+ return value => ({ [key]: value })
7
3
  }
@@ -0,0 +1,12 @@
1
+ import { equals } from './equals.js'
2
+ import { filterObject } from './filterObject.js'
3
+
4
+ export function objectIncludes(condition) {
5
+ return obj => {
6
+ const result = filterObject((conditionValue, conditionProp) =>
7
+ equals(conditionValue)(obj[conditionProp]),
8
+ )(condition)
9
+
10
+ return Object.keys(result).length === Object.keys(condition).length
11
+ }
12
+ }
package/src/omit.js CHANGED
@@ -1,18 +1,33 @@
1
1
  import { createPath } from './_internals/createPath.js'
2
- import { includes } from './_internals/includes.js'
3
2
 
4
- export function omit(propsToOmit, obj){
5
- if (arguments.length === 1) return _obj => omit(propsToOmit, _obj)
3
+ export function _includes(x, list) {
4
+ let index = -1
5
+ const { length } = list
6
6
 
7
- if (obj === null || obj === undefined)
8
- return undefined
7
+ while (++index < length) {
8
+ if (String(list[index]) === String(x)) {
9
+ return true
10
+ }
11
+ }
9
12
 
10
- const propsToOmitValue = createPath(propsToOmit, ',')
11
- const willReturn = {}
13
+ return false
14
+ }
15
+
16
+ export function omit(propsToOmit) {
17
+ return obj => {
18
+ if (!obj) {
19
+ return undefined
20
+ }
21
+
22
+ const propsToOmitValue = createPath(propsToOmit, ',')
23
+ const willReturn = {}
12
24
 
13
- for (const key in obj)
14
- if (!includes(key, propsToOmitValue))
15
- willReturn[ key ] = obj[ key ]
25
+ for (const key in obj) {
26
+ if (!_includes(key, propsToOmitValue)) {
27
+ willReturn[key] = obj[key]
28
+ }
29
+ }
16
30
 
17
- return willReturn
31
+ return willReturn
32
+ }
18
33
  }
package/src/partition.js CHANGED
@@ -1,44 +1,17 @@
1
- import { isArray } from './_internals/isArray.js'
2
-
3
- export function partitionObject(predicate, iterable){
4
- const yes = {}
5
- const no = {}
6
- Object.entries(iterable).forEach(([ prop, value ]) => {
7
- if (predicate(value, prop)){
8
- yes[ prop ] = value
9
- } else {
10
- no[ prop ] = value
11
- }
12
- })
13
-
14
- return [ yes, no ]
15
- }
16
-
17
- export function partitionArray(
18
- predicate, list, indexed = false
19
- ){
20
- const yes = []
21
- const no = []
22
- let counter = -1
23
-
24
- while (counter++ < list.length - 1){
25
- if (
26
- indexed ? predicate(list[ counter ], counter) : predicate(list[ counter ])
27
- ){
28
- yes.push(list[ counter ])
29
- } else {
30
- no.push(list[ counter ])
31
- }
32
- }
33
-
34
- return [ yes, no ]
35
- }
36
-
37
- export function partition(predicate, iterable){
38
- if (arguments.length === 1){
39
- return listHolder => partition(predicate, listHolder)
1
+ export function partition(predicate) {
2
+ return list => {
3
+ const yes = []
4
+ const no = []
5
+ let counter = -1
6
+
7
+ while (counter++ < list.length - 1) {
8
+ if (predicate(list[counter], counter)) {
9
+ yes.push(list[counter])
10
+ } else {
11
+ no.push(list[counter])
12
+ }
13
+ }
14
+
15
+ return [yes, no]
40
16
  }
41
- if (!isArray(iterable)) return partitionObject(predicate, iterable)
42
-
43
- return partitionArray(predicate, iterable)
44
17
  }
@@ -0,0 +1,15 @@
1
+ export function partitionObject(predicate) {
2
+ return obj => {
3
+ const yes = {}
4
+ const no = {}
5
+ Object.entries(obj).forEach(([prop, value]) => {
6
+ if (predicate(value, prop)) {
7
+ yes[prop] = value
8
+ } else {
9
+ no[prop] = value
10
+ }
11
+ })
12
+
13
+ return [yes, no]
14
+ }
15
+ }
package/src/path.js CHANGED
@@ -1,30 +1,29 @@
1
1
  import { createPath } from './_internals/createPath.js'
2
2
 
3
- export function pathFn(pathInput, obj){
3
+ export function path(pathInput, obj) {
4
+ if (arguments.length === 1) {
5
+ return _obj => path(pathInput, _obj)
6
+ }
7
+
8
+ if (!obj) {
9
+ return undefined
10
+ }
4
11
  let willReturn = obj
5
12
  let counter = 0
6
13
 
7
14
  const pathArrValue = createPath(pathInput)
8
15
 
9
- while (counter < pathArrValue.length){
10
- if (willReturn === null || willReturn === undefined){
16
+ while (counter < pathArrValue.length) {
17
+ if (willReturn === null || willReturn === undefined) {
18
+ return undefined
19
+ }
20
+ if (willReturn[pathArrValue[counter]] === null) {
11
21
  return undefined
12
22
  }
13
- if (willReturn[ pathArrValue[ counter ] ] === null) return undefined
14
23
 
15
- willReturn = willReturn[ pathArrValue[ counter ] ]
24
+ willReturn = willReturn[pathArrValue[counter]]
16
25
  counter++
17
26
  }
18
27
 
19
28
  return willReturn
20
29
  }
21
-
22
- export function path(pathInput, obj){
23
- if (arguments.length === 1) return _obj => path(pathInput, _obj)
24
-
25
- if (obj === null || obj === undefined){
26
- return undefined
27
- }
28
-
29
- return pathFn(pathInput, obj)
30
- }
@@ -0,0 +1,40 @@
1
+ import { cloneList } from './_internals/cloneList.js'
2
+
3
+ /**
4
+ * Source:
5
+ * https://github.com/denoland/std/blob/main/collections/permutations.ts
6
+ */
7
+ export function permutations(inputArray) {
8
+ const result = [];
9
+ const array = cloneList(inputArray);
10
+ const k = array.length;
11
+ if (k === 0) {
12
+ return result;
13
+ }
14
+
15
+ const c = new Array(k).fill(0);
16
+
17
+ result.push([...array]);
18
+
19
+ let i = 1;
20
+
21
+ while (i < k) {
22
+ if (c[i] < i) {
23
+ if (i % 2 === 0) {
24
+ [array[0], array[i]] = [array[i], array[0]]
25
+ } else {
26
+ [array[c[i]], array[i]] = [array[i], array[c[i]]]
27
+ }
28
+
29
+ result.push([...array]);
30
+
31
+ c[i] += 1;
32
+ i = 1;
33
+ } else {
34
+ c[i] = 0;
35
+ i += 1;
36
+ }
37
+ }
38
+
39
+ return result;
40
+ }
package/src/pick.js CHANGED
@@ -1,21 +1,21 @@
1
1
  import { createPath } from './_internals/createPath.js'
2
2
 
3
- export function pick(propsToPick, input){
4
- if (arguments.length === 1) return _input => pick(propsToPick, _input)
5
-
6
- if (input === null || input === undefined){
7
- return undefined
8
- }
9
- const keys = createPath(propsToPick, ',')
10
- const willReturn = {}
11
- let counter = 0
3
+ export function pick(propsToPick) {
4
+ return input => {
5
+ if (!input === null) {
6
+ return undefined
7
+ }
8
+ const keys = createPath(propsToPick, ',')
9
+ const willReturn = {}
10
+ let counter = 0
12
11
 
13
- while (counter < keys.length){
14
- if (keys[ counter ] in input){
15
- willReturn[ keys[ counter ] ] = input[ keys[ counter ] ]
12
+ while (counter < keys.length) {
13
+ if (keys[counter] in input) {
14
+ willReturn[keys[counter]] = input[keys[counter]]
15
+ }
16
+ counter++
16
17
  }
17
- counter++
18
- }
19
18
 
20
- return willReturn
19
+ return willReturn
20
+ }
21
21
  }
package/src/pipe.js CHANGED
@@ -1,23 +1,80 @@
1
- import { _arity } from './_internals/_arity.js'
2
- import { reduceFn } from './reduce.js'
1
+ import { reduce } from './reduce.js'
3
2
 
4
- export function _pipe(f, g){
5
- return function (){
3
+ export function _arity(n, fn) {
4
+ switch (n) {
5
+ case 0:
6
+ return function () {
7
+ return fn.apply(this, arguments)
8
+ }
9
+ case 1:
10
+ return function (a0) {
11
+ return fn.apply(this, arguments)
12
+ }
13
+ case 2:
14
+ return function (a0, a1) {
15
+ return fn.apply(this, arguments)
16
+ }
17
+ case 3:
18
+ return function (a0, a1, a2) {
19
+ return fn.apply(this, arguments)
20
+ }
21
+ case 4:
22
+ return function (a0, a1, a2, a3) {
23
+ return fn.apply(this, arguments)
24
+ }
25
+ case 5:
26
+ return function (a0, a1, a2, a3, a4) {
27
+ return fn.apply(this, arguments)
28
+ }
29
+ case 6:
30
+ return function (a0, a1, a2, a3, a4, a5) {
31
+ return fn.apply(this, arguments)
32
+ }
33
+ case 7:
34
+ return function (a0, a1, a2, a3, a4, a5, a6) {
35
+ return fn.apply(this, arguments)
36
+ }
37
+ case 8:
38
+ return function (a0, a1, a2, a3, a4, a5, a6, a7) {
39
+ return fn.apply(this, arguments)
40
+ }
41
+ case 9:
42
+ return function (a0, a1, a2, a3, a4, a5, a6, a7, a8) {
43
+ return fn.apply(this, arguments)
44
+ }
45
+ case 10:
46
+ return function (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) {
47
+ return fn.apply(this, arguments)
48
+ }
49
+ default:
50
+ throw new Error(
51
+ 'First argument to _arity must be a non-negative integer no greater than ten',
52
+ )
53
+ }
54
+ }
55
+
56
+ function _pipe(f, g) {
57
+ return function () {
6
58
  return g.call(this, f.apply(this, arguments))
7
59
  }
8
60
  }
9
61
 
10
- export function pipe(){
11
- if (arguments.length === 0){
62
+ function pipeFn() {
63
+ if (arguments.length === 0) {
12
64
  throw new Error('pipe requires at least one argument')
13
65
  }
14
66
 
15
- return _arity(arguments[ 0 ].length,
16
- reduceFn(
67
+ return _arity(
68
+ arguments[0].length,
69
+ reduce(
17
70
  _pipe,
18
- arguments[ 0 ],
19
- Array.prototype.slice.call(
20
- arguments, 1, Infinity
21
- )
22
- ))
71
+ arguments[0],
72
+ )(Array.prototype.slice.call(arguments, 1, Number.POSITIVE_INFINITY)),
73
+ )
74
+ }
75
+
76
+ export function pipe(...inputs) {
77
+ const [input, ...fnList] = inputs
78
+
79
+ return pipeFn(...fnList)(input)
23
80
  }
@@ -0,0 +1,11 @@
1
+ import { type } from './type.js'
2
+
3
+ export async function pipeAsync(input, ...fnList) {
4
+ let willReturn = input
5
+ for (const fn of fnList) {
6
+ const initialResult = fn(willReturn)
7
+ willReturn =
8
+ type(initialResult) === 'Promise' ? await initialResult : initialResult
9
+ }
10
+ return willReturn
11
+ }
package/src/pluck.js CHANGED
@@ -1,15 +1,13 @@
1
- import { map } from './map.js'
2
-
3
- export function pluck(property, list){
4
- if (arguments.length === 1) return _list => pluck(property, _list)
5
-
6
- const willReturn = []
7
-
8
- map(x => {
9
- if (x[ property ] !== undefined){
10
- willReturn.push(x[ property ])
11
- }
12
- }, list)
13
-
14
- return willReturn
1
+ export function pluck(property) {
2
+ return list => {
3
+ const willReturn = []
4
+
5
+ list.forEach(x => {
6
+ if (x[property] !== undefined) {
7
+ willReturn.push(x[property])
8
+ }
9
+ })
10
+
11
+ return willReturn
12
+ }
15
13
  }
package/src/prepend.js CHANGED
@@ -1,7 +1,3 @@
1
- export function prepend(x, input){
2
- if (arguments.length === 1) return _input => prepend(x, _input)
3
-
4
- if (typeof input === 'string') return [ x ].concat(input.split(''))
5
-
6
- return [ x ].concat(input)
1
+ export function prepend(x) {
2
+ return list => [x].concat(list)
7
3
  }
package/src/prop.js CHANGED
@@ -1,11 +1,3 @@
1
- export function propFn(searchProperty, obj){
2
- if (!obj) return undefined
3
-
4
- return obj[ searchProperty ]
5
- }
6
-
7
- export function prop(searchProperty, obj){
8
- if (arguments.length === 1) return _obj => prop(searchProperty, _obj)
9
-
10
- return propFn(searchProperty, obj)
1
+ export function prop(searchProperty) {
2
+ return obj => (obj ? obj[searchProperty] : undefined)
11
3
  }
package/src/propEq.js CHANGED
@@ -1,13 +1,11 @@
1
- import { curry } from './curry.js'
2
- import { equals } from './equals.js'
3
- import { prop } from './prop.js'
1
+ import { equalsFn } from './equals.js'
4
2
 
5
- function propEqFn(
6
- valueToMatch, propToFind, obj
7
- ){
8
- if (!obj) return false
3
+ export function propEq(valueToMatch, propToFind) {
4
+ return obj => {
5
+ if (!obj) {
6
+ return false
7
+ }
9
8
 
10
- return equals(valueToMatch, prop(propToFind, obj))
9
+ return equalsFn(valueToMatch, obj[propToFind])
10
+ }
11
11
  }
12
-
13
- export const propEq = curry(propEqFn)
package/src/propOr.js CHANGED
@@ -1,12 +1,11 @@
1
- import { curry } from './curry.js'
2
1
  import { defaultTo } from './defaultTo.js'
3
2
 
4
- function propOrFn(
5
- defaultValue, property, obj
6
- ){
7
- if (!obj) return defaultValue
3
+ export function propOr(defaultValue, property) {
4
+ return obj => {
5
+ if (!obj) {
6
+ return defaultValue
7
+ }
8
8
 
9
- return defaultTo(defaultValue, obj[ property ])
9
+ return defaultTo(defaultValue, obj[property])
10
+ }
10
11
  }
11
-
12
- export const propOr = curry(propOrFn)
@@ -1,10 +1,3 @@
1
- import { curry } from './curry.js'
2
- import { prop } from './prop.js'
3
-
4
- function propSatisfiesFn(
5
- predicate, property, obj
6
- ){
7
- return predicate(prop(property, obj))
1
+ export function propSatisfies(predicate, property) {
2
+ return obj => predicate(obj[property])
8
3
  }
9
-
10
- export const propSatisfies = curry(propSatisfiesFn)
package/src/range.js CHANGED
@@ -1,18 +1,41 @@
1
- export function range(start, end){
2
- if (arguments.length === 1) return _end => range(start, _end)
1
+ export function range(start) {
2
+ return end => {
3
+ if (Number.isNaN(Number(start)) || Number.isNaN(Number(end))) {
4
+ throw new TypeError('Both arguments to range must be numbers')
5
+ }
3
6
 
4
- if (Number.isNaN(Number(start)) || Number.isNaN(Number(end))){
5
- throw new TypeError('Both arguments to range must be numbers')
6
- }
7
+ if (end <= start) {
8
+ return []
9
+ }
7
10
 
8
- if (end < start) return []
11
+ const len = end - start
12
+ const willReturn = Array(len)
9
13
 
10
- const len = end - start
11
- const willReturn = Array(len)
14
+ for (let i = 0; i < len + 1; i++) {
15
+ willReturn[i] = start + i
16
+ }
12
17
 
13
- for (let i = 0; i < len; i++){
14
- willReturn[ i ] = start + i
18
+ return willReturn
15
19
  }
20
+ }
21
+
22
+ export function rangeDescending(start) {
23
+ return end => {
24
+ if (Number.isNaN(Number(start)) || Number.isNaN(Number(end))) {
25
+ throw new TypeError('Both arguments to range must be numbers')
26
+ }
27
+
28
+ if (end >= start) {
29
+ return []
30
+ }
16
31
 
17
- return willReturn
32
+ const len = start - end
33
+ const willReturn = Array(len)
34
+
35
+ for (let i = 0; i < len + 1; i++) {
36
+ willReturn[i] = start - i
37
+ }
38
+
39
+ return willReturn
40
+ }
18
41
  }