rambda 7.0.3 → 7.1.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 (201) hide show
  1. package/CHANGELOG.md +18 -2
  2. package/README.md +3541 -2696
  3. package/dist/rambda.js +282 -76
  4. package/dist/rambda.mjs +268 -76
  5. package/dist/rambda.umd.js +1 -1
  6. package/immutable.d.ts +91 -10
  7. package/index.d.ts +91 -10
  8. package/package.json +119 -119
  9. package/src/F.js +1 -1
  10. package/src/T.js +1 -1
  11. package/src/_internals/_isInteger.js +1 -1
  12. package/src/_internals/_keys.js +0 -1
  13. package/src/_internals/_objectIs.js +2 -7
  14. package/src/_internals/baseSlice.js +8 -6
  15. package/src/_internals/cloneList.js +1 -3
  16. package/src/_internals/createPath.js +3 -0
  17. package/src/_internals/isFalsy.js +5 -5
  18. package/src/_internals/isObject.js +2 -2
  19. package/src/_internals/isTruthy.js +5 -5
  20. package/src/_internals/set.js +19 -13
  21. package/src/add.js +1 -1
  22. package/src/adjust.js +6 -4
  23. package/src/all.js +3 -3
  24. package/src/allPass.js +3 -3
  25. package/src/always.js +2 -2
  26. package/src/and.js +1 -1
  27. package/src/any.js +3 -3
  28. package/src/anyPass.js +3 -3
  29. package/src/append.js +2 -2
  30. package/src/apply.js +2 -2
  31. package/src/applySpec.js +59 -33
  32. package/src/assoc.js +7 -3
  33. package/src/assocPath.js +25 -21
  34. package/src/bind.js +3 -3
  35. package/src/both.js +1 -1
  36. package/src/chain.js +2 -2
  37. package/src/clamp.js +6 -6
  38. package/src/clone.js +10 -10
  39. package/src/complement.js +1 -1
  40. package/src/compose.js +5 -14
  41. package/src/concat.js +2 -2
  42. package/src/cond.js +3 -3
  43. package/src/converge.js +11 -11
  44. package/src/count.js +10 -0
  45. package/src/countBy.js +17 -0
  46. package/src/curry.js +2 -2
  47. package/src/curryN.js +81 -61
  48. package/src/defaultTo.js +3 -3
  49. package/src/difference.js +3 -3
  50. package/src/dissoc.js +4 -4
  51. package/src/divide.js +1 -1
  52. package/src/drop.js +1 -1
  53. package/src/dropLast.js +5 -5
  54. package/src/dropLastWhile.js +12 -12
  55. package/src/dropRepeats.js +6 -6
  56. package/src/dropRepeatsWith.js +7 -7
  57. package/src/dropWhile.js +9 -9
  58. package/src/either.js +2 -2
  59. package/src/endsWith.js +6 -5
  60. package/src/eqProps.js +6 -4
  61. package/src/equals.js +64 -65
  62. package/src/evolve.js +21 -23
  63. package/src/filter.js +21 -15
  64. package/src/find.js +4 -4
  65. package/src/findIndex.js +3 -3
  66. package/src/findLast.js +4 -4
  67. package/src/findLastIndex.js +3 -3
  68. package/src/flatten.js +6 -6
  69. package/src/flip.js +15 -11
  70. package/src/forEach.js +12 -10
  71. package/src/fromPairs.js +2 -2
  72. package/src/groupBy.js +6 -6
  73. package/src/groupWith.js +12 -10
  74. package/src/has.js +1 -1
  75. package/src/hasPath.js +3 -3
  76. package/src/head.js +3 -3
  77. package/src/identical.js +2 -2
  78. package/src/identity.js +1 -1
  79. package/src/ifElse.js +5 -3
  80. package/src/includes.js +6 -6
  81. package/src/indexBy.js +11 -11
  82. package/src/indexOf.js +3 -3
  83. package/src/init.js +7 -3
  84. package/src/intersection.js +3 -3
  85. package/src/intersperse.js +5 -5
  86. package/src/is.js +2 -2
  87. package/src/isEmpty.js +5 -5
  88. package/src/isNil.js +1 -1
  89. package/src/isPromise.js +3 -3
  90. package/src/join.js +1 -1
  91. package/src/juxt.js +3 -0
  92. package/src/keys.js +1 -1
  93. package/src/last.js +4 -4
  94. package/src/lastIndexOf.js +3 -3
  95. package/src/length.js +2 -2
  96. package/src/lens.js +3 -3
  97. package/src/lensIndex.js +4 -4
  98. package/src/lensPath.js +4 -4
  99. package/src/lensProp.js +4 -4
  100. package/src/map.js +15 -11
  101. package/src/match.js +1 -1
  102. package/src/mathMod.js +3 -3
  103. package/src/max.js +1 -1
  104. package/src/maxBy.js +4 -2
  105. package/src/maybe.js +4 -2
  106. package/src/mean.js +2 -2
  107. package/src/median.js +10 -12
  108. package/src/merge.js +1 -5
  109. package/src/mergeAll.js +4 -4
  110. package/src/mergeDeepRight.js +8 -8
  111. package/src/mergeLeft.js +3 -3
  112. package/src/mergeRight.js +7 -0
  113. package/src/mergeWith.js +29 -0
  114. package/src/min.js +1 -1
  115. package/src/minBy.js +4 -2
  116. package/src/modulo.js +1 -1
  117. package/src/move.js +8 -6
  118. package/src/multiply.js +1 -1
  119. package/src/negate.js +1 -1
  120. package/src/none.js +3 -3
  121. package/src/not.js +1 -1
  122. package/src/nth.js +6 -6
  123. package/src/objOf.js +3 -5
  124. package/src/of.js +2 -2
  125. package/src/omit.js +8 -8
  126. package/src/on.js +16 -0
  127. package/src/once.js +6 -6
  128. package/src/or.js +1 -1
  129. package/src/over.js +5 -3
  130. package/src/partial.js +3 -3
  131. package/src/partialObject.js +15 -0
  132. package/src/partition.js +18 -16
  133. package/src/path.js +9 -8
  134. package/src/pathEq.js +6 -4
  135. package/src/pathOr.js +6 -4
  136. package/src/paths.js +3 -3
  137. package/src/pick.js +8 -8
  138. package/src/pickAll.js +9 -9
  139. package/src/pipe.js +85 -13
  140. package/src/pluck.js +4 -4
  141. package/src/prepend.js +3 -3
  142. package/src/product.js +2 -2
  143. package/src/prop.js +2 -2
  144. package/src/propEq.js +5 -3
  145. package/src/propIs.js +6 -4
  146. package/src/propOr.js +6 -4
  147. package/src/propSatisfies.js +10 -0
  148. package/src/props.js +6 -6
  149. package/src/range.js +4 -4
  150. package/src/reduce.js +11 -7
  151. package/src/reject.js +2 -2
  152. package/src/repeat.js +2 -2
  153. package/src/replace.js +4 -2
  154. package/src/reverse.js +4 -3
  155. package/src/set.js +9 -5
  156. package/src/slice.js +4 -2
  157. package/src/sort.js +2 -2
  158. package/src/sortBy.js +2 -2
  159. package/src/split.js +1 -1
  160. package/src/splitAt.js +9 -9
  161. package/src/splitEvery.js +6 -8
  162. package/src/splitWhen.js +10 -10
  163. package/src/startsWith.js +6 -5
  164. package/src/subtract.js +1 -1
  165. package/src/sum.js +1 -1
  166. package/src/symmetricDifference.js +7 -9
  167. package/src/tail.js +2 -2
  168. package/src/take.js +5 -3
  169. package/src/takeLast.js +5 -3
  170. package/src/takeLastWhile.js +7 -7
  171. package/src/takeWhile.js +8 -8
  172. package/src/tap.js +1 -1
  173. package/src/test.js +3 -5
  174. package/src/times.js +4 -4
  175. package/src/toLower.js +1 -1
  176. package/src/toPairs.js +1 -1
  177. package/src/toString.js +1 -1
  178. package/src/toUpper.js +1 -1
  179. package/src/transpose.js +3 -4
  180. package/src/trim.js +1 -1
  181. package/src/tryCatch.js +7 -5
  182. package/src/type.js +5 -5
  183. package/src/unapply.js +2 -2
  184. package/src/union.js +3 -3
  185. package/src/uniq.js +3 -3
  186. package/src/uniqWith.js +12 -8
  187. package/src/unless.js +3 -3
  188. package/src/unwind.js +15 -0
  189. package/src/update.js +8 -4
  190. package/src/values.js +2 -2
  191. package/src/view.js +2 -2
  192. package/src/when.js +4 -2
  193. package/src/where.js +5 -5
  194. package/src/whereAny.js +12 -0
  195. package/src/whereEq.js +7 -9
  196. package/src/without.js +4 -4
  197. package/src/xor.js +2 -2
  198. package/src/zip.js +3 -3
  199. package/src/zipObj.js +6 -4
  200. package/src/zipWith.js +6 -6
  201. package/src/isFunction.js +0 -5
package/src/applySpec.js CHANGED
@@ -1,71 +1,93 @@
1
- import {_isArray} from './_internals/_isArray'
1
+ import { _isArray } from './_internals/_isArray.js'
2
2
 
3
3
  // recursively traverse the given spec object to find the highest arity function
4
- function __findHighestArity(spec, max = 0) {
5
- for (const key in spec) {
4
+ export function __findHighestArity(spec, max = 0){
5
+ for (const key in spec){
6
6
  if (spec.hasOwnProperty(key) === false || key === 'constructor') continue
7
7
 
8
- if (typeof spec[key] === 'object') {
9
- max = Math.max(max, __findHighestArity(spec[key]))
8
+ if (typeof spec[ key ] === 'object'){
9
+ max = Math.max(max, __findHighestArity(spec[ key ]))
10
10
  }
11
11
 
12
- if (typeof spec[key] === 'function') {
13
- max = Math.max(max, spec[key].length)
12
+ if (typeof spec[ key ] === 'function'){
13
+ max = Math.max(max, spec[ key ].length)
14
14
  }
15
15
  }
16
16
 
17
17
  return max
18
18
  }
19
19
 
20
- function __filterUndefined() {
20
+ function __filterUndefined(){
21
21
  const defined = []
22
22
  let i = 0
23
23
  const l = arguments.length
24
- while (i < l) {
25
- if (typeof arguments[i] === 'undefined') break
26
- defined[i] = arguments[i]
24
+ while (i < l){
25
+ if (typeof arguments[ i ] === 'undefined') break
26
+ defined[ i ] = arguments[ i ]
27
27
  i++
28
28
  }
29
29
 
30
30
  return defined
31
31
  }
32
32
 
33
- function __applySpecWithArity(spec, arity, cache) {
33
+ function __applySpecWithArity(
34
+ spec, arity, cache
35
+ ){
34
36
  const remaining = arity - cache.length
35
37
 
36
38
  if (remaining === 1)
37
39
  return x =>
38
- __applySpecWithArity(spec, arity, __filterUndefined(...cache, x))
40
+ __applySpecWithArity(
41
+ spec, arity, __filterUndefined(...cache, x)
42
+ )
39
43
  if (remaining === 2)
40
44
  return (x, y) =>
41
- __applySpecWithArity(spec, arity, __filterUndefined(...cache, x, y))
45
+ __applySpecWithArity(
46
+ spec, arity, __filterUndefined(
47
+ ...cache, x, y
48
+ )
49
+ )
42
50
  if (remaining === 3)
43
- return (x, y, z) =>
44
- __applySpecWithArity(spec, arity, __filterUndefined(...cache, x, y, z))
51
+ return (
52
+ x, y, z
53
+ ) =>
54
+ __applySpecWithArity(
55
+ spec, arity, __filterUndefined(
56
+ ...cache, x, y, z
57
+ )
58
+ )
45
59
  if (remaining === 4)
46
- return (x, y, z, a) =>
60
+ return (
61
+ x, y, z, a
62
+ ) =>
47
63
  __applySpecWithArity(
48
64
  spec,
49
65
  arity,
50
- __filterUndefined(...cache, x, y, z, a)
66
+ __filterUndefined(
67
+ ...cache, x, y, z, a
68
+ )
51
69
  )
52
70
  if (remaining > 4)
53
71
  return (...args) =>
54
- __applySpecWithArity(spec, arity, __filterUndefined(...cache, ...args))
72
+ __applySpecWithArity(
73
+ spec, arity, __filterUndefined(...cache, ...args)
74
+ )
55
75
 
56
76
  // handle spec as Array
57
- if (_isArray(spec)) {
77
+ if (_isArray(spec)){
58
78
  const ret = []
59
79
  let i = 0
60
80
  const l = spec.length
61
- for (; i < l; i++) {
81
+ for (; i < l; i++){
62
82
  // handle recursive spec inside array
63
- if (typeof spec[i] === 'object' || _isArray(spec[i])) {
64
- ret[i] = __applySpecWithArity(spec[i], arity, cache)
83
+ if (typeof spec[ i ] === 'object' || _isArray(spec[ i ])){
84
+ ret[ i ] = __applySpecWithArity(
85
+ spec[ i ], arity, cache
86
+ )
65
87
  }
66
88
  // apply spec to the key
67
- if (typeof spec[i] === 'function') {
68
- ret[i] = spec[i](...cache)
89
+ if (typeof spec[ i ] === 'function'){
90
+ ret[ i ] = spec[ i ](...cache)
69
91
  }
70
92
  }
71
93
 
@@ -75,32 +97,36 @@ function __applySpecWithArity(spec, arity, cache) {
75
97
  // handle spec as Object
76
98
  const ret = {}
77
99
  // apply callbacks to each property in the spec object
78
- for (const key in spec) {
100
+ for (const key in spec){
79
101
  if (spec.hasOwnProperty(key) === false || key === 'constructor') continue
80
102
 
81
103
  // apply the spec recursively
82
- if (typeof spec[key] === 'object') {
83
- ret[key] = __applySpecWithArity(spec[key], arity, cache)
104
+ if (typeof spec[ key ] === 'object'){
105
+ ret[ key ] = __applySpecWithArity(
106
+ spec[ key ], arity, cache
107
+ )
84
108
  continue
85
109
  }
86
110
 
87
111
  // apply spec to the key
88
- if (typeof spec[key] === 'function') {
89
- ret[key] = spec[key](...cache)
112
+ if (typeof spec[ key ] === 'function'){
113
+ ret[ key ] = spec[ key ](...cache)
90
114
  }
91
115
  }
92
116
 
93
117
  return ret
94
118
  }
95
119
 
96
- export function applySpec(spec, ...args) {
120
+ export function applySpec(spec, ...args){
97
121
  // get the highest arity spec function, cache the result and pass to __applySpecWithArity
98
122
  const arity = __findHighestArity(spec)
99
123
 
100
- if (arity === 0) {
124
+ if (arity === 0){
101
125
  return () => ({})
102
126
  }
103
- const toReturn = __applySpecWithArity(spec, arity, args)
127
+ const toReturn = __applySpecWithArity(
128
+ spec, arity, args
129
+ )
104
130
 
105
131
  return toReturn
106
132
  }
package/src/assoc.js CHANGED
@@ -1,7 +1,11 @@
1
- import {curry} from './curry'
1
+ import { curry } from './curry.js'
2
2
 
3
- function assocFn(prop, newValue, obj) {
4
- return Object.assign({}, obj, {[prop]: newValue})
3
+ function assocFn(
4
+ prop, newValue, obj
5
+ ){
6
+ return Object.assign(
7
+ {}, obj, { [ prop ] : newValue }
8
+ )
5
9
  }
6
10
 
7
11
  export const assoc = curry(assocFn)
package/src/assocPath.js CHANGED
@@ -1,30 +1,32 @@
1
- import {_isArray} from './_internals/_isArray'
2
- import {_isInteger} from './_internals/_isInteger'
3
- import {assoc} from './assoc'
4
- import {curry} from './curry'
5
- import {cloneList} from './_internals/cloneList'
6
-
7
- function assocPathFn(path, newValue, input) {
1
+ import { _isArray } from './_internals/_isArray.js'
2
+ import { _isInteger } from './_internals/_isInteger.js'
3
+ import { cloneList } from './_internals/cloneList.js'
4
+ import { assoc } from './assoc.js'
5
+ import { curry } from './curry.js'
6
+
7
+ function assocPathFn(
8
+ path, newValue, input
9
+ ){
8
10
  const pathArrValue =
9
- typeof path === 'string'
10
- ? path.split('.').map(x => (_isInteger(Number(x)) ? Number(x) : x))
11
- : path
12
- if (pathArrValue.length === 0) {
11
+ typeof path === 'string' ?
12
+ path.split('.').map(x => _isInteger(Number(x)) ? Number(x) : x) :
13
+ path
14
+ if (pathArrValue.length === 0){
13
15
  return newValue
14
16
  }
15
17
 
16
- const index = pathArrValue[0]
17
- if (pathArrValue.length > 1) {
18
+ const index = pathArrValue[ 0 ]
19
+ if (pathArrValue.length > 1){
18
20
  const condition =
19
21
  typeof input !== 'object' ||
20
22
  input === null ||
21
23
  !input.hasOwnProperty(index)
22
24
 
23
- const nextinput = condition
24
- ? _isInteger(pathArrValue[1])
25
- ? []
26
- : {}
27
- : input[index]
25
+ const nextinput = condition ?
26
+ _isInteger(pathArrValue[ 1 ]) ?
27
+ [] :
28
+ {} :
29
+ input[ index ]
28
30
 
29
31
  newValue = assocPathFn(
30
32
  Array.prototype.slice.call(pathArrValue, 1),
@@ -33,14 +35,16 @@ function assocPathFn(path, newValue, input) {
33
35
  )
34
36
  }
35
37
 
36
- if (_isInteger(index) && _isArray(input)) {
38
+ if (_isInteger(index) && _isArray(input)){
37
39
  const arr = cloneList(input)
38
- arr[index] = newValue
40
+ arr[ index ] = newValue
39
41
 
40
42
  return arr
41
43
  }
42
44
 
43
- return assoc(index, newValue, input)
45
+ return assoc(
46
+ index, newValue, input
47
+ )
44
48
  }
45
49
 
46
50
  export const assocPath = curry(assocPathFn)
package/src/bind.js CHANGED
@@ -1,7 +1,7 @@
1
- import {curryN} from './curryN'
1
+ import { curryN } from './curryN.js'
2
2
 
3
- export function bind(fn, thisObj) {
4
- if (arguments.length === 1) {
3
+ export function bind(fn, thisObj){
4
+ if (arguments.length === 1){
5
5
  return _thisObj => bind(fn, _thisObj)
6
6
  }
7
7
 
package/src/both.js CHANGED
@@ -1,4 +1,4 @@
1
- export function both(f, g) {
1
+ export function both(f, g){
2
2
  if (arguments.length === 1) return _g => both(f, _g)
3
3
 
4
4
  return (...input) => f(...input) && g(...input)
package/src/chain.js CHANGED
@@ -1,5 +1,5 @@
1
- export function chain(fn, list) {
2
- if (arguments.length === 1) {
1
+ export function chain(fn, list){
2
+ if (arguments.length === 1){
3
3
  return _list => chain(fn, _list)
4
4
  }
5
5
 
package/src/clamp.js CHANGED
@@ -1,10 +1,10 @@
1
- import {curry} from './curry'
1
+ import { curry } from './curry.js'
2
2
 
3
- function clampFn(min, max, input) {
4
- if (min > max) {
5
- throw new Error(
6
- 'min must not be greater than max in clamp(min, max, value)'
7
- )
3
+ function clampFn(
4
+ min, max, input
5
+ ){
6
+ if (min > max){
7
+ throw new Error('min must not be greater than max in clamp(min, max, value)')
8
8
  }
9
9
  if (input >= min && input <= max) return input
10
10
 
package/src/clone.js CHANGED
@@ -1,17 +1,17 @@
1
- import {_isArray} from './_internals/_isArray'
1
+ import { _isArray } from './_internals/_isArray.js'
2
2
 
3
- export function clone(input) {
3
+ export function clone(input){
4
4
  const out = _isArray(input) ? Array(input.length) : {}
5
5
  if (input && input.getTime) return new Date(input.getTime())
6
6
 
7
- for (const key in input) {
8
- const v = input[key]
9
- out[key] =
10
- typeof v === 'object' && v !== null
11
- ? v.getTime
12
- ? new Date(v.getTime())
13
- : clone(v)
14
- : v
7
+ for (const key in input){
8
+ const v = input[ key ]
9
+ out[ key ] =
10
+ typeof v === 'object' && v !== null ?
11
+ v.getTime ?
12
+ new Date(v.getTime()) :
13
+ clone(v) :
14
+ v
15
15
  }
16
16
 
17
17
  return out
package/src/complement.js CHANGED
@@ -1,3 +1,3 @@
1
- export function complement(fn) {
1
+ export function complement(fn){
2
2
  return (...input) => !fn(...input)
3
3
  }
package/src/compose.js CHANGED
@@ -1,18 +1,9 @@
1
- export function compose(...fns) {
2
- if (fns.length === 0) {
1
+ import { pipe } from './pipe.js'
2
+
3
+ export function compose(){
4
+ if (arguments.length === 0){
3
5
  throw new Error('compose requires at least one argument')
4
6
  }
5
7
 
6
- return function (...args) {
7
- const list = fns.slice()
8
- if (list.length > 0) {
9
- const fn = list.pop()
10
- let result = fn.apply(this, args)
11
- while (list.length > 0) {
12
- result = list.pop()(result)
13
- }
14
-
15
- return result
16
- }
17
- }
8
+ return pipe.apply(this, Array.prototype.slice.call(arguments, 0).reverse())
18
9
  }
package/src/concat.js CHANGED
@@ -1,5 +1,5 @@
1
- export function concat(x, y) {
1
+ export function concat(x, y){
2
2
  if (arguments.length === 1) return _y => concat(x, _y)
3
3
 
4
- return typeof x === 'string' ? `${x}${y}` : [...x, ...y]
4
+ return typeof x === 'string' ? `${ x }${ y }` : [ ...x, ...y ]
5
5
  }
package/src/cond.js CHANGED
@@ -1,9 +1,9 @@
1
- export function cond(conditions) {
1
+ export function cond(conditions){
2
2
  return input => {
3
3
  let done = false
4
4
  let toReturn
5
- conditions.forEach(([predicate, resultClosure]) => {
6
- if (!done && predicate(input)) {
5
+ conditions.forEach(([ predicate, resultClosure ]) => {
6
+ if (!done && predicate(input)){
7
7
  done = true
8
8
  toReturn = resultClosure(input)
9
9
  }
package/src/converge.js CHANGED
@@ -1,18 +1,18 @@
1
- import {curryN} from './curryN'
2
- import {map} from './map'
3
- import {max} from './max'
4
- import {reduce} from './reduce'
1
+ import { curryN } from './curryN.js'
2
+ import { map } from './map.js'
3
+ import { max } from './max.js'
4
+ import { reduce } from './reduce.js'
5
5
 
6
- export function converge(fn, transformers) {
6
+ export function converge(fn, transformers){
7
7
  if (arguments.length === 1)
8
8
  return _transformers => converge(fn, _transformers)
9
9
 
10
- const highestArity = reduce((a, b) => max(a, b.length), 0, transformers)
10
+ const highestArity = reduce(
11
+ (a, b) => max(a, b.length), 0, transformers
12
+ )
11
13
 
12
- return curryN(highestArity, function () {
13
- return fn.apply(
14
- this,
15
- map(g => g.apply(this, arguments), transformers)
16
- )
14
+ return curryN(highestArity, function (){
15
+ return fn.apply(this,
16
+ map(g => g.apply(this, arguments), transformers))
17
17
  })
18
18
  }
package/src/count.js ADDED
@@ -0,0 +1,10 @@
1
+ import { _isArray } from './_internals/_isArray.js'
2
+
3
+ export function count(predicate, list){
4
+ if (arguments.length === 1){
5
+ return _list => count(predicate, _list)
6
+ }
7
+ if (!_isArray(list)) return 0
8
+
9
+ return list.filter(x => predicate(x)).length
10
+ }
package/src/countBy.js ADDED
@@ -0,0 +1,17 @@
1
+ export function countBy(fn, list){
2
+ if (arguments.length === 1){
3
+ return _list => countBy(fn, _list)
4
+ }
5
+ const willReturn = {}
6
+
7
+ list.forEach(item => {
8
+ const key = fn(item)
9
+ if (!willReturn[ key ]){
10
+ willReturn[ key ] = 1
11
+ } else {
12
+ willReturn[ key ]++
13
+ }
14
+ })
15
+
16
+ return willReturn
17
+ }
package/src/curry.js CHANGED
@@ -1,6 +1,6 @@
1
- export function curry(fn, args = []) {
1
+ export function curry(fn, args = []){
2
2
  return (..._args) =>
3
- (rest => (rest.length >= fn.length ? fn(...rest) : curry(fn, rest)))([
3
+ (rest => rest.length >= fn.length ? fn(...rest) : curry(fn, rest))([
4
4
  ...args,
5
5
  ..._args,
6
6
  ])
package/src/curryN.js CHANGED
@@ -1,83 +1,103 @@
1
- function _curryN(n, cache, fn) {
2
- return function () {
1
+ function _curryN(
2
+ n, cache, fn
3
+ ){
4
+ return function (){
3
5
  let ci = 0
4
6
  let ai = 0
5
7
  const cl = cache.length
6
8
  const al = arguments.length
7
9
  const args = new Array(cl + al)
8
- while (ci < cl) {
9
- args[ci] = cache[ci]
10
+ while (ci < cl){
11
+ args[ ci ] = cache[ ci ]
10
12
  ci++
11
13
  }
12
- while (ai < al) {
13
- args[cl + ai] = arguments[ai]
14
+ while (ai < al){
15
+ args[ cl + ai ] = arguments[ ai ]
14
16
  ai++
15
17
  }
16
18
  const remaining = n - args.length
17
19
 
18
- return args.length >= n
19
- ? fn.apply(this, args)
20
- : _arity(remaining, _curryN(n, args, fn))
20
+ return args.length >= n ?
21
+ fn.apply(this, args) :
22
+ _arity(remaining, _curryN(
23
+ n, args, fn
24
+ ))
21
25
  }
22
26
  }
23
27
 
24
- function _arity(n, fn) {
25
- switch (n) {
26
- case 0:
27
- return function () {
28
- return fn.apply(this, arguments)
29
- }
30
- case 1:
31
- return function (_1) {
32
- return fn.apply(this, arguments)
33
- }
34
- case 2:
35
- return function (_1, _2) {
36
- return fn.apply(this, arguments)
37
- }
38
- case 3:
39
- return function (_1, _2, _3) {
40
- return fn.apply(this, arguments)
41
- }
42
- case 4:
43
- return function (_1, _2, _3, _4) {
44
- return fn.apply(this, arguments)
45
- }
46
- case 5:
47
- return function (_1, _2, _3, _4, _5) {
48
- return fn.apply(this, arguments)
49
- }
50
- case 6:
51
- return function (_1, _2, _3, _4, _5, _6) {
52
- return fn.apply(this, arguments)
53
- }
54
- case 7:
55
- return function (_1, _2, _3, _4, _5, _6, _7) {
56
- return fn.apply(this, arguments)
57
- }
58
- case 8:
59
- return function (_1, _2, _3, _4, _5, _6, _7, _8) {
60
- return fn.apply(this, arguments)
61
- }
62
- case 9:
63
- return function (_1, _2, _3, _4, _5, _6, _7, _8, _9) {
64
- return fn.apply(this, arguments)
65
- }
66
- default:
67
- return function (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10) {
68
- return fn.apply(this, arguments)
69
- }
28
+ function _arity(n, fn){
29
+ switch (n){
30
+ case 0:
31
+ return function (){
32
+ return fn.apply(this, arguments)
33
+ }
34
+ case 1:
35
+ return function (_1){
36
+ return fn.apply(this, arguments)
37
+ }
38
+ case 2:
39
+ return function (_1, _2){
40
+ return fn.apply(this, arguments)
41
+ }
42
+ case 3:
43
+ return function (
44
+ _1, _2, _3
45
+ ){
46
+ return fn.apply(this, arguments)
47
+ }
48
+ case 4:
49
+ return function (
50
+ _1, _2, _3, _4
51
+ ){
52
+ return fn.apply(this, arguments)
53
+ }
54
+ case 5:
55
+ return function (
56
+ _1, _2, _3, _4, _5
57
+ ){
58
+ return fn.apply(this, arguments)
59
+ }
60
+ case 6:
61
+ return function (
62
+ _1, _2, _3, _4, _5, _6
63
+ ){
64
+ return fn.apply(this, arguments)
65
+ }
66
+ case 7:
67
+ return function (
68
+ _1, _2, _3, _4, _5, _6, _7
69
+ ){
70
+ return fn.apply(this, arguments)
71
+ }
72
+ case 8:
73
+ return function (
74
+ _1, _2, _3, _4, _5, _6, _7, _8
75
+ ){
76
+ return fn.apply(this, arguments)
77
+ }
78
+ case 9:
79
+ return function (
80
+ _1, _2, _3, _4, _5, _6, _7, _8, _9
81
+ ){
82
+ return fn.apply(this, arguments)
83
+ }
84
+ default:
85
+ return function (
86
+ _1, _2, _3, _4, _5, _6, _7, _8, _9, _10
87
+ ){
88
+ return fn.apply(this, arguments)
89
+ }
70
90
  }
71
91
  }
72
92
 
73
- export function curryN(n, fn) {
93
+ export function curryN(n, fn){
74
94
  if (arguments.length === 1) return _fn => curryN(n, _fn)
75
95
 
76
- if (n > 10) {
77
- throw new Error(
78
- 'First argument to _arity must be a non-negative integer no greater than ten'
79
- )
96
+ if (n > 10){
97
+ throw new Error('First argument to _arity must be a non-negative integer no greater than ten')
80
98
  }
81
99
 
82
- return _arity(n, _curryN(n, [], fn))
100
+ return _arity(n, _curryN(
101
+ n, [], fn
102
+ ))
83
103
  }
package/src/defaultTo.js CHANGED
@@ -1,11 +1,11 @@
1
- function isFalsy(input) {
1
+ function isFalsy(input){
2
2
  return (
3
3
  input === undefined || input === null || Number.isNaN(input) === true
4
4
  )
5
5
  }
6
6
 
7
- export function defaultTo(defaultArgument, input) {
8
- if (arguments.length === 1) {
7
+ export function defaultTo(defaultArgument, input){
8
+ if (arguments.length === 1){
9
9
  return _input => defaultTo(defaultArgument, _input)
10
10
  }
11
11
 
package/src/difference.js CHANGED
@@ -1,7 +1,7 @@
1
- import {includes} from './includes'
2
- import {uniq} from './uniq'
1
+ import { includes } from './includes.js'
2
+ import { uniq } from './uniq.js'
3
3
 
4
- export function difference(a, b) {
4
+ export function difference(a, b){
5
5
  if (arguments.length === 1) return _b => difference(a, _b)
6
6
 
7
7
  return uniq(a).filter(aInstance => !includes(aInstance, b))
package/src/dissoc.js CHANGED
@@ -1,13 +1,13 @@
1
- export function dissoc(prop, obj) {
1
+ export function dissoc(prop, obj){
2
2
  if (arguments.length === 1) return _obj => dissoc(prop, _obj)
3
3
 
4
4
  if (obj === null || obj === undefined) return {}
5
5
 
6
6
  const willReturn = {}
7
- for (const p in obj) {
8
- willReturn[p] = obj[p]
7
+ for (const p in obj){
8
+ willReturn[ p ] = obj[ p ]
9
9
  }
10
- delete willReturn[prop]
10
+ delete willReturn[ prop ]
11
11
 
12
12
  return willReturn
13
13
  }
package/src/divide.js CHANGED
@@ -1,4 +1,4 @@
1
- export function divide(a, b) {
1
+ export function divide(a, b){
2
2
  if (arguments.length === 1) return _b => divide(a, _b)
3
3
 
4
4
  return a / b