rambda 9.4.2 → 10.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (271) hide show
  1. package/CHANGELOG.md +177 -1
  2. package/README.md +6799 -11799
  3. package/dist/rambda.cjs +1795 -0
  4. package/dist/rambda.js +1162 -2234
  5. package/dist/rambda.umd.js +1801 -1
  6. package/immutable.d.ts +1154 -1403
  7. package/index.d.ts +1154 -1403
  8. package/package.json +102 -94
  9. package/rambda.js +24 -137
  10. package/src/_internals/baseSlice.js +5 -7
  11. package/src/_internals/createPath.js +4 -6
  12. package/src/_internals/includes.js +8 -4
  13. package/src/_internals/set.js +11 -11
  14. package/src/addProp.js +3 -0
  15. package/src/all.js +8 -6
  16. package/src/allPass.js +4 -4
  17. package/src/any.js +10 -10
  18. package/src/anyPass.js +4 -4
  19. package/src/append.js +6 -8
  20. package/src/ascend.js +8 -15
  21. package/src/checkObjectWithSpec.js +16 -0
  22. package/src/compact.js +12 -0
  23. package/src/complement.js +1 -1
  24. package/src/concat.js +2 -4
  25. package/src/count.js +7 -6
  26. package/src/countBy.js +13 -14
  27. package/src/createObjectFromKeys.js +10 -0
  28. package/src/defaultTo.js +4 -6
  29. package/src/descend.js +6 -13
  30. package/src/drop.js +4 -2
  31. package/src/dropLast.js +2 -8
  32. package/src/dropLastWhile.js +17 -26
  33. package/src/dropWhile.js +14 -22
  34. package/src/eqBy.js +3 -8
  35. package/src/eqProps.js +3 -9
  36. package/src/equals.js +99 -58
  37. package/src/evolve.js +3 -57
  38. package/src/excludes.js +5 -0
  39. package/src/filter.js +13 -43
  40. package/src/filterObject.js +13 -0
  41. package/src/find.js +10 -10
  42. package/src/findIndex.js +10 -10
  43. package/src/findLast.js +9 -9
  44. package/src/findLastIndex.js +9 -9
  45. package/src/findNth.js +16 -0
  46. package/src/flatMap.js +3 -0
  47. package/src/flatten.js +5 -5
  48. package/src/groupBy.js +14 -11
  49. package/src/head.js +5 -3
  50. package/src/includes.js +13 -11
  51. package/src/indexOf.js +2 -6
  52. package/src/init.js +6 -8
  53. package/src/innerJoin.js +11 -19
  54. package/src/interpolate.js +29 -0
  55. package/src/intersection.js +2 -4
  56. package/src/intersperse.js +13 -13
  57. package/src/join.js +2 -4
  58. package/src/last.js +4 -4
  59. package/src/lastIndexOf.js +2 -6
  60. package/src/map.js +9 -49
  61. package/src/mapAsync.js +11 -0
  62. package/src/mapKeys.js +11 -0
  63. package/src/mapObject.js +18 -0
  64. package/src/mapObjectAsync.js +10 -0
  65. package/src/mapParallelAsync.js +3 -0
  66. package/src/match.js +5 -5
  67. package/src/maxBy.js +2 -8
  68. package/src/merge.js +4 -1
  69. package/src/mergeTypes.js +3 -0
  70. package/src/minBy.js +2 -8
  71. package/src/modifyProp.js +20 -0
  72. package/src/none.js +8 -6
  73. package/src/objOf.js +2 -6
  74. package/src/objectIncludes.js +12 -0
  75. package/src/omit.js +26 -11
  76. package/src/partition.js +15 -42
  77. package/src/partitionObject.js +15 -0
  78. package/src/path.js +14 -15
  79. package/src/permutations.js +40 -0
  80. package/src/pick.js +15 -15
  81. package/src/pipe.js +70 -13
  82. package/src/pipeAsync.js +11 -0
  83. package/src/pluck.js +12 -14
  84. package/src/prepend.js +2 -6
  85. package/src/prop.js +2 -10
  86. package/src/propEq.js +8 -10
  87. package/src/propOr.js +7 -8
  88. package/src/propSatisfies.js +2 -9
  89. package/src/range.js +34 -11
  90. package/src/reduce.js +15 -30
  91. package/src/reject.js +2 -4
  92. package/src/rejectObject.js +13 -0
  93. package/src/replace.js +2 -8
  94. package/src/replaceItemAtIndex.js +15 -0
  95. package/src/shuffle.js +13 -0
  96. package/src/sort.js +2 -4
  97. package/src/sortBy.js +12 -10
  98. package/src/sortObject.js +15 -0
  99. package/src/sortWith.js +12 -16
  100. package/src/split.js +2 -4
  101. package/src/splitEvery.js +11 -13
  102. package/src/symmetricDifference.js +5 -8
  103. package/src/tail.js +2 -2
  104. package/src/take.js +11 -9
  105. package/src/takeLast.js +14 -14
  106. package/src/takeLastWhile.js +15 -16
  107. package/src/takeWhile.js +12 -21
  108. package/src/tap.js +5 -5
  109. package/src/test.js +2 -8
  110. package/src/tryCatch.js +5 -14
  111. package/src/type.js +6 -5
  112. package/src/union.js +10 -8
  113. package/src/uniq.js +2 -2
  114. package/src/uniqBy.js +5 -6
  115. package/src/uniqWith.js +15 -19
  116. package/src/unless.js +7 -9
  117. package/src/unwind.js +6 -14
  118. package/src/update.js +8 -11
  119. package/src/when.js +7 -9
  120. package/src/zip.js +8 -8
  121. package/src/zipWith.js +5 -7
  122. package/src/F.js +0 -3
  123. package/src/T.js +0 -3
  124. package/src/_internals/_arity.js +0 -64
  125. package/src/_internals/compare.js +0 -3
  126. package/src/_internals/constants.js +0 -1
  127. package/src/_internals/createPathInput.js +0 -7
  128. package/src/_internals/isFalsy.js +0 -13
  129. package/src/_internals/isInteger.js +0 -10
  130. package/src/_internals/isIterable.js +0 -5
  131. package/src/_internals/isObject.js +0 -5
  132. package/src/_internals/isTruthy.js +0 -13
  133. package/src/_internals/objectIs.js +0 -9
  134. package/src/_internals/utils.js +0 -21
  135. package/src/add.js +0 -5
  136. package/src/addIndex.js +0 -23
  137. package/src/addIndexRight.js +0 -9
  138. package/src/adjust.js +0 -16
  139. package/src/always.js +0 -3
  140. package/src/and.js +0 -5
  141. package/src/ap.js +0 -7
  142. package/src/aperture.js +0 -15
  143. package/src/apply.js +0 -7
  144. package/src/applySpec.js +0 -132
  145. package/src/applyTo.js +0 -7
  146. package/src/assoc.js +0 -11
  147. package/src/assocPath.js +0 -46
  148. package/src/binary.js +0 -5
  149. package/src/bind.js +0 -9
  150. package/src/both.js +0 -5
  151. package/src/call.js +0 -1
  152. package/src/chain.js +0 -7
  153. package/src/clamp.js +0 -15
  154. package/src/clone.js +0 -18
  155. package/src/collectBy.js +0 -27
  156. package/src/comparator.js +0 -5
  157. package/src/compose.js +0 -9
  158. package/src/composeWith.js +0 -33
  159. package/src/cond.js +0 -14
  160. package/src/converge.js +0 -18
  161. package/src/curry.js +0 -7
  162. package/src/curryN.js +0 -40
  163. package/src/dec.js +0 -1
  164. package/src/difference.js +0 -8
  165. package/src/differenceWith.js +0 -20
  166. package/src/dissoc.js +0 -13
  167. package/src/dissocPath.js +0 -47
  168. package/src/divide.js +0 -5
  169. package/src/dropRepeats.js +0 -20
  170. package/src/dropRepeatsBy.js +0 -21
  171. package/src/dropRepeatsWith.js +0 -28
  172. package/src/either.js +0 -8
  173. package/src/empty.js +0 -15
  174. package/src/endsWith.js +0 -23
  175. package/src/flip.js +0 -23
  176. package/src/forEach.js +0 -19
  177. package/src/forEachObjIndexed.js +0 -24
  178. package/src/fromPairs.js +0 -6
  179. package/src/groupWith.js +0 -46
  180. package/src/gt.js +0 -6
  181. package/src/gte.js +0 -6
  182. package/src/has.js +0 -7
  183. package/src/hasIn.js +0 -9
  184. package/src/hasPath.js +0 -9
  185. package/src/identical.js +0 -7
  186. package/src/identity.js +0 -3
  187. package/src/ifElse.js +0 -17
  188. package/src/inc.js +0 -1
  189. package/src/indexBy.js +0 -29
  190. package/src/insert.js +0 -11
  191. package/src/insertAll.js +0 -7
  192. package/src/is.js +0 -8
  193. package/src/isEmpty.js +0 -18
  194. package/src/isNil.js +0 -3
  195. package/src/isNotEmpty.js +0 -5
  196. package/src/isNotNil.js +0 -3
  197. package/src/isPromise.js +0 -5
  198. package/src/juxt.js +0 -3
  199. package/src/keys.js +0 -3
  200. package/src/length.js +0 -8
  201. package/src/lens.js +0 -7
  202. package/src/lensIndex.js +0 -7
  203. package/src/lensPath.js +0 -7
  204. package/src/lensProp.js +0 -7
  205. package/src/lt.js +0 -6
  206. package/src/lte.js +0 -6
  207. package/src/mathMod.js +0 -8
  208. package/src/max.js +0 -5
  209. package/src/maybe.js +0 -13
  210. package/src/mean.js +0 -5
  211. package/src/median.js +0 -17
  212. package/src/mergeAll.js +0 -11
  213. package/src/mergeDeepLeft.js +0 -5
  214. package/src/mergeDeepRight.js +0 -24
  215. package/src/mergeLeft.js +0 -7
  216. package/src/mergeRight.js +0 -8
  217. package/src/mergeWith.js +0 -25
  218. package/src/min.js +0 -5
  219. package/src/modify.js +0 -23
  220. package/src/modifyPath.js +0 -33
  221. package/src/modulo.js +0 -5
  222. package/src/move.js +0 -19
  223. package/src/multiply.js +0 -5
  224. package/src/negate.js +0 -3
  225. package/src/not.js +0 -3
  226. package/src/nth.js +0 -9
  227. package/src/of.js +0 -3
  228. package/src/on.js +0 -16
  229. package/src/once.js +0 -24
  230. package/src/or.js +0 -5
  231. package/src/over.js +0 -14
  232. package/src/partial.js +0 -17
  233. package/src/partialObject.js +0 -5
  234. package/src/pathEq.js +0 -11
  235. package/src/pathOr.js +0 -11
  236. package/src/pathSatisfies.js +0 -9
  237. package/src/paths.js +0 -9
  238. package/src/pickAll.js +0 -23
  239. package/src/pickBy.js +0 -11
  240. package/src/product.js +0 -4
  241. package/src/propIs.js +0 -10
  242. package/src/props.js +0 -13
  243. package/src/reduceBy.js +0 -29
  244. package/src/removeIndex.js +0 -7
  245. package/src/repeat.js +0 -7
  246. package/src/reverse.js +0 -9
  247. package/src/set.js +0 -9
  248. package/src/slice.js +0 -9
  249. package/src/splitAt.js +0 -21
  250. package/src/splitWhen.js +0 -25
  251. package/src/startsWith.js +0 -23
  252. package/src/subtract.js +0 -5
  253. package/src/sum.js +0 -3
  254. package/src/swap.js +0 -42
  255. package/src/times.js +0 -12
  256. package/src/toLower.js +0 -3
  257. package/src/toPairs.js +0 -3
  258. package/src/toString.js +0 -3
  259. package/src/toUpper.js +0 -3
  260. package/src/transpose.js +0 -10
  261. package/src/trim.js +0 -3
  262. package/src/unapply.js +0 -5
  263. package/src/unnest.js +0 -9
  264. package/src/values.js +0 -6
  265. package/src/view.js +0 -10
  266. package/src/where.js +0 -15
  267. package/src/whereAny.js +0 -12
  268. package/src/whereEq.js +0 -14
  269. package/src/without.js +0 -15
  270. package/src/xor.js +0 -5
  271. package/src/zipObj.js +0 -13
package/src/append.js CHANGED
@@ -1,12 +1,10 @@
1
1
  import { cloneList } from './_internals/cloneList.js'
2
2
 
3
- export function append(x, input){
4
- if (arguments.length === 1) return _input => append(x, _input)
3
+ export function append(x) {
4
+ return list => {
5
+ const clone = cloneList(list)
6
+ clone.push(x)
5
7
 
6
- if (typeof input === 'string') return input.split('').concat(x)
7
-
8
- const clone = cloneList(input)
9
- clone.push(x)
10
-
11
- return clone
8
+ return clone
9
+ }
12
10
  }
package/src/ascend.js CHANGED
@@ -1,23 +1,16 @@
1
- export function createCompareFunction(
2
- a, b, winner, loser
3
- ){
4
- if (a === b) return 0
1
+ export function createCompareFunction(a, b, winner, loser) {
2
+ if (a === b) {
3
+ return 0
4
+ }
5
5
 
6
6
  return a < b ? winner : loser
7
7
  }
8
8
 
9
- export function ascend(
10
- getFunction, a, b
11
- ){
12
- if (arguments.length === 1){
13
- return (_a, _b) => ascend(
14
- getFunction, _a, _b
15
- )
16
- }
9
+ export function ascend(getFunction) {
10
+ return (a, b) => {
17
11
  const aValue = getFunction(a)
18
12
  const bValue = getFunction(b)
19
13
 
20
- return createCompareFunction(
21
- aValue, bValue, -1, 1
22
- )
14
+ return createCompareFunction(aValue, bValue, -1, 1)
15
+ }
23
16
  }
@@ -0,0 +1,16 @@
1
+ export function checkObjectWithSpec(conditions) {
2
+ return input => {
3
+ let shouldProceed = true
4
+ for (const prop in conditions) {
5
+ if (!shouldProceed) {
6
+ continue
7
+ }
8
+ const result = conditions[prop](input[prop])
9
+ if (shouldProceed && result === false) {
10
+ shouldProceed = false
11
+ }
12
+ }
13
+
14
+ return shouldProceed
15
+ }
16
+ }
package/src/compact.js ADDED
@@ -0,0 +1,12 @@
1
+ import { isArray } from './_internals/isArray.js'
2
+ import { reject } from './reject.js'
3
+ import { rejectObject } from './rejectObject.js'
4
+
5
+ const isNullOrUndefined = x => x === null || x === undefined
6
+
7
+ export function compact(input){
8
+ if(isArray(input)){
9
+ return reject(isNullOrUndefined)(input)
10
+ }
11
+ return rejectObject(isNullOrUndefined)(input)
12
+ }
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/concat.js CHANGED
@@ -1,5 +1,3 @@
1
- export function concat(x, y){
2
- if (arguments.length === 1) return _y => concat(x, _y)
3
-
4
- return typeof x === 'string' ? `${ x }${ y }` : [ ...x, ...y ]
1
+ export function concat(x) {
2
+ return y => (typeof x === 'string' ? `${x}${y}` : [...x, ...y])
5
3
  }
package/src/count.js CHANGED
@@ -1,10 +1,11 @@
1
1
  import { isArray } from './_internals/isArray.js'
2
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
3
+ export function count(predicate) {
4
+ return list => {
5
+ if (!isArray(list)) {
6
+ return 0
7
+ }
8
8
 
9
- return list.filter(x => predicate(x)).length
9
+ return list.filter(x => predicate(x)).length
10
+ }
10
11
  }
package/src/countBy.js CHANGED
@@ -1,17 +1,16 @@
1
- export function countBy(fn, list){
2
- if (arguments.length === 1){
3
- return _list => countBy(fn, _list)
4
- }
5
- const willReturn = {}
1
+ export function countBy(fn) {
2
+ return list => {
3
+ const willReturn = {}
6
4
 
7
- list.forEach(item => {
8
- const key = fn(item)
9
- if (!willReturn[ key ]){
10
- willReturn[ key ] = 1
11
- } else {
12
- willReturn[ key ]++
13
- }
14
- })
5
+ list.forEach(item => {
6
+ const key = fn(item)
7
+ if (!willReturn[key]) {
8
+ willReturn[key] = 1
9
+ } else {
10
+ willReturn[key]++
11
+ }
12
+ })
15
13
 
16
- return willReturn
14
+ return willReturn
15
+ }
17
16
  }
@@ -0,0 +1,10 @@
1
+ export function createObjectFromKeys(keys) {
2
+ return fn => {
3
+ const result = {}
4
+ keys.forEach((key, index) => {
5
+ result[key] = fn(key, index)
6
+ })
7
+
8
+ return result
9
+ }
10
+ }
package/src/defaultTo.js CHANGED
@@ -1,11 +1,9 @@
1
- function isFalsy(input){
2
- return (
3
- input === undefined || input === null || Number.isNaN(input) === true
4
- )
1
+ function isFalsy(input) {
2
+ return input === undefined || input === null || Number.isNaN(input) === true
5
3
  }
6
4
 
7
- export function defaultTo(defaultArgument, input){
8
- if (arguments.length === 1){
5
+ export function defaultTo(defaultArgument, input) {
6
+ if (arguments.length === 1) {
9
7
  return _input => defaultTo(defaultArgument, _input)
10
8
  }
11
9
 
package/src/descend.js CHANGED
@@ -1,17 +1,10 @@
1
1
  import { createCompareFunction } from './ascend.js'
2
2
 
3
- export function descend(
4
- getFunction, a, b
5
- ){
6
- if (arguments.length === 1){
7
- return (_a, _b) => descend(
8
- getFunction, _a, _b
9
- )
10
- }
11
- const aValue = getFunction(a)
12
- const bValue = getFunction(b)
3
+ export function descend(getFunction) {
4
+ return (a, b) => {
5
+ const aValue = getFunction(a)
6
+ const bValue = getFunction(b)
13
7
 
14
- return createCompareFunction(
15
- aValue, bValue, 1, -1
16
- )
8
+ return createCompareFunction(aValue, bValue, 1, -1)
9
+ }
17
10
  }
package/src/drop.js CHANGED
@@ -1,5 +1,7 @@
1
- export function drop(howManyToDrop, listOrString){
2
- if (arguments.length === 1) return _list => drop(howManyToDrop, _list)
1
+ export function drop(howManyToDrop, listOrString) {
2
+ if (arguments.length === 1) {
3
+ return _list => drop(howManyToDrop, _list)
4
+ }
3
5
 
4
6
  return listOrString.slice(howManyToDrop > 0 ? howManyToDrop : 0)
5
7
  }
package/src/dropLast.js CHANGED
@@ -1,9 +1,3 @@
1
- export function dropLast(howManyToDrop, listOrString){
2
- if (arguments.length === 1){
3
- return _listOrString => dropLast(howManyToDrop, _listOrString)
4
- }
5
-
6
- return howManyToDrop > 0 ?
7
- listOrString.slice(0, -howManyToDrop) :
8
- listOrString.slice()
1
+ export function dropLast(numberItems) {
2
+ return list => (numberItems > 0 ? list.slice(0, -numberItems) : list.slice())
9
3
  }
@@ -1,33 +1,24 @@
1
- import { isArray as isArrayMethod } from './_internals/isArray.js'
2
-
3
- export function dropLastWhile(predicate, iterable){
4
- if (arguments.length === 1){
5
- return _iterable => dropLastWhile(predicate, _iterable)
6
- }
7
- if (iterable.length === 0) return iterable
8
- const isArray = isArrayMethod(iterable)
1
+ export function dropLastWhile(predicate) {
2
+ return list => {
3
+ if (list.length === 0) {
4
+ return list
5
+ }
9
6
 
10
- if (typeof predicate !== 'function'){
11
- throw new Error(`'predicate' is from wrong type ${ typeof predicate }`)
12
- }
13
- if (!isArray && typeof iterable !== 'string'){
14
- throw new Error(`'iterable' is from wrong type ${ typeof iterable }`)
15
- }
7
+ const toReturn = []
8
+ let counter = list.length
16
9
 
17
- const toReturn = []
18
- let counter = iterable.length
10
+ while (counter) {
11
+ const item = list[--counter]
12
+ if (!predicate(item, counter)) {
13
+ toReturn.push(item)
14
+ break
15
+ }
16
+ }
19
17
 
20
- while (counter){
21
- const item = iterable[ --counter ]
22
- if (!predicate(item)){
23
- toReturn.push(item)
24
- break
18
+ while (counter) {
19
+ toReturn.push(list[--counter])
25
20
  }
26
- }
27
21
 
28
- while (counter){
29
- toReturn.push(iterable[ --counter ])
22
+ return toReturn.reverse()
30
23
  }
31
-
32
- return isArray ? toReturn.reverse() : toReturn.reverse().join('')
33
24
  }
package/src/dropWhile.js CHANGED
@@ -1,28 +1,20 @@
1
- import { isArray as isArrayMethod } from './_internals/isArray.js'
1
+ export function dropWhile(predicate) {
2
+ return iterable => {
3
+ const toReturn = []
4
+ let counter = 0
2
5
 
3
- export function dropWhile(predicate, iterable){
4
- if (arguments.length === 1){
5
- return _iterable => dropWhile(predicate, _iterable)
6
- }
7
- const isArray = isArrayMethod(iterable)
8
- if (!isArray && typeof iterable !== 'string'){
9
- throw new Error('`iterable` is neither list nor a string')
10
- }
11
-
12
- const toReturn = []
13
- let counter = 0
6
+ while (counter < iterable.length) {
7
+ const item = iterable[counter++]
8
+ if (!predicate(item, counter)) {
9
+ toReturn.push(item)
10
+ break
11
+ }
12
+ }
14
13
 
15
- while (counter < iterable.length){
16
- const item = iterable[ counter++ ]
17
- if (!predicate(item)){
18
- toReturn.push(item)
19
- break
14
+ while (counter < iterable.length) {
15
+ toReturn.push(iterable[counter++])
20
16
  }
21
- }
22
17
 
23
- while (counter < iterable.length){
24
- toReturn.push(iterable[ counter++ ])
18
+ return toReturn
25
19
  }
26
-
27
- return isArray ? toReturn : toReturn.join('')
28
20
  }
package/src/eqBy.js CHANGED
@@ -1,10 +1,5 @@
1
- import { curry } from './curry.js'
2
- import { equals } from './equals.js'
1
+ import { equalsFn } from './equals.js'
3
2
 
4
- export function eqByFn(
5
- fn, a, b
6
- ){
7
- return equals(fn(a), fn(b))
3
+ export function eqBy(fn, a) {
4
+ return b => equalsFn(fn(a), fn(b))
8
5
  }
9
-
10
- export const eqBy = curry(eqByFn)
package/src/eqProps.js CHANGED
@@ -1,11 +1,5 @@
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 eqPropsFn(
6
- property, objA, objB
7
- ){
8
- return equals(prop(property, objA), prop(property, objB))
3
+ export function eqProps(property, objA) {
4
+ return objB => equalsFn( objA[property], objB[property] )
9
5
  }
10
-
11
- export const eqProps = curry(eqPropsFn)
package/src/equals.js CHANGED
@@ -1,56 +1,66 @@
1
1
  import { isArray } from './_internals/isArray.js'
2
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
9
  const typeOfValue = type(valueToFind)
9
- if (![ 'Array', 'NaN', 'Object', 'RegExp' ].includes(typeOfValue))
10
+ if (!['Array', 'NaN', 'Object', 'RegExp'].includes(typeOfValue)) {
10
11
  return list.lastIndexOf(valueToFind)
12
+ }
11
13
 
12
14
  const { length } = list
13
15
  let index = length
14
16
  let foundIndex = -1
15
17
 
16
- while (--index > -1 && foundIndex === -1)
17
- if (equals(list[ index ], valueToFind))
18
+ while (--index > -1 && foundIndex === -1) {
19
+ if (equalsFn(list[index], valueToFind)) {
18
20
  foundIndex = index
21
+ }
22
+ }
19
23
 
20
24
  return foundIndex
21
25
  }
22
26
 
23
- export function _indexOf(valueToFind, list){
24
- if (!isArray(list))
25
- throw new Error(`Cannot read property 'indexOf' of ${ list }`)
27
+ export function _indexOf(valueToFind, list) {
28
+ if (!isArray(list)) {
29
+ throw new Error(`Cannot read property 'indexOf' of ${list}`)
30
+ }
26
31
 
27
32
  const typeOfValue = type(valueToFind)
28
- if (![ 'Array', 'NaN', 'Object', 'RegExp' ].includes(typeOfValue))
33
+ if (!['Array', 'NaN', 'Object', 'RegExp'].includes(typeOfValue)) {
29
34
  return list.indexOf(valueToFind)
35
+ }
30
36
 
31
37
  let index = -1
32
38
  let foundIndex = -1
33
39
  const { length } = list
34
40
 
35
- while (++index < length && foundIndex === -1)
36
- if (equals(list[ index ], valueToFind))
41
+ while (++index < length && foundIndex === -1) {
42
+ if (equalsFn(list[index], valueToFind)) {
37
43
  foundIndex = index
44
+ }
45
+ }
38
46
 
39
47
  return foundIndex
40
48
  }
41
49
 
42
- function _arrayFromIterator(iter){
50
+ function _arrayFromIterator(iter) {
43
51
  const list = []
44
52
  let next
45
- while (!(next = iter.next()).done)
53
+ while (!(next = iter.next()).done) {
46
54
  list.push(next.value)
55
+ }
47
56
 
48
57
  return list
49
58
  }
50
59
 
51
- function _compareSets(a, b){
52
- if (a.size !== b.size)
60
+ function _compareSets(a, b) {
61
+ if (a.size !== b.size) {
53
62
  return false
63
+ }
54
64
 
55
65
  const aList = _arrayFromIterator(a.values())
56
66
  const bList = _arrayFromIterator(b.values())
@@ -60,63 +70,81 @@ function _compareSets(a, b){
60
70
  return filtered.length === 0
61
71
  }
62
72
 
63
- function compareErrors(a, b){
64
- if (a.message !== b.message) return false
65
- if (a.toString !== b.toString) return false
73
+ function compareErrors(a, b) {
74
+ if (a.message !== b.message) {
75
+ return false
76
+ }
77
+ if (a.toString !== b.toString) {
78
+ return false
79
+ }
66
80
 
67
81
  return a.toString() === b.toString()
68
82
  }
69
83
 
70
- function parseDate(maybeDate){
71
- if (!maybeDate.toDateString) return [ false ]
84
+ function parseDate(maybeDate) {
85
+ if (!maybeDate.toDateString) {
86
+ return [false]
87
+ }
72
88
 
73
- return [ true, maybeDate.getTime() ]
89
+ return [true, maybeDate.getTime()]
74
90
  }
75
91
 
76
- function parseRegex(maybeRegex){
77
- if (maybeRegex.constructor !== RegExp) return [ false ]
92
+ function parseRegex(maybeRegex) {
93
+ if (maybeRegex.constructor !== RegExp) {
94
+ return [false]
95
+ }
78
96
 
79
- return [ true, maybeRegex.toString() ]
97
+ return [true, maybeRegex.toString()]
80
98
  }
81
99
 
82
- export function equals(a, b){
83
- if (arguments.length === 1) return _b => equals(a, _b)
84
-
85
- if (Object.is(a, b)) return true
100
+ export function equalsFn(a, b) {
101
+ if (Object.is(a, b)) {
102
+ return true
103
+ }
86
104
 
87
105
  const aType = type(a)
88
106
 
89
- if (aType !== type(b)) return false
90
- if (aType === 'Function')
107
+ if (aType !== type(b)) {
108
+ return false
109
+ }
110
+ if (aType === 'Function') {
91
111
  return a.name === undefined ? false : a.name === b.name
112
+ }
92
113
 
93
- if ([ 'NaN', 'Null', 'Undefined' ].includes(aType)) return true
114
+ if (['NaN', 'Null', 'Undefined'].includes(aType)) {
115
+ return true
116
+ }
94
117
 
95
- if ([ 'BigInt', 'Number' ].includes(aType)){
96
- if (Object.is(-0, a) !== Object.is(-0, b)) return false
118
+ if (['BigInt', 'Number'].includes(aType)) {
119
+ if (Object.is(-0, a) !== Object.is(-0, b)) {
120
+ return false
121
+ }
97
122
 
98
123
  return a.toString() === b.toString()
99
124
  }
100
125
 
101
- if ([ 'Boolean', 'String' ].includes(aType))
126
+ if (['Boolean', 'String'].includes(aType)) {
102
127
  return a.toString() === b.toString()
128
+ }
103
129
 
104
- if (aType === 'Array'){
130
+ if (aType === 'Array') {
105
131
  const aClone = Array.from(a)
106
132
  const bClone = Array.from(b)
107
133
 
108
- if (aClone.toString() !== bClone.toString())
134
+ if (aClone.toString() !== bClone.toString()) {
109
135
  return false
136
+ }
110
137
 
111
138
  let loopArrayFlag = true
112
139
  aClone.forEach((aCloneInstance, aCloneIndex) => {
113
- if (loopArrayFlag)
140
+ if (loopArrayFlag) {
114
141
  if (
115
- aCloneInstance !== bClone[ aCloneIndex ] &&
116
- !equals(aCloneInstance, bClone[ aCloneIndex ])
117
- )
142
+ aCloneInstance !== bClone[aCloneIndex] &&
143
+ !equalsFn(aCloneInstance, bClone[aCloneIndex])
144
+ ) {
118
145
  loopArrayFlag = false
119
-
146
+ }
147
+ }
120
148
  })
121
149
 
122
150
  return loopArrayFlag
@@ -125,41 +153,51 @@ export function equals(a, b){
125
153
  const aRegex = parseRegex(a)
126
154
  const bRegex = parseRegex(b)
127
155
 
128
- if (aRegex[ 0 ])
129
- return bRegex[ 0 ] ? aRegex[ 1 ] === bRegex[ 1 ] : false
130
- else if (bRegex[ 0 ]) return false
156
+ if (aRegex[0]) {
157
+ return bRegex[0] ? aRegex[1] === bRegex[1] : false
158
+ }
159
+ if (bRegex[0]) {
160
+ return false
161
+ }
131
162
 
132
163
  const aDate = parseDate(a)
133
164
  const bDate = parseDate(b)
134
165
 
135
- if (aDate[ 0 ])
136
- return bDate[ 0 ] ? aDate[ 1 ] === bDate[ 1 ] : false
137
- else if (bDate[ 0 ]) return false
166
+ if (aDate[0]) {
167
+ return bDate[0] ? aDate[1] === bDate[1] : false
168
+ }
169
+ if (bDate[0]) {
170
+ return false
171
+ }
138
172
 
139
- if (a instanceof Error){
140
- if (!(b instanceof Error)) return false
173
+ if (a instanceof Error) {
174
+ if (!(b instanceof Error)) {
175
+ return false
176
+ }
141
177
 
142
178
  return compareErrors(a, b)
143
179
  }
144
180
 
145
- if (aType === 'Set')
181
+ if (aType === 'Set') {
146
182
  return _compareSets(a, b)
183
+ }
147
184
 
148
- if (aType === 'Object'){
185
+ if (aType === 'Object') {
149
186
  const aKeys = Object.keys(a)
150
187
 
151
- if (aKeys.length !== Object.keys(b).length)
188
+ if (aKeys.length !== Object.keys(b).length) {
152
189
  return false
190
+ }
153
191
 
154
192
  let loopObjectFlag = true
155
193
  aKeys.forEach(aKeyInstance => {
156
- if (loopObjectFlag){
157
- const aValue = a[ aKeyInstance ]
158
- const bValue = b[ aKeyInstance ]
194
+ if (loopObjectFlag) {
195
+ const aValue = a[aKeyInstance]
196
+ const bValue = b[aKeyInstance]
159
197
 
160
- if (aValue !== bValue && !equals(aValue, bValue))
198
+ if (aValue !== bValue && !equalsFn(aValue, bValue)) {
161
199
  loopObjectFlag = false
162
-
200
+ }
163
201
  }
164
202
  })
165
203
 
@@ -168,3 +206,6 @@ export function equals(a, b){
168
206
 
169
207
  return false
170
208
  }
209
+ export function equals(a) {
210
+ return b => equalsFn(a, b)
211
+ }