rambda 6.9.0 → 7.0.3

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 (188) hide show
  1. package/CHANGELOG.md +87 -1
  2. package/README.md +3827 -4905
  3. package/dist/rambda.esm.js +301 -208
  4. package/dist/rambda.js +306 -209
  5. package/dist/rambda.mjs +303 -210
  6. package/dist/rambda.umd.js +1 -1
  7. package/immutable.d.ts +207 -285
  8. package/index.d.ts +198 -276
  9. package/package.json +119 -98
  10. package/src/F.js +1 -1
  11. package/src/T.js +1 -1
  12. package/src/_internals/_isInteger.js +1 -1
  13. package/src/_internals/_objectIs.js +2 -2
  14. package/src/_internals/baseSlice.js +6 -8
  15. package/src/_internals/cloneList.js +3 -0
  16. package/src/_internals/isFalsy.js +5 -5
  17. package/src/_internals/isObject.js +3 -3
  18. package/src/_internals/isTruthy.js +5 -5
  19. package/src/_internals/set.js +4 -4
  20. package/src/add.js +1 -1
  21. package/src/adjust.js +5 -6
  22. package/src/all.js +3 -3
  23. package/src/allPass.js +4 -4
  24. package/src/always.js +1 -1
  25. package/src/and.js +1 -1
  26. package/src/any.js +3 -3
  27. package/src/anyPass.js +4 -4
  28. package/src/append.js +4 -2
  29. package/src/apply.js +7 -0
  30. package/src/applySpec.js +33 -59
  31. package/src/assoc.js +3 -7
  32. package/src/assocPath.js +22 -25
  33. package/src/bind.js +9 -0
  34. package/src/both.js +1 -1
  35. package/src/chain.js +2 -2
  36. package/src/clamp.js +6 -6
  37. package/src/clone.js +10 -10
  38. package/src/complement.js +1 -1
  39. package/src/compose.js +6 -6
  40. package/src/concat.js +2 -2
  41. package/src/cond.js +3 -3
  42. package/src/converge.js +11 -11
  43. package/src/curry.js +2 -2
  44. package/src/curryN.js +61 -81
  45. package/src/defaultTo.js +5 -8
  46. package/src/difference.js +3 -3
  47. package/src/dissoc.js +4 -4
  48. package/src/divide.js +1 -1
  49. package/src/drop.js +1 -1
  50. package/src/dropLast.js +5 -5
  51. package/src/dropLastWhile.js +12 -12
  52. package/src/dropRepeats.js +6 -6
  53. package/src/dropRepeatsWith.js +7 -7
  54. package/src/dropWhile.js +9 -9
  55. package/src/either.js +2 -2
  56. package/src/endsWith.js +20 -3
  57. package/src/eqProps.js +5 -10
  58. package/src/equals.js +119 -38
  59. package/src/evolve.js +23 -21
  60. package/src/filter.js +18 -18
  61. package/src/find.js +4 -4
  62. package/src/findIndex.js +3 -3
  63. package/src/findLast.js +4 -4
  64. package/src/findLastIndex.js +3 -3
  65. package/src/flatten.js +6 -6
  66. package/src/flip.js +11 -15
  67. package/src/forEach.js +10 -12
  68. package/src/fromPairs.js +2 -2
  69. package/src/groupBy.js +6 -6
  70. package/src/groupWith.js +11 -12
  71. package/src/hasPath.js +5 -5
  72. package/src/head.js +3 -3
  73. package/src/identical.js +1 -1
  74. package/src/identity.js +2 -2
  75. package/src/ifElse.js +3 -5
  76. package/src/includes.js +11 -10
  77. package/src/indexBy.js +11 -11
  78. package/src/indexOf.js +3 -25
  79. package/src/init.js +2 -4
  80. package/src/intersection.js +3 -3
  81. package/src/intersperse.js +5 -5
  82. package/src/is.js +2 -2
  83. package/src/isEmpty.js +5 -5
  84. package/src/isFunction.js +3 -3
  85. package/src/isNil.js +1 -1
  86. package/src/isPromise.js +3 -3
  87. package/src/join.js +1 -1
  88. package/src/keys.js +1 -1
  89. package/src/last.js +4 -4
  90. package/src/lastIndexOf.js +5 -11
  91. package/src/length.js +6 -5
  92. package/src/lens.js +3 -3
  93. package/src/lensIndex.js +4 -4
  94. package/src/lensProp.js +4 -4
  95. package/src/map.js +17 -18
  96. package/src/match.js +1 -1
  97. package/src/mathMod.js +2 -2
  98. package/src/max.js +1 -1
  99. package/src/maxBy.js +2 -4
  100. package/src/maybe.js +2 -4
  101. package/src/mean.js +2 -2
  102. package/src/median.js +12 -10
  103. package/src/merge.js +2 -4
  104. package/src/mergeAll.js +3 -3
  105. package/src/mergeDeepRight.js +8 -8
  106. package/src/mergeLeft.js +2 -2
  107. package/src/min.js +1 -1
  108. package/src/minBy.js +2 -4
  109. package/src/modulo.js +1 -1
  110. package/src/move.js +7 -8
  111. package/src/multiply.js +1 -1
  112. package/src/negate.js +1 -1
  113. package/src/none.js +4 -4
  114. package/src/not.js +1 -1
  115. package/src/nth.js +4 -4
  116. package/src/objOf.js +3 -3
  117. package/src/of.js +2 -2
  118. package/src/omit.js +5 -5
  119. package/src/once.js +6 -6
  120. package/src/or.js +1 -1
  121. package/src/over.js +3 -5
  122. package/src/partial.js +3 -3
  123. package/src/partition.js +17 -15
  124. package/src/path.js +6 -6
  125. package/src/pathEq.js +4 -6
  126. package/src/pathOr.js +5 -7
  127. package/src/paths.js +3 -3
  128. package/src/pick.js +5 -5
  129. package/src/pickAll.js +6 -6
  130. package/src/pipe.js +3 -3
  131. package/src/pluck.js +4 -4
  132. package/src/prepend.js +3 -3
  133. package/src/product.js +2 -2
  134. package/src/prop.js +2 -2
  135. package/src/propEq.js +3 -5
  136. package/src/propIs.js +4 -6
  137. package/src/propOr.js +4 -6
  138. package/src/props.js +6 -6
  139. package/src/range.js +4 -4
  140. package/src/reduce.js +7 -11
  141. package/src/reject.js +2 -2
  142. package/src/repeat.js +2 -2
  143. package/src/replace.js +2 -4
  144. package/src/reverse.js +3 -4
  145. package/src/set.js +5 -9
  146. package/src/slice.js +2 -4
  147. package/src/sort.js +4 -4
  148. package/src/sortBy.js +4 -2
  149. package/src/split.js +1 -1
  150. package/src/splitAt.js +9 -9
  151. package/src/splitEvery.js +8 -6
  152. package/src/splitWhen.js +10 -10
  153. package/src/startsWith.js +20 -3
  154. package/src/subtract.js +1 -1
  155. package/src/sum.js +1 -1
  156. package/src/symmetricDifference.js +9 -7
  157. package/src/tail.js +2 -2
  158. package/src/take.js +2 -4
  159. package/src/takeLast.js +2 -4
  160. package/src/takeLastWhile.js +7 -7
  161. package/src/takeWhile.js +8 -8
  162. package/src/tap.js +1 -1
  163. package/src/test.js +5 -3
  164. package/src/times.js +4 -4
  165. package/src/toLower.js +1 -1
  166. package/src/toPairs.js +1 -1
  167. package/src/toString.js +1 -1
  168. package/src/toUpper.js +1 -1
  169. package/src/transpose.js +4 -3
  170. package/src/trim.js +1 -1
  171. package/src/tryCatch.js +5 -5
  172. package/src/type.js +7 -29
  173. package/src/unapply.js +5 -0
  174. package/src/union.js +4 -3
  175. package/src/uniq.js +2 -2
  176. package/src/uniqWith.js +18 -7
  177. package/src/unless.js +3 -3
  178. package/src/update.js +6 -8
  179. package/src/values.js +2 -2
  180. package/src/view.js +2 -2
  181. package/src/when.js +2 -4
  182. package/src/where.js +5 -5
  183. package/src/whereEq.js +9 -7
  184. package/src/without.js +1 -1
  185. package/src/xor.js +2 -2
  186. package/src/zip.js +3 -3
  187. package/src/zipObj.js +4 -6
  188. package/src/zipWith.js +6 -7
package/src/endsWith.js CHANGED
@@ -1,5 +1,22 @@
1
- export function endsWith(target, str){
2
- if (arguments.length === 1) return _str => endsWith(target, _str)
1
+ import {equals} from './equals.js'
2
+ import {_isArray} from './_internals/_isArray.js'
3
3
 
4
- return str.endsWith(target)
4
+ export function endsWith(target, iterable) {
5
+ if (arguments.length === 1) return _iterable => endsWith(target, _iterable)
6
+
7
+ if (typeof iterable === 'string') {
8
+ return iterable.endsWith(target)
9
+ }
10
+ if (!_isArray(target)) return false
11
+
12
+ const diff = iterable.length - target.length
13
+ let correct = true
14
+ const filtered = target.filter((x, index) => {
15
+ if (!correct) return false
16
+ const result = equals(x, iterable[index + diff])
17
+ if (!result) correct = false
18
+ return result
19
+ })
20
+
21
+ return filtered.length === target.length
5
22
  }
package/src/eqProps.js CHANGED
@@ -1,14 +1,9 @@
1
- import { curry } from './curry'
2
- import { equals } from './equals'
1
+ import {curry} from './curry'
2
+ import {equals} from './equals'
3
+ import {prop} from './prop'
3
4
 
4
- function eqPropsFn(
5
- prop, obj1, obj2
6
- ){
7
- if (!obj1 || !obj2){
8
- throw new Error('wrong object inputs are passed to R.eqProps')
9
- }
10
-
11
- return equals(obj1[ prop ], obj2[ prop ])
5
+ function eqPropsFn(property, objA, objB) {
6
+ return equals(prop(property, objA), prop(property, objB))
12
7
  }
13
8
 
14
9
  export const eqProps = curry(eqPropsFn)
package/src/equals.js CHANGED
@@ -1,60 +1,139 @@
1
- import { type } from './type'
1
+ import {type} from './type'
2
+ import {_isArray} from './_internals/_isArray'
2
3
 
3
- function parseError(maybeError){
4
+ export function _lastIndexOf(valueToFind, list) {
5
+ if (!_isArray(list)) {
6
+ throw new Error(`Cannot read property 'indexOf' of ${list}`)
7
+ }
8
+ const typeOfValue = type(valueToFind)
9
+ if (!['Object', 'Array', 'NaN', 'RegExp'].includes(typeOfValue))
10
+ return list.lastIndexOf(valueToFind)
11
+
12
+ const {length} = list
13
+ let index = length
14
+ let foundIndex = -1
15
+
16
+ while (--index > -1 && foundIndex === -1) {
17
+ if (equals(list[index], valueToFind)) {
18
+ foundIndex = index
19
+ }
20
+ }
21
+
22
+ return foundIndex
23
+ }
24
+
25
+ export function _indexOf(valueToFind, list) {
26
+ if (!_isArray(list)) {
27
+ throw new Error(`Cannot read property 'indexOf' of ${list}`)
28
+ }
29
+ const typeOfValue = type(valueToFind)
30
+ if (!['Object', 'Array', 'NaN', 'RegExp'].includes(typeOfValue))
31
+ return list.indexOf(valueToFind)
32
+
33
+ let index = -1
34
+ let foundIndex = -1
35
+ const {length} = list
36
+
37
+ while (++index < length && foundIndex === -1) {
38
+ if (equals(list[index], valueToFind)) {
39
+ foundIndex = index
40
+ }
41
+ }
42
+
43
+ return foundIndex
44
+ }
45
+
46
+ function _arrayFromIterator(iter) {
47
+ const list = []
48
+ let next
49
+ while (!(next = iter.next()).done) {
50
+ list.push(next.value)
51
+ }
52
+ return list
53
+ }
54
+
55
+ function _equalsSets(a, b) {
56
+ if (a.size !== b.size) {
57
+ return false
58
+ }
59
+ const aList = _arrayFromIterator(a.values())
60
+ const bList = _arrayFromIterator(b.values())
61
+
62
+ const filtered = aList.filter(
63
+ aInstance => _indexOf(aInstance, bList) === -1
64
+ )
65
+ return filtered.length === 0
66
+ }
67
+
68
+ function parseError(maybeError) {
4
69
  const typeofError = maybeError.__proto__.toString()
5
- if (![ 'Error', 'TypeError' ].includes(typeofError)) return []
70
+ if (!['Error', 'TypeError'].includes(typeofError)) return []
6
71
 
7
- return [ typeofError, maybeError.message ]
72
+ return [typeofError, maybeError.message]
8
73
  }
9
74
 
10
- function parseDate(maybeDate){
11
- if (!maybeDate.toDateString) return [ false ]
75
+ function parseDate(maybeDate) {
76
+ if (!maybeDate.toDateString) return [false]
12
77
 
13
- return [ true, maybeDate.getTime() ]
78
+ return [true, maybeDate.getTime()]
14
79
  }
15
80
 
16
- function parseRegex(maybeRegex){
17
- if (maybeRegex.constructor !== RegExp) return [ false ]
81
+ function parseRegex(maybeRegex) {
82
+ if (maybeRegex.constructor !== RegExp) return [false]
18
83
 
19
- return [ true, maybeRegex.toString() ]
84
+ return [true, maybeRegex.toString()]
20
85
  }
21
86
 
22
- export function equals(a, b){
87
+ function equalsSets(a, b) {
88
+ if (a.size !== b.size) {
89
+ return false
90
+ }
91
+ const aList = _arrayFromIterator(a.values())
92
+ const bList = _arrayFromIterator(b.values())
93
+
94
+ const filtered = aList.filter(
95
+ aInstance => _indexOf(aInstance, bList) === -1
96
+ )
97
+ return filtered.length === 0
98
+ }
99
+
100
+ export function equals(a, b) {
23
101
  if (arguments.length === 1) return _b => equals(a, _b)
24
102
 
25
103
  const aType = type(a)
104
+
26
105
  if (aType !== type(b)) return false
27
- if (aType === 'Function'){
106
+ if (aType === 'Function') {
28
107
  return a.name === undefined ? false : a.name === b.name
29
108
  }
30
109
 
31
- if ([ 'NaN', 'Undefined', 'Null' ].includes(aType)) return true
110
+ if (['NaN', 'Undefined', 'Null'].includes(aType)) return true
32
111
 
33
- if (aType === 'Number'){
112
+ if (aType === 'Number') {
34
113
  if (Object.is(-0, a) !== Object.is(-0, b)) return false
35
114
 
36
115
  return a.toString() === b.toString()
37
116
  }
38
117
 
39
- if ([ 'String', 'Boolean' ].includes(aType)){
118
+ if (['String', 'Boolean'].includes(aType)) {
40
119
  return a.toString() === b.toString()
41
120
  }
42
121
 
43
- if (aType === 'Array'){
122
+ if (aType === 'Array') {
44
123
  const aClone = Array.from(a)
45
124
  const bClone = Array.from(b)
46
125
 
47
- if (aClone.toString() !== bClone.toString()){
126
+ if (aClone.toString() !== bClone.toString()) {
48
127
  return false
49
128
  }
50
129
 
51
130
  let loopArrayFlag = true
52
131
  aClone.forEach((aCloneInstance, aCloneIndex) => {
53
- if (loopArrayFlag){
132
+ if (loopArrayFlag) {
54
133
  if (
55
- aCloneInstance !== bClone[ aCloneIndex ] &&
56
- !equals(aCloneInstance, bClone[ aCloneIndex ])
57
- ){
134
+ aCloneInstance !== bClone[aCloneIndex] &&
135
+ !equals(aCloneInstance, bClone[aCloneIndex])
136
+ ) {
58
137
  loopArrayFlag = false
59
138
  }
60
139
  }
@@ -66,40 +145,42 @@ export function equals(a, b){
66
145
  const aRegex = parseRegex(a)
67
146
  const bRegex = parseRegex(b)
68
147
 
69
- if (aRegex[ 0 ]){
70
- return bRegex[ 0 ] ? aRegex[ 1 ] === bRegex[ 1 ] : false
71
- } else if (bRegex[ 0 ]) return false
148
+ if (aRegex[0]) {
149
+ return bRegex[0] ? aRegex[1] === bRegex[1] : false
150
+ } else if (bRegex[0]) return false
72
151
 
73
152
  const aDate = parseDate(a)
74
153
  const bDate = parseDate(b)
75
154
 
76
- if (aDate[ 0 ]){
77
- return bDate[ 0 ] ? aDate[ 1 ] === bDate[ 1 ] : false
78
- } else if (bDate[ 0 ]) return false
155
+ if (aDate[0]) {
156
+ return bDate[0] ? aDate[1] === bDate[1] : false
157
+ } else if (bDate[0]) return false
79
158
 
80
159
  const aError = parseError(a)
81
160
  const bError = parseError(b)
82
161
 
83
- if (aError[ 0 ]){
84
- return bError[ 0 ] ?
85
- aError[ 0 ] === bError[ 0 ] && aError[ 1 ] === bError[ 1 ] :
86
- false
162
+ if (aError[0]) {
163
+ return bError[0]
164
+ ? aError[0] === bError[0] && aError[1] === bError[1]
165
+ : false
87
166
  }
88
-
89
- if (aType === 'Object'){
167
+ if (aType === 'Set') {
168
+ return _equalsSets(a, b)
169
+ }
170
+ if (aType === 'Object') {
90
171
  const aKeys = Object.keys(a)
91
172
 
92
- if (aKeys.length !== Object.keys(b).length){
173
+ if (aKeys.length !== Object.keys(b).length) {
93
174
  return false
94
175
  }
95
176
 
96
177
  let loopObjectFlag = true
97
178
  aKeys.forEach(aKeyInstance => {
98
- if (loopObjectFlag){
99
- const aValue = a[ aKeyInstance ]
100
- const bValue = b[ aKeyInstance ]
179
+ if (loopObjectFlag) {
180
+ const aValue = a[aKeyInstance]
181
+ const bValue = b[aKeyInstance]
101
182
 
102
- if (aValue !== bValue && !equals(aValue, bValue)){
183
+ if (aValue !== bValue && !equals(aValue, bValue)) {
103
184
  loopObjectFlag = false
104
185
  }
105
186
  }
package/src/evolve.js CHANGED
@@ -1,12 +1,12 @@
1
- import { _isArray } from './_internals/_isArray'
2
- import { mapArray, mapObject } from './map'
3
- import { type } from './type'
1
+ import {_isArray} from './_internals/_isArray'
2
+ import {mapArray, mapObject} from './map'
3
+ import {type} from './type'
4
4
 
5
- export function evolveArray(rules, list){
5
+ export function evolveArray(rules, list) {
6
6
  return mapArray(
7
7
  (x, i) => {
8
- if (type(rules[ i ]) === 'Function'){
9
- return rules[ i ](x)
8
+ if (type(rules[i]) === 'Function') {
9
+ return rules[i](x)
10
10
  }
11
11
 
12
12
  return x
@@ -16,43 +16,45 @@ export function evolveArray(rules, list){
16
16
  )
17
17
  }
18
18
 
19
- export function evolveObject(rules, iterable){
19
+ export function evolveObject(rules, iterable) {
20
20
  return mapObject((x, prop) => {
21
- if (type(x) === 'Object'){
22
- const typeRule = type(rules[ prop ])
23
- if (typeRule === 'Function'){
24
- return rules[ prop ](x)
21
+ if (type(x) === 'Object') {
22
+ const typeRule = type(rules[prop])
23
+ if (typeRule === 'Function') {
24
+ return rules[prop](x)
25
25
  }
26
- if (typeRule === 'Object'){
27
- return evolve(rules[ prop ], x)
26
+ if (typeRule === 'Object') {
27
+ return evolve(rules[prop], x)
28
28
  }
29
29
 
30
30
  return x
31
31
  }
32
- if (type(rules[ prop ]) === 'Function'){
33
- return rules[ prop ](x)
32
+ if (type(rules[prop]) === 'Function') {
33
+ return rules[prop](x)
34
34
  }
35
35
 
36
36
  return x
37
37
  }, iterable)
38
38
  }
39
39
 
40
- export function evolve(rules, iterable){
41
- if (arguments.length === 1){
40
+ export function evolve(rules, iterable) {
41
+ if (arguments.length === 1) {
42
42
  return _iterable => evolve(rules, _iterable)
43
43
  }
44
44
  const rulesType = type(rules)
45
45
  const iterableType = type(iterable)
46
46
 
47
- if (iterableType !== rulesType){
47
+ if (iterableType !== rulesType) {
48
48
  throw new Error('iterableType !== rulesType')
49
49
  }
50
50
 
51
- if (![ 'Object', 'Array' ].includes(rulesType)){
52
- throw new Error(`'iterable' and 'rules' are from wrong type ${ rulesType }`)
51
+ if (!['Object', 'Array'].includes(rulesType)) {
52
+ throw new Error(
53
+ `'iterable' and 'rules' are from wrong type ${rulesType}`
54
+ )
53
55
  }
54
56
 
55
- if (iterableType === 'Object'){
57
+ if (iterableType === 'Object') {
56
58
  return evolveObject(rules, iterable)
57
59
  }
58
60
 
package/src/filter.js CHANGED
@@ -1,30 +1,28 @@
1
- import { _isArray } from './_internals/_isArray'
1
+ import {_isArray} from './_internals/_isArray'
2
2
 
3
- export function filterObject(predicate, obj){
3
+ export function filterObject(predicate, obj) {
4
4
  const willReturn = {}
5
5
 
6
- for (const prop in obj){
7
- if (predicate(obj[ prop ], prop, obj)){
8
- willReturn[ prop ] = obj[ prop ]
6
+ for (const prop in obj) {
7
+ if (predicate(obj[prop], prop, obj)) {
8
+ willReturn[prop] = obj[prop]
9
9
  }
10
10
  }
11
11
 
12
12
  return willReturn
13
13
  }
14
14
 
15
- export function filterArray(
16
- predicate, list, indexed = false
17
- ){
15
+ export function filterArray(predicate, list, indexed = false) {
18
16
  let index = 0
19
17
  const len = list.length
20
18
  const willReturn = []
21
19
 
22
- while (index < len){
23
- const predicateResult = indexed ?
24
- predicate(list[ index ], index) :
25
- predicate(list[ index ])
26
- if (predicateResult){
27
- willReturn.push(list[ index ])
20
+ while (index < len) {
21
+ const predicateResult = indexed
22
+ ? predicate(list[index], index)
23
+ : predicate(list[index])
24
+ if (predicateResult) {
25
+ willReturn.push(list[index])
28
26
  }
29
27
 
30
28
  index++
@@ -33,12 +31,14 @@ export function filterArray(
33
31
  return willReturn
34
32
  }
35
33
 
36
- export function filter(predicate, iterable){
37
- if (arguments.length === 1){
34
+ export function filter(predicate, iterable) {
35
+ if (arguments.length === 1)
38
36
  return _iterable => filter(predicate, _iterable)
37
+ if (!iterable) {
38
+ throw new Error('Incorrect iterable input')
39
39
  }
40
- if (!iterable) return []
41
- if (_isArray(iterable)) return filterArray(predicate, iterable)
40
+
41
+ if (_isArray(iterable)) return filterArray(predicate, iterable, false)
42
42
 
43
43
  return filterObject(predicate, iterable)
44
44
  }
package/src/find.js CHANGED
@@ -1,12 +1,12 @@
1
- export function find(predicate, list){
1
+ export function find(predicate, list) {
2
2
  if (arguments.length === 1) return _list => find(predicate, _list)
3
3
 
4
4
  let index = 0
5
5
  const len = list.length
6
6
 
7
- while (index < len){
8
- const x = list[ index ]
9
- if (predicate(x)){
7
+ while (index < len) {
8
+ const x = list[index]
9
+ if (predicate(x)) {
10
10
  return x
11
11
  }
12
12
 
package/src/findIndex.js CHANGED
@@ -1,11 +1,11 @@
1
- export function findIndex(predicate, list){
1
+ export function findIndex(predicate, list) {
2
2
  if (arguments.length === 1) return _list => findIndex(predicate, _list)
3
3
 
4
4
  const len = list.length
5
5
  let index = -1
6
6
 
7
- while (++index < len){
8
- if (predicate(list[ index ])){
7
+ while (++index < len) {
8
+ if (predicate(list[index])) {
9
9
  return index
10
10
  }
11
11
  }
package/src/findLast.js CHANGED
@@ -1,11 +1,11 @@
1
- export function findLast(predicate, list){
1
+ export function findLast(predicate, list) {
2
2
  if (arguments.length === 1) return _list => findLast(predicate, _list)
3
3
 
4
4
  let index = list.length
5
5
 
6
- while (--index >= 0){
7
- if (predicate(list[ index ])){
8
- return list[ index ]
6
+ while (--index >= 0) {
7
+ if (predicate(list[index])) {
8
+ return list[index]
9
9
  }
10
10
  }
11
11
 
@@ -1,10 +1,10 @@
1
- export function findLastIndex(fn, list){
1
+ export function findLastIndex(fn, list) {
2
2
  if (arguments.length === 1) return _list => findLastIndex(fn, _list)
3
3
 
4
4
  let index = list.length
5
5
 
6
- while (--index >= 0){
7
- if (fn(list[ index ])){
6
+ while (--index >= 0) {
7
+ if (fn(list[index])) {
8
8
  return index
9
9
  }
10
10
  }
package/src/flatten.js CHANGED
@@ -1,13 +1,13 @@
1
- import { _isArray } from './_internals/_isArray'
1
+ import {_isArray} from './_internals/_isArray'
2
2
 
3
- export function flatten(list, input){
3
+ export function flatten(list, input) {
4
4
  const willReturn = input === undefined ? [] : input
5
5
 
6
- for (let i = 0; i < list.length; i++){
7
- if (_isArray(list[ i ])){
8
- flatten(list[ i ], willReturn)
6
+ for (let i = 0; i < list.length; i++) {
7
+ if (_isArray(list[i])) {
8
+ flatten(list[i], willReturn)
9
9
  } else {
10
- willReturn.push(list[ i ])
10
+ willReturn.push(list[i])
11
11
  }
12
12
  }
13
13
 
package/src/flip.js CHANGED
@@ -1,23 +1,19 @@
1
- function flipFn(fn){
1
+ function flipFn(fn) {
2
2
  return (...input) => {
3
- if (input.length === 1){
4
- return holder => fn(holder, input[ 0 ])
5
- } else if (input.length === 2){
6
- return fn(input[ 1 ], input[ 0 ])
7
- } else if (input.length === 3){
8
- return fn(
9
- input[ 1 ], input[ 0 ], input[ 2 ]
10
- )
11
- } else if (input.length === 4){
12
- return fn(
13
- input[ 1 ], input[ 0 ], input[ 2 ], input[ 3 ]
14
- )
3
+ if (input.length === 1) {
4
+ return holder => fn(holder, input[0])
5
+ } else if (input.length === 2) {
6
+ return fn(input[1], input[0])
7
+ } else if (input.length === 3) {
8
+ return fn(input[1], input[0], input[2])
9
+ } else if (input.length === 4) {
10
+ return fn(input[1], input[0], input[2], input[3])
15
11
  }
16
12
 
17
- throw new Error('R.flip doesn\'t work with arity > 4')
13
+ throw new Error("R.flip doesn't work with arity > 4")
18
14
  }
19
15
  }
20
16
 
21
- export function flip(fn){
17
+ export function flip(fn) {
22
18
  return flipFn(fn)
23
19
  }
package/src/forEach.js CHANGED
@@ -1,19 +1,19 @@
1
- import { _isArray } from './_internals/_isArray'
2
- import { _keys } from './_internals/_keys'
1
+ import {_isArray} from './_internals/_isArray'
2
+ import {_keys} from './_internals/_keys'
3
3
 
4
- export function forEach(fn, list){
4
+ export function forEach(fn, list) {
5
5
  if (arguments.length === 1) return _list => forEach(fn, _list)
6
6
 
7
- if (list === undefined){
7
+ if (list === undefined) {
8
8
  return
9
9
  }
10
10
 
11
- if (_isArray(list)){
11
+ if (_isArray(list)) {
12
12
  let index = 0
13
13
  const len = list.length
14
14
 
15
- while (index < len){
16
- fn(list[ index ])
15
+ while (index < len) {
16
+ fn(list[index])
17
17
  index++
18
18
  }
19
19
  } else {
@@ -21,11 +21,9 @@ export function forEach(fn, list){
21
21
  const keys = _keys(list)
22
22
  const len = keys.length
23
23
 
24
- while (index < len){
25
- const key = keys[ index ]
26
- fn(
27
- list[ key ], key, list
28
- )
24
+ while (index < len) {
25
+ const key = keys[index]
26
+ fn(list[key], key, list)
29
27
  index++
30
28
  }
31
29
  }
package/src/fromPairs.js CHANGED
@@ -1,6 +1,6 @@
1
- export function fromPairs(listOfPairs){
1
+ export function fromPairs(listOfPairs) {
2
2
  const toReturn = {}
3
- listOfPairs.forEach(([ prop, value ]) => toReturn[ prop ] = value)
3
+ listOfPairs.forEach(([prop, value]) => (toReturn[prop] = value))
4
4
 
5
5
  return toReturn
6
6
  }
package/src/groupBy.js CHANGED
@@ -1,16 +1,16 @@
1
- export function groupBy(groupFn, list){
1
+ export function groupBy(groupFn, list) {
2
2
  if (arguments.length === 1) return _list => groupBy(groupFn, _list)
3
3
 
4
4
  const result = {}
5
- for (let i = 0; i < list.length; i++){
6
- const item = list[ i ]
5
+ for (let i = 0; i < list.length; i++) {
6
+ const item = list[i]
7
7
  const key = groupFn(item)
8
8
 
9
- if (!result[ key ]){
10
- result[ key ] = []
9
+ if (!result[key]) {
10
+ result[key] = []
11
11
  }
12
12
 
13
- result[ key ].push(item)
13
+ result[key].push(item)
14
14
  }
15
15
 
16
16
  return result
package/src/groupWith.js CHANGED
@@ -1,25 +1,24 @@
1
- import { _isArray } from './_internals/_isArray'
1
+ import {_isArray} from './_internals/_isArray'
2
+ import {cloneList} from './_internals/cloneList'
2
3
 
3
- export function groupWith(compareFn, list){
4
+ export function groupWith(compareFn, list) {
4
5
  if (!_isArray(list)) throw new TypeError('list.reduce is not a function')
5
6
 
6
- const clone = list.slice()
7
+ const clone = cloneList(list)
7
8
 
8
- if (list.length === 1) return [ clone ]
9
+ if (list.length === 1) return [clone]
9
10
 
10
11
  const toReturn = []
11
12
  let holder = []
12
13
 
13
- clone.reduce((
14
- prev, current, i
15
- ) => {
14
+ clone.reduce((prev, current, i) => {
16
15
  if (i === 0) return current
17
16
 
18
17
  const okCompare = compareFn(prev, current)
19
18
  const holderIsEmpty = holder.length === 0
20
19
  const lastCall = i === list.length - 1
21
20
 
22
- if (okCompare){
21
+ if (okCompare) {
23
22
  if (holderIsEmpty) holder.push(prev)
24
23
  holder.push(current)
25
24
  if (lastCall) toReturn.push(holder)
@@ -27,15 +26,15 @@ export function groupWith(compareFn, list){
27
26
  return current
28
27
  }
29
28
 
30
- if (holderIsEmpty){
31
- toReturn.push([ prev ])
32
- if (lastCall) toReturn.push([ current ])
29
+ if (holderIsEmpty) {
30
+ toReturn.push([prev])
31
+ if (lastCall) toReturn.push([current])
33
32
 
34
33
  return current
35
34
  }
36
35
 
37
36
  toReturn.push(holder)
38
- if (lastCall) toReturn.push([ current ])
37
+ if (lastCall) toReturn.push([current])
39
38
  holder = []
40
39
 
41
40
  return current
package/src/hasPath.js CHANGED
@@ -1,9 +1,9 @@
1
- import { path } from './path'
1
+ import {path} from './path'
2
2
 
3
- export function hasPath(maybePath, obj){
4
- if (arguments.length === 1){
5
- return objHolder => hasPath(maybePath, objHolder)
3
+ export function hasPath(pathInput, obj) {
4
+ if (arguments.length === 1) {
5
+ return objHolder => hasPath(pathInput, objHolder)
6
6
  }
7
7
 
8
- return path(maybePath, obj) !== undefined
8
+ return path(pathInput, obj) !== undefined
9
9
  }