rambda 9.4.2 → 10.0.0-alpha.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 (257) hide show
  1. package/CHANGELOG.md +69 -1
  2. package/README.md +4637 -13433
  3. package/dist/rambda.esm.js +1487 -0
  4. package/dist/rambda.js +952 -2113
  5. package/dist/rambda.umd.js +1595 -1
  6. package/immutable.d.ts +1066 -1293
  7. package/index.d.ts +1066 -1293
  8. package/package.json +95 -94
  9. package/rambda.js +10 -138
  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/all.js +8 -6
  15. package/src/allPass.js +4 -4
  16. package/src/any.js +10 -10
  17. package/src/anyPass.js +4 -4
  18. package/src/append.js +4 -6
  19. package/src/checkObjectWithSpec.js +16 -0
  20. package/src/complement.js +1 -1
  21. package/src/concat.js +2 -4
  22. package/src/count.js +5 -4
  23. package/src/countBy.js +6 -7
  24. package/src/defaultTo.js +4 -6
  25. package/src/drop.js +4 -2
  26. package/src/dropLast.js +4 -8
  27. package/src/dropLastWhile.js +17 -26
  28. package/src/dropWhile.js +14 -22
  29. package/src/eqBy.js +3 -8
  30. package/src/eqProps.js +3 -8
  31. package/src/equals.js +99 -58
  32. package/src/evolve.js +19 -52
  33. package/src/excludes.js +5 -0
  34. package/src/filter.js +10 -40
  35. package/src/filterObject.js +13 -0
  36. package/src/find.js +6 -6
  37. package/src/findIndex.js +5 -5
  38. package/src/findLast.js +6 -6
  39. package/src/findLastIndex.js +5 -5
  40. package/src/flatMap.js +3 -0
  41. package/src/flatten.js +5 -5
  42. package/src/groupBy.js +9 -7
  43. package/src/head.js +5 -3
  44. package/src/includes.js +10 -7
  45. package/src/indexOf.js +2 -6
  46. package/src/init.js +6 -8
  47. package/src/innerJoin.js +11 -19
  48. package/src/intersection.js +2 -4
  49. package/src/intersperse.js +7 -7
  50. package/src/join.js +2 -4
  51. package/src/last.js +4 -4
  52. package/src/lastIndexOf.js +2 -6
  53. package/src/map.js +9 -49
  54. package/src/mapAsync.js +11 -0
  55. package/src/mapObject.js +18 -0
  56. package/src/mapObjectAsync.js +10 -0
  57. package/src/match.js +6 -6
  58. package/src/maxBy.js +2 -8
  59. package/src/merge.js +4 -1
  60. package/src/mergeTypes.js +3 -0
  61. package/src/minBy.js +2 -8
  62. package/src/modifyPath.js +22 -25
  63. package/src/none.js +8 -6
  64. package/src/objOf.js +2 -6
  65. package/src/omit.js +26 -11
  66. package/src/partition.js +20 -23
  67. package/src/path.js +14 -15
  68. package/src/pick.js +15 -15
  69. package/src/pipe.js +70 -13
  70. package/src/pipeAsync.js +10 -0
  71. package/src/pluck.js +7 -9
  72. package/src/prepend.js +2 -6
  73. package/src/prop.js +2 -10
  74. package/src/propEq.js +8 -10
  75. package/src/propOr.js +7 -8
  76. package/src/propSatisfies.js +2 -7
  77. package/src/range.js +3 -3
  78. package/src/reduce.js +15 -30
  79. package/src/reject.js +2 -4
  80. package/src/replace.js +2 -8
  81. package/src/replaceItemAtIndex.js +15 -0
  82. package/src/sort.js +2 -4
  83. package/src/sortBy.js +3 -3
  84. package/src/sortWith.js +9 -13
  85. package/src/split.js +2 -4
  86. package/src/splitEvery.js +6 -8
  87. package/src/symmetricDifference.js +5 -8
  88. package/src/tail.js +2 -2
  89. package/src/take.js +11 -9
  90. package/src/takeLast.js +14 -14
  91. package/src/takeLastWhile.js +19 -20
  92. package/src/takeWhile.js +12 -21
  93. package/src/tap.js +3 -3
  94. package/src/test.js +2 -8
  95. package/src/tryCatch.js +5 -14
  96. package/src/type.js +6 -5
  97. package/src/union.js +10 -8
  98. package/src/uniq.js +2 -2
  99. package/src/uniqBy.js +5 -6
  100. package/src/uniqWith.js +10 -14
  101. package/src/unless.js +7 -9
  102. package/src/unwind.js +6 -14
  103. package/src/update.js +8 -11
  104. package/src/when.js +7 -9
  105. package/src/zip.js +8 -8
  106. package/src/zipWith.js +5 -7
  107. package/src/F.js +0 -3
  108. package/src/T.js +0 -3
  109. package/src/_internals/_arity.js +0 -64
  110. package/src/_internals/compare.js +0 -3
  111. package/src/_internals/constants.js +0 -1
  112. package/src/_internals/createPathInput.js +0 -7
  113. package/src/_internals/isFalsy.js +0 -13
  114. package/src/_internals/isInteger.js +0 -10
  115. package/src/_internals/isIterable.js +0 -5
  116. package/src/_internals/isObject.js +0 -5
  117. package/src/_internals/isTruthy.js +0 -13
  118. package/src/_internals/objectIs.js +0 -9
  119. package/src/_internals/utils.js +0 -21
  120. package/src/add.js +0 -5
  121. package/src/addIndex.js +0 -23
  122. package/src/addIndexRight.js +0 -9
  123. package/src/adjust.js +0 -16
  124. package/src/always.js +0 -3
  125. package/src/and.js +0 -5
  126. package/src/ap.js +0 -7
  127. package/src/aperture.js +0 -15
  128. package/src/apply.js +0 -7
  129. package/src/applySpec.js +0 -132
  130. package/src/applyTo.js +0 -7
  131. package/src/ascend.js +0 -23
  132. package/src/assoc.js +0 -11
  133. package/src/assocPath.js +0 -46
  134. package/src/binary.js +0 -5
  135. package/src/bind.js +0 -9
  136. package/src/both.js +0 -5
  137. package/src/call.js +0 -1
  138. package/src/chain.js +0 -7
  139. package/src/clamp.js +0 -15
  140. package/src/clone.js +0 -18
  141. package/src/collectBy.js +0 -27
  142. package/src/comparator.js +0 -5
  143. package/src/compose.js +0 -9
  144. package/src/composeWith.js +0 -33
  145. package/src/cond.js +0 -14
  146. package/src/converge.js +0 -18
  147. package/src/curry.js +0 -7
  148. package/src/curryN.js +0 -40
  149. package/src/dec.js +0 -1
  150. package/src/descend.js +0 -17
  151. package/src/difference.js +0 -8
  152. package/src/differenceWith.js +0 -20
  153. package/src/dissoc.js +0 -13
  154. package/src/dissocPath.js +0 -47
  155. package/src/divide.js +0 -5
  156. package/src/dropRepeats.js +0 -20
  157. package/src/dropRepeatsBy.js +0 -21
  158. package/src/dropRepeatsWith.js +0 -28
  159. package/src/either.js +0 -8
  160. package/src/empty.js +0 -15
  161. package/src/endsWith.js +0 -23
  162. package/src/flip.js +0 -23
  163. package/src/forEach.js +0 -19
  164. package/src/forEachObjIndexed.js +0 -24
  165. package/src/fromPairs.js +0 -6
  166. package/src/groupWith.js +0 -46
  167. package/src/gt.js +0 -6
  168. package/src/gte.js +0 -6
  169. package/src/has.js +0 -7
  170. package/src/hasIn.js +0 -9
  171. package/src/hasPath.js +0 -9
  172. package/src/identical.js +0 -7
  173. package/src/identity.js +0 -3
  174. package/src/ifElse.js +0 -17
  175. package/src/inc.js +0 -1
  176. package/src/indexBy.js +0 -29
  177. package/src/insert.js +0 -11
  178. package/src/insertAll.js +0 -7
  179. package/src/is.js +0 -8
  180. package/src/isEmpty.js +0 -18
  181. package/src/isNil.js +0 -3
  182. package/src/isNotEmpty.js +0 -5
  183. package/src/isNotNil.js +0 -3
  184. package/src/isPromise.js +0 -5
  185. package/src/juxt.js +0 -3
  186. package/src/keys.js +0 -3
  187. package/src/length.js +0 -8
  188. package/src/lens.js +0 -7
  189. package/src/lensIndex.js +0 -7
  190. package/src/lensPath.js +0 -7
  191. package/src/lensProp.js +0 -7
  192. package/src/lt.js +0 -6
  193. package/src/lte.js +0 -6
  194. package/src/mathMod.js +0 -8
  195. package/src/max.js +0 -5
  196. package/src/maybe.js +0 -13
  197. package/src/mean.js +0 -5
  198. package/src/median.js +0 -17
  199. package/src/mergeAll.js +0 -11
  200. package/src/mergeDeepLeft.js +0 -5
  201. package/src/mergeDeepRight.js +0 -24
  202. package/src/mergeLeft.js +0 -7
  203. package/src/mergeRight.js +0 -8
  204. package/src/mergeWith.js +0 -25
  205. package/src/min.js +0 -5
  206. package/src/modify.js +0 -23
  207. package/src/modulo.js +0 -5
  208. package/src/move.js +0 -19
  209. package/src/multiply.js +0 -5
  210. package/src/negate.js +0 -3
  211. package/src/not.js +0 -3
  212. package/src/nth.js +0 -9
  213. package/src/of.js +0 -3
  214. package/src/on.js +0 -16
  215. package/src/once.js +0 -24
  216. package/src/or.js +0 -5
  217. package/src/over.js +0 -14
  218. package/src/partial.js +0 -17
  219. package/src/partialObject.js +0 -5
  220. package/src/pathEq.js +0 -11
  221. package/src/pathOr.js +0 -11
  222. package/src/pathSatisfies.js +0 -9
  223. package/src/paths.js +0 -9
  224. package/src/pickAll.js +0 -23
  225. package/src/pickBy.js +0 -11
  226. package/src/product.js +0 -4
  227. package/src/propIs.js +0 -10
  228. package/src/props.js +0 -13
  229. package/src/reduceBy.js +0 -29
  230. package/src/removeIndex.js +0 -7
  231. package/src/repeat.js +0 -7
  232. package/src/reverse.js +0 -9
  233. package/src/set.js +0 -9
  234. package/src/slice.js +0 -9
  235. package/src/splitAt.js +0 -21
  236. package/src/splitWhen.js +0 -25
  237. package/src/startsWith.js +0 -23
  238. package/src/subtract.js +0 -5
  239. package/src/sum.js +0 -3
  240. package/src/swap.js +0 -42
  241. package/src/times.js +0 -12
  242. package/src/toLower.js +0 -3
  243. package/src/toPairs.js +0 -3
  244. package/src/toString.js +0 -3
  245. package/src/toUpper.js +0 -3
  246. package/src/transpose.js +0 -10
  247. package/src/trim.js +0 -3
  248. package/src/unapply.js +0 -5
  249. package/src/unnest.js +0 -9
  250. package/src/values.js +0 -6
  251. package/src/view.js +0 -10
  252. package/src/where.js +0 -15
  253. package/src/whereAny.js +0 -12
  254. package/src/whereEq.js +0 -14
  255. package/src/without.js +0 -15
  256. package/src/xor.js +0 -5
  257. package/src/zipObj.js +0 -13
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
- }
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,10 @@
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 = type(initialResult) === 'Promise' ? await initialResult : initialResult
8
+ }
9
+ return willReturn
10
+ }
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
-
1
+ export function pluck(property) {
2
+ return list => {
6
3
  const willReturn = []
7
4
 
8
- map(x => {
9
- if (x[ property ] !== undefined){
10
- willReturn.push(x[ property ])
5
+ list.forEach(x => {
6
+ if (x[property] !== undefined) {
7
+ willReturn.push(x[property])
11
8
  }
12
- }, list)
9
+ })
13
10
 
14
11
  return willReturn
15
12
  }
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,5 @@
1
- import { curry } from './curry.js'
2
1
  import { prop } from './prop.js'
3
2
 
4
- function propSatisfiesFn(
5
- predicate, property, obj
6
- ){
7
- return predicate(prop(property, obj))
3
+ export function propSatisfies(predicate, property) {
4
+ return obj => predicate(prop(property, obj))
8
5
  }
9
-
10
- export const propSatisfies = curry(propSatisfiesFn)
package/src/range.js CHANGED
@@ -1,6 +1,5 @@
1
- export function range(start, end){
2
- if (arguments.length === 1) return _end => range(start, _end)
3
-
1
+ export function range(start){
2
+ return end => {
4
3
  if (Number.isNaN(Number(start)) || Number.isNaN(Number(end))){
5
4
  throw new TypeError('Both arguments to range must be numbers')
6
5
  }
@@ -16,3 +15,4 @@ export function range(start, end){
16
15
 
17
16
  return willReturn
18
17
  }
18
+ }
package/src/reduce.js CHANGED
@@ -1,36 +1,21 @@
1
1
  import { isArray } from './_internals/isArray.js'
2
- import { curry } from './curry.js'
3
2
 
4
- class ReduceStopper{
5
- constructor(value){
6
- this.value = value
7
- }
8
- }
9
-
10
- export function reduceFn(
11
- reducer, acc, list
12
- ){
13
- if (list == null){
14
- return acc
15
- }
16
- if (!isArray(list)){
17
- throw new TypeError('reduce: list must be array or iterable')
18
- }
19
- let index = 0
20
- const len = list.length
3
+ export function reduce(reducer, acc) {
4
+ return list => {
5
+ if (list == null) {
6
+ return acc
7
+ }
8
+ if (!isArray(list)) {
9
+ throw new TypeError('reduce: list must be array or iterable')
10
+ }
11
+ let index = 0
12
+ const len = list.length
21
13
 
22
- while (index < len){
23
- acc = reducer(
24
- acc, list[ index ], index, list
25
- )
26
- if (acc instanceof ReduceStopper){
27
- return acc.value
14
+ while (index < len) {
15
+ acc = reducer(acc, list[index], index, list)
16
+ index++
28
17
  }
29
- index++
30
- }
31
18
 
32
- return acc
19
+ return acc
20
+ }
33
21
  }
34
-
35
- export const reduce = curry(reduceFn)
36
- export const reduceStopper = value => new ReduceStopper(value)
package/src/reject.js CHANGED
@@ -1,7 +1,5 @@
1
1
  import { filter } from './filter.js'
2
2
 
3
- export function reject(predicate, list){
4
- if (arguments.length === 1) return _list => reject(predicate, _list)
5
-
6
- return filter(x => !predicate(x), list)
3
+ export function reject(predicate) {
4
+ return list => filter(x => !predicate(x), list)
7
5
  }
package/src/replace.js CHANGED
@@ -1,9 +1,3 @@
1
- import { curry } from './curry.js'
2
-
3
- function replaceFn(
4
- pattern, replacer, str
5
- ){
6
- return str.replace(pattern, replacer)
1
+ export function replace(pattern, replacer) {
2
+ return str => str.replace(pattern, replacer)
7
3
  }
8
-
9
- export const replace = curry(replaceFn)
@@ -0,0 +1,15 @@
1
+ import { cloneList } from './_internals/cloneList.js'
2
+
3
+ export function replaceItemAtIndex(index, replaceFn) {
4
+ return list => {
5
+ const actualIndex = index < 0 ? list.length + index : index
6
+ if (index >= list.length || actualIndex < 0) {
7
+ return list
8
+ }
9
+
10
+ const clone = cloneList(list)
11
+ clone[actualIndex] = replaceFn(clone[actualIndex])
12
+
13
+ return clone
14
+ }
15
+ }
package/src/sort.js CHANGED
@@ -1,7 +1,5 @@
1
1
  import { cloneList } from './_internals/cloneList.js'
2
2
 
3
- export function sort(sortFn, list){
4
- if (arguments.length === 1) return _list => sort(sortFn, _list)
5
-
6
- return cloneList(list).sort(sortFn)
3
+ export function sort(sortFn){
4
+ return list => cloneList(list).sort(sortFn)
7
5
  }
package/src/sortBy.js CHANGED
@@ -1,8 +1,7 @@
1
1
  import { cloneList } from './_internals/cloneList.js'
2
2
 
3
- export function sortBy(sortFn, list){
4
- if (arguments.length === 1) return _list => sortBy(sortFn, _list)
5
-
3
+ export function sortBy(sortFn){
4
+ return list => {
6
5
  const clone = cloneList(list)
7
6
 
8
7
  return clone.sort((a, b) => {
@@ -14,3 +13,4 @@ export function sortBy(sortFn, list){
14
13
  return aSortResult < bSortResult ? -1 : 1
15
14
  })
16
15
  }
16
+ }
package/src/sortWith.js CHANGED
@@ -1,27 +1,23 @@
1
- function sortHelper(
2
- a, b, listOfSortingFns
3
- ){
1
+ function sortHelper(a, b, listOfSortingFns) {
4
2
  let result = 0
5
3
  let i = 0
6
- while (result === 0 && i < listOfSortingFns.length){
7
- result = listOfSortingFns[ i ](a, b)
4
+ while (result === 0 && i < listOfSortingFns.length) {
5
+ result = listOfSortingFns[i](a, b)
8
6
  i += 1
9
7
  }
10
8
 
11
9
  return result
12
10
  }
13
11
 
14
- export function sortWith(listOfSortingFns, list){
15
- if (arguments.length === 1)
16
- return _list => sortWith(listOfSortingFns, _list)
17
-
18
- if (Array.isArray(list) === false)
12
+ export function sortWith(listOfSortingFns) {
13
+ return list => {
14
+ if (Array.isArray(list) === false) {
19
15
  return []
16
+ }
20
17
 
21
18
  const clone = list.slice()
22
- clone.sort((a, b) => sortHelper(
23
- a, b, listOfSortingFns
24
- ))
19
+ clone.sort((a, b) => sortHelper(a, b, listOfSortingFns))
25
20
 
26
21
  return clone
27
22
  }
23
+ }
package/src/split.js CHANGED
@@ -1,5 +1,3 @@
1
- export function split(separator, str){
2
- if (arguments.length === 1) return _str => split(separator, _str)
3
-
4
- return str.split(separator)
1
+ export function split(separator){
2
+ return str => str.split(separator)
5
3
  }
package/src/splitEvery.js CHANGED
@@ -1,18 +1,16 @@
1
- export function splitEvery(sliceLength, listOrString){
2
- if (arguments.length === 1){
3
- return _listOrString => splitEvery(sliceLength, _listOrString)
4
- }
5
-
6
- if (sliceLength < 1){
1
+ export function splitEvery(sliceLength) {
2
+ return list => {
3
+ if (sliceLength < 1) {
7
4
  throw new Error('First argument to splitEvery must be a positive integer')
8
5
  }
9
6
 
10
7
  const willReturn = []
11
8
  let counter = 0
12
9
 
13
- while (counter < listOrString.length){
14
- willReturn.push(listOrString.slice(counter, counter += sliceLength))
10
+ while (counter < list.length) {
11
+ willReturn.push(list.slice(counter, (counter += sliceLength)))
15
12
  }
16
13
 
17
14
  return willReturn
18
15
  }
16
+ }
@@ -1,12 +1,9 @@
1
- import { concat } from './concat.js'
2
1
  import { filter } from './filter.js'
3
2
  import { includes } from './includes.js'
4
3
 
5
- export function symmetricDifference(x, y){
6
- if (arguments.length === 1){
7
- return _y => symmetricDifference(x, _y)
8
- }
9
-
10
- return concat(filter(value => !includes(value, y), x),
11
- filter(value => !includes(value, x), y))
4
+ export function symmetricDifference(x) {
5
+ return y => [
6
+ ...filter(value => !includes(value)(y))(x),
7
+ ...filter(value => !includes(value)(x))(y),
8
+ ]
12
9
  }
package/src/tail.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { drop } from './drop.js'
2
2
 
3
- export function tail(listOrString){
4
- return drop(1, listOrString)
3
+ export function tail(listOrString) {
4
+ return drop(1)(listOrString)
5
5
  }
package/src/take.js CHANGED
@@ -1,12 +1,14 @@
1
- import baseSlice from './_internals/baseSlice.js'
1
+ import { baseSlice } from './_internals/baseSlice.js'
2
2
 
3
- export function take(howMany, listOrString){
4
- if (arguments.length === 1)
5
- return _listOrString => take(howMany, _listOrString)
6
- if (howMany < 0) return listOrString.slice()
7
- if (typeof listOrString === 'string') return listOrString.slice(0, howMany)
3
+ export function take(numberOfItems) {
4
+ return input => {
5
+ if (numberOfItems < 0) {
6
+ return input.slice()
7
+ }
8
+ if (typeof input === 'string') {
9
+ return input.slice(0, numberOfItems)
10
+ }
8
11
 
9
- return baseSlice(
10
- listOrString, 0, howMany
11
- )
12
+ return baseSlice(input, 0, numberOfItems)
13
+ }
12
14
  }
package/src/takeLast.js CHANGED
@@ -1,19 +1,19 @@
1
- import baseSlice from './_internals/baseSlice.js'
1
+ import { baseSlice } from './_internals/baseSlice.js'
2
2
 
3
- export function takeLast(howMany, listOrString){
4
- if (arguments.length === 1)
5
- return _listOrString => takeLast(howMany, _listOrString)
3
+ export function takeLast(numberOfItems) {
4
+ return input => {
5
+ const len = input.length
6
+ if (numberOfItems < 0) {
7
+ return input.slice()
8
+ }
9
+ let numValue = numberOfItems > len ? len : numberOfItems
6
10
 
7
- const len = listOrString.length
8
- if (howMany < 0) return listOrString.slice()
9
- let numValue = howMany > len ? len : howMany
11
+ if (typeof input === 'string') {
12
+ return input.slice(len - numValue)
13
+ }
10
14
 
11
- if (typeof listOrString === 'string')
12
- return listOrString.slice(len - numValue)
15
+ numValue = len - numValue
13
16
 
14
- numValue = len - numValue
15
-
16
- return baseSlice(
17
- listOrString, numValue, len
18
- )
17
+ return baseSlice(input, numValue, len)
18
+ }
19
19
  }
@@ -1,21 +1,20 @@
1
- import { isArray } from './_internals/isArray.js'
2
-
3
- export function takeLastWhile(predicate, input){
4
- if (arguments.length === 1){
5
- return _input => takeLastWhile(predicate, _input)
6
- }
7
- if (input.length === 0) return input
8
-
9
- const toReturn = []
10
- let counter = input.length
11
-
12
- while (counter){
13
- const item = input[ --counter ]
14
- if (!predicate(item)){
15
- break
16
- }
17
- toReturn.push(item)
18
- }
19
-
20
- return isArray(input) ? toReturn.reverse() : toReturn.reverse().join('')
1
+ export function takeLastWhile(predicate) {
2
+ return input => {
3
+ if (input.length === 0) {
4
+ return input
5
+ }
6
+
7
+ const toReturn = []
8
+ let counter = input.length
9
+
10
+ while (counter) {
11
+ const item = input[--counter]
12
+ if (!predicate(item)) {
13
+ break
14
+ }
15
+ toReturn.push(item)
16
+ }
17
+
18
+ return toReturn.reverse()
19
+ }
21
20
  }