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