rambda 8.3.0 → 8.5.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.
package/package.json CHANGED
@@ -1,108 +1,109 @@
1
1
  {
2
- "name": "rambda",
3
- "version": "8.3.0",
4
- "scripts": {
5
- "benchmark": "cd ../rambda-scripts && RAMBDA_RUN_ALL=ON RAMBDA_RUN_INDEXES=ON yarn benchmark",
6
- "benchmark:all": "yarn build:step && cd ../rambda-scripts && yarn benchmark:all",
7
- "benchmark:check": "yarn build:step && METHOD=compose yarn benchmark:check:apply",
8
- "benchmark:check:apply": "cd ../rambda-scripts && yarn check-benchmark",
9
- "build": "yarn build:main && yarn build:web",
10
- "build:main": "cross-env NODE_ENV=build rollup -c files/rollup.config.mjs",
11
- "build:step": "yarn populatereadme && yarn build:main",
12
- "build:web": "cross-env NODE_ENV=build rollup -c files/rollup.web.config.mjs",
13
- "d": "yarn out && yarn lint && run d",
14
- "docs": "npx docsify-cli init ./docs && yarn fix-docsify",
15
- "fix-docsify": "cd ../rambda-scripts && yarn fix-docsify:rambda",
16
- "git:add": "git add -A",
17
- "github": "cd ../rambda-scripts && yarn github",
18
- "immutable": "cd ../rambda-scripts && yarn immutable:rambda",
19
- "immutable:x": "cd ../rambda-scripts && yarn immutable:rambdax",
20
- "lint": "yarn git:add && yarn lint:staged && yarn git:add",
21
- "lint:all": "cd ../rambda-scripts && yarn lint",
22
- "lint:staged": "cd ../rambda-scripts && yarn lint:staged",
23
- "new": "cd ../rambda-scripts && yarn new",
24
- "out": "yarn populatedocs && yarn populatereadme && yarn immutable && yarn build",
25
- "populatedocs": "cd ../rambda-scripts && yarn populate:docs",
26
- "populatedocs:x": "cd ../rambda-scripts && yarn populate:docs:rambdax",
27
- "populatereadme": "cd ../rambda-scripts && yarn populate:readme",
28
- "populatereadme:x": "cd ../rambda-scripts && yarn populate:readme:rambdax",
29
- "publish:experimental": "node files/publish",
30
- "run:ramda:test": "cd ../rambda-scripts && yarn run:ramda:test",
31
- "test": "jest -o -u --watch",
32
- "test:all": "jest source/*.spec.js -u --bail=false",
33
- "test:ci": "jest source/*.spec.js --coverage --no-cache -w 1",
34
- "test:typings": "dtslint --localTs ./node_modules/typescript/lib --expectOnly ./source",
35
- "usedby": "cd ../rambda-scripts && yarn usedby",
36
- "x": "yarn populatedocs:x && yarn populatereadme:x && yarn immutable:x"
37
- },
38
- "dependencies": {},
39
- "devDependencies": {
40
- "@babel/core": "7.21.8",
41
- "@babel/plugin-proposal-object-rest-spread": "7.20.7",
42
- "@babel/preset-env": "7.21.5",
43
- "@rollup/plugin-babel": "6.0.3",
44
- "@rollup/plugin-commonjs": "25.0.0",
45
- "@rollup/plugin-node-resolve": "15.0.2",
46
- "@rollup/plugin-replace": "5.0.2",
47
- "@types/jest": "29.5.1",
48
- "combinate": "1.1.11",
49
- "cross-env": "7.0.3",
50
- "dtslint": "4.2.1",
51
- "fast-check": "^3.11.0",
52
- "helpers-fn": "1.8.1",
53
- "is-ci": "3.0.1",
54
- "jest": "29.5.0",
55
- "jest-extended": "3.2.4",
56
- "lodash": "4.17.21",
57
- "rambdax": "9.1.1",
58
- "ramda": "0.29.0",
59
- "rollup": "3.22.0",
60
- "rollup-plugin-cleanup": "3.2.1",
61
- "rollup-plugin-sourcemaps": "0.6.3",
62
- "rollup-plugin-uglify": "6.0.4",
63
- "types-ramda": "0.29.2",
64
- "typescript": "5.0.4"
65
- },
66
- "jest": {
67
- "testEnvironment": "node",
68
- "testRegex": ".*\\.(spec|test)\\.js$",
69
- "setupFilesAfterEnv": [
70
- "./files/testSetup.js"
71
- ],
72
- "collectCoverageFrom": [
73
- "source/*.js",
74
- "!_internals",
75
- "!benchmarks"
76
- ]
77
- },
78
- "repository": {
79
- "type": "git",
80
- "url": "git+https://github.com/selfrefactor/rambda.git"
81
- },
82
- "license": "MIT",
83
- "author": "self_refactor",
84
- "description": "Lightweight and faster alternative to Ramda with included TS definitions",
85
- "keywords": [
86
- "ramda",
87
- "fp",
88
- "functional",
89
- "utility",
90
- "lodash"
91
- ],
92
- "homepage": "https://github.com/selfrefactor/rambda#readme",
93
- "files": [
94
- "dist",
95
- "src",
96
- "README.md",
97
- "CHANGELOG.md",
98
- "index.d.ts",
99
- "immutable.d.ts",
100
- "rambda.js",
101
- "immutable.js"
102
- ],
103
- "sideEffects": false,
104
- "main": "./dist/rambda.js",
105
- "umd": "./dist/rambda.umd.js",
106
- "module": "./rambda.js",
107
- "types": "./index.d.ts"
2
+ "name": "rambda",
3
+ "version": "8.5.0",
4
+ "scripts": {
5
+ "benchmark": "cd ../rambda-scripts && RAMBDA_RUN_ALL=ON RAMBDA_RUN_INDEXES=ON yarn benchmark",
6
+ "benchmark:all": "yarn build:step && cd ../rambda-scripts && yarn benchmark:all",
7
+ "benchmark:check": "yarn build:step && METHOD=compose yarn benchmark:check:apply",
8
+ "benchmark:check:apply": "cd ../rambda-scripts && yarn check-benchmark",
9
+ "build": "yarn build:main && yarn build:web",
10
+ "build:main": "cross-env NODE_ENV=build rollup -c files/rollup.config.mjs",
11
+ "build:step": "yarn populatereadme && yarn build:main",
12
+ "build:web": "cross-env NODE_ENV=build rollup -c files/rollup.web.config.mjs",
13
+ "d": "yarn out && yarn lint && run d",
14
+ "docs": "npx docsify-cli init ./docs && yarn fix-docsify",
15
+ "fix-docsify": "cd ../rambda-scripts && yarn fix-docsify:rambda",
16
+ "git:add": "git add -A",
17
+ "github": "cd ../rambda-scripts && yarn github",
18
+ "immutable": "cd ../rambda-scripts && yarn immutable:rambda",
19
+ "immutable:x": "cd ../rambda-scripts && yarn immutable:rambdax",
20
+ "lint": "yarn git:add && yarn lint:staged && yarn git:add",
21
+ "lint:all": "cd ../rambda-scripts && yarn lint",
22
+ "lint:staged": "cd ../rambda-scripts && yarn lint:staged",
23
+ "new": "cd ../rambda-scripts && yarn new",
24
+ "out": "yarn populatedocs && yarn populatereadme && yarn immutable && yarn build",
25
+ "before": "yarn out && yarn docs",
26
+ "populatedocs": "cd ../rambda-scripts && yarn populate:docs",
27
+ "populatedocs:x": "cd ../rambda-scripts && yarn populate:docs:rambdax",
28
+ "populatereadme": "cd ../rambda-scripts && yarn populate:readme",
29
+ "populatereadme:x": "cd ../rambda-scripts && yarn populate:readme:rambdax",
30
+ "run:ramda:test": "cd ../rambda-scripts && yarn run:ramda:test",
31
+ "test": "jest -o -u --watch",
32
+ "test:all": "jest source/*.spec.js -u --bail=false",
33
+ "test:ci": "jest source/*.spec.js --coverage --no-cache -w 1",
34
+ "test:typings": "dtslint --localTs ./node_modules/typescript/lib --expectOnly ./source",
35
+ "ts": "yarn test:typings",
36
+ "usedby": "cd ../rambda-scripts && yarn usedby",
37
+ "x": "yarn populatedocs:x && yarn populatereadme:x && yarn immutable:x"
38
+ },
39
+ "dependencies": {},
40
+ "devDependencies": {
41
+ "@babel/core": "7.21.8",
42
+ "@babel/plugin-proposal-object-rest-spread": "7.20.7",
43
+ "@babel/preset-env": "7.21.5",
44
+ "@definitelytyped/dtslint": "0.0.176",
45
+ "@rollup/plugin-babel": "6.0.3",
46
+ "@rollup/plugin-commonjs": "25.0.0",
47
+ "@rollup/plugin-node-resolve": "15.0.2",
48
+ "@rollup/plugin-replace": "5.0.2",
49
+ "@types/jest": "29.5.1",
50
+ "combinate": "1.1.11",
51
+ "cross-env": "7.0.3",
52
+ "fast-check": "^3.11.0",
53
+ "helpers-fn": "1.8.1",
54
+ "is-ci": "3.0.1",
55
+ "jest": "29.5.0",
56
+ "jest-extended": "3.2.4",
57
+ "lodash": "4.17.21",
58
+ "rambdax": "9.1.1",
59
+ "ramda": "0.29.0",
60
+ "rollup": "3.22.0",
61
+ "rollup-plugin-cleanup": "3.2.1",
62
+ "rollup-plugin-sourcemaps": "0.6.3",
63
+ "rollup-plugin-uglify": "6.0.4",
64
+ "types-ramda": "0.29.2",
65
+ "typescript": "5.2.2"
66
+ },
67
+ "jest": {
68
+ "testEnvironment": "node",
69
+ "testRegex": ".*\\.(spec|test)\\.js$",
70
+ "setupFilesAfterEnv": [
71
+ "./files/testSetup.js"
72
+ ],
73
+ "collectCoverageFrom": [
74
+ "source/*.js",
75
+ "!_internals",
76
+ "!benchmarks"
77
+ ]
78
+ },
79
+ "repository": {
80
+ "type": "git",
81
+ "url": "git+https://github.com/selfrefactor/rambda.git"
82
+ },
83
+ "license": "MIT",
84
+ "author": "self_refactor",
85
+ "description": "Lightweight and faster alternative to Ramda with included TS definitions",
86
+ "keywords": [
87
+ "ramda",
88
+ "fp",
89
+ "functional",
90
+ "utility",
91
+ "lodash"
92
+ ],
93
+ "homepage": "https://github.com/selfrefactor/rambda#readme",
94
+ "files": [
95
+ "dist",
96
+ "src",
97
+ "README.md",
98
+ "CHANGELOG.md",
99
+ "index.d.ts",
100
+ "immutable.d.ts",
101
+ "rambda.js",
102
+ "immutable.js"
103
+ ],
104
+ "sideEffects": false,
105
+ "main": "./dist/rambda.js",
106
+ "umd": "./dist/rambda.umd.js",
107
+ "module": "./rambda.js",
108
+ "types": "./index.d.ts"
108
109
  }
package/rambda.js CHANGED
@@ -45,15 +45,19 @@ export * from './src/descend.js'
45
45
  export * from './src/difference.js'
46
46
  export * from './src/differenceWith.js'
47
47
  export * from './src/dissoc.js'
48
+ export * from './src/dissocPath.js'
48
49
  export * from './src/divide.js'
49
50
  export * from './src/drop.js'
50
51
  export * from './src/dropLast.js'
51
52
  export * from './src/dropLastWhile.js'
52
53
  export * from './src/dropRepeats.js'
54
+ export * from './src/dropRepeatsBy.js'
53
55
  export * from './src/dropRepeatsWith.js'
54
56
  export * from './src/dropWhile.js'
55
57
  export * from './src/either.js'
58
+ export * from './src/empty.js'
56
59
  export * from './src/endsWith.js'
60
+ export * from './src/eqBy.js'
57
61
  export * from './src/eqProps.js'
58
62
  export * from './src/equals.js'
59
63
  export * from './src/evolve.js'
@@ -147,6 +151,7 @@ export * from './src/props.js'
147
151
  export * from './src/range.js'
148
152
  export * from './src/reduce.js'
149
153
  export * from './src/reject.js'
154
+ export * from './src/removeIndex.js'
150
155
  export * from './src/repeat.js'
151
156
  export * from './src/replace.js'
152
157
  export * from './src/reverse.js'
@@ -0,0 +1,3 @@
1
+ export function compare(a, b){
2
+ return String(a) === String(b)
3
+ }
@@ -1,3 +1,7 @@
1
+ import { isInteger } from './isInteger.js'
2
+
1
3
  export function createPath(path, delimiter = '.'){
2
- return typeof path === 'string' ? path.split(delimiter) : path
4
+ return typeof path === 'string' ?
5
+ path.split(delimiter).map(x => isInteger(x) ? Number(x) : x) :
6
+ path
3
7
  }
@@ -0,0 +1,7 @@
1
+ import { isInteger } from './isInteger.js'
2
+
3
+ export function createPathInput(path){
4
+ return typeof path === 'string' ?
5
+ path.split('.').map(x => isInteger(Number(x)) ? Number(x) : x) :
6
+ path
7
+ }
@@ -0,0 +1,12 @@
1
+ import { compare } from './compare.js'
2
+
3
+ export function includes(a, list){
4
+ let index = -1
5
+ const { length } = list
6
+
7
+ while (++index < length)
8
+ if (compare(list[ index ], a))
9
+ return true
10
+
11
+ return false
12
+ }
@@ -3,3 +3,8 @@ function _isInteger(n){
3
3
  }
4
4
 
5
5
  export const isInteger = Number.isInteger || _isInteger
6
+
7
+ /**
8
+ * Check if `index` is integer even if it is a string.
9
+ */
10
+ export const isIndexInteger = index => Number.isInteger(Number(index))
package/src/assoc.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { curry } from './curry.js'
2
2
 
3
- function assocFn(
3
+ export function assocFn(
4
4
  prop, newValue, obj
5
5
  ){
6
6
  return Object.assign(
package/src/assocPath.js CHANGED
@@ -1,19 +1,15 @@
1
1
  import { cloneList } from './_internals/cloneList.js'
2
+ import { createPath } from './_internals/createPath.js'
2
3
  import { isArray } from './_internals/isArray.js'
3
- import { isInteger } from './_internals/isInteger.js'
4
- import { assoc } from './assoc.js'
4
+ import { isIndexInteger } from './_internals/isInteger.js'
5
+ import { assocFn } from './assoc.js'
5
6
  import { curry } from './curry.js'
6
7
 
7
- function assocPathFn(
8
+ export function assocPathFn(
8
9
  path, newValue, input
9
10
  ){
10
- const pathArrValue =
11
- typeof path === 'string' ?
12
- path.split('.').map(x => isInteger(Number(x)) ? Number(x) : x) :
13
- path
14
- if (pathArrValue.length === 0){
15
- return newValue
16
- }
11
+ const pathArrValue = createPath(path)
12
+ if (pathArrValue.length === 0) return newValue
17
13
 
18
14
  const index = pathArrValue[ 0 ]
19
15
  if (pathArrValue.length > 1){
@@ -23,7 +19,7 @@ function assocPathFn(
23
19
  !input.hasOwnProperty(index)
24
20
 
25
21
  const nextInput = condition ?
26
- isInteger(pathArrValue[ 1 ]) ?
22
+ isIndexInteger(pathArrValue[ 1 ]) ?
27
23
  [] :
28
24
  {} :
29
25
  input[ index ]
@@ -35,14 +31,14 @@ function assocPathFn(
35
31
  )
36
32
  }
37
33
 
38
- if (isInteger(index) && isArray(input)){
34
+ if (isIndexInteger(index) && isArray(input)){
39
35
  const arr = cloneList(input)
40
36
  arr[ index ] = newValue
41
37
 
42
38
  return arr
43
39
  }
44
40
 
45
- return assoc(
41
+ return assocFn(
46
42
  index, newValue, input
47
43
  )
48
44
  }
@@ -0,0 +1,47 @@
1
+ import { createPath } from '../src/_internals/createPath.js'
2
+ import { isArray } from './_internals/isArray.js'
3
+ import { isIndexInteger } from './_internals/isInteger.js'
4
+ import { omit } from './omit.js'
5
+ import { path } from './path.js'
6
+ import { removeIndex } from './removeIndex.js'
7
+ import { update } from './update.js'
8
+
9
+ export function dissocPath(pathInput, input){
10
+ if (arguments.length === 1) return _obj => dissocPath(pathInput, _obj)
11
+
12
+ const pathArrValue = createPath(pathInput)
13
+ // this {...input} spread could be done to satisfy ramda specs, but this is done on so many places
14
+ // TODO: add warning that Rambda simply returns input if path is empty
15
+ if (pathArrValue.length === 0) return input
16
+
17
+ const pathResult = path(pathArrValue, input)
18
+ if (pathResult === undefined) return input
19
+
20
+ const index = pathArrValue[ 0 ]
21
+ const condition =
22
+ typeof input !== 'object' ||
23
+ input === null ||
24
+ !input.hasOwnProperty(index)
25
+ if (pathArrValue.length > 1){
26
+ const nextInput = condition ?
27
+ isIndexInteger(pathArrValue[ 1 ]) ?
28
+ [] :
29
+ {} :
30
+ input[ index ]
31
+ const nextPathInput = Array.prototype.slice.call(pathArrValue, 1)
32
+ const intermediateResult = dissocPath(
33
+ nextPathInput, nextInput, input
34
+ )
35
+ if (isArray(input)) return update(
36
+ index, intermediateResult, input
37
+ )
38
+
39
+ return {
40
+ ...input,
41
+ [ index ] : intermediateResult,
42
+ }
43
+ }
44
+ if (isArray(input)) return removeIndex(index, input)
45
+
46
+ return omit([ index ], input)
47
+ }
@@ -0,0 +1,21 @@
1
+ import { equals } from './equals.js'
2
+
3
+ export function dropRepeatsBy(fn, list){
4
+ if (arguments.length === 1) return _list => dropRepeatsBy(fn, _list)
5
+
6
+ let lastEvaluated = null
7
+
8
+ return list.slice().filter(item => {
9
+ if (lastEvaluated === null){
10
+ lastEvaluated = fn(item)
11
+
12
+ return true
13
+ }
14
+ const evaluatedResult = fn(item)
15
+ if (equals(lastEvaluated, evaluatedResult)) return false
16
+
17
+ lastEvaluated = evaluatedResult
18
+
19
+ return true
20
+ })
21
+ }
package/src/empty.js ADDED
@@ -0,0 +1,15 @@
1
+ import { type } from './type.js'
2
+
3
+ export function empty(list){
4
+ if (typeof list === 'string') return ''
5
+
6
+ if (Array.isArray(list)){
7
+ const { name } = list.constructor
8
+ if (name === 'Uint8Array') return Uint8Array.from('')
9
+
10
+ if (name === 'Float32Array') return new Float32Array([])
11
+
12
+ return []
13
+ }
14
+ if (type(list) === 'Object') return {}
15
+ }
package/src/eqBy.js ADDED
@@ -0,0 +1,10 @@
1
+ import { curry } from './curry.js'
2
+ import { equals } from './equals.js'
3
+
4
+ export function eqByFn(
5
+ fn, a, b
6
+ ){
7
+ return equals(fn(a), fn(b))
8
+ }
9
+
10
+ export const eqBy = curry(eqByFn)
package/src/equals.js CHANGED
@@ -2,43 +2,39 @@ import { isArray } from './_internals/isArray.js'
2
2
  import { type } from './type.js'
3
3
 
4
4
  export function _lastIndexOf(valueToFind, list){
5
- if (!isArray(list)){
5
+ if (!isArray(list))
6
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 (![ 'Array', 'NaN', 'Object', 'RegExp' ].includes(typeOfValue))
10
10
  return list.lastIndexOf(valueToFind)
11
11
 
12
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
- }
20
- }
21
19
 
22
20
  return foundIndex
23
21
  }
24
22
 
25
23
  export function _indexOf(valueToFind, list){
26
- if (!isArray(list)){
24
+ if (!isArray(list))
27
25
  throw new Error(`Cannot read property 'indexOf' of ${ list }`)
28
- }
26
+
29
27
  const typeOfValue = type(valueToFind)
30
- if (![ 'Object', 'Array', 'NaN', 'RegExp' ].includes(typeOfValue))
28
+ if (![ 'Array', 'NaN', 'Object', 'RegExp' ].includes(typeOfValue))
31
29
  return list.indexOf(valueToFind)
32
30
 
33
31
  let index = -1
34
32
  let foundIndex = -1
35
33
  const { length } = list
36
34
 
37
- while (++index < length && foundIndex === -1){
38
- if (equals(list[ index ], valueToFind)){
35
+ while (++index < length && foundIndex === -1)
36
+ if (equals(list[ index ], valueToFind))
39
37
  foundIndex = index
40
- }
41
- }
42
38
 
43
39
  return foundIndex
44
40
  }
@@ -46,17 +42,16 @@ export function _indexOf(valueToFind, list){
46
42
  function _arrayFromIterator(iter){
47
43
  const list = []
48
44
  let next
49
- while (!(next = iter.next()).done){
45
+ while (!(next = iter.next()).done)
50
46
  list.push(next.value)
51
- }
52
47
 
53
48
  return list
54
49
  }
55
50
 
56
- function _equalsSets(a, b){
57
- if (a.size !== b.size){
51
+ function _compareSets(a, b){
52
+ if (a.size !== b.size)
58
53
  return false
59
- }
54
+
60
55
  const aList = _arrayFromIterator(a.values())
61
56
  const bList = _arrayFromIterator(b.values())
62
57
 
@@ -65,11 +60,11 @@ function _equalsSets(a, b){
65
60
  return filtered.length === 0
66
61
  }
67
62
 
68
- function parseError(maybeError){
69
- const typeofError = maybeError.__proto__.toString()
70
- if (![ 'Error', 'TypeError' ].includes(typeofError)) return []
63
+ function compareErrors(a, b){
64
+ if (a.message !== b.message) return false
65
+ if (a.toString !== b.toString) return false
71
66
 
72
- return [ typeofError, maybeError.message ]
67
+ return a.toString() === b.toString()
73
68
  }
74
69
 
75
70
  function parseDate(maybeDate){
@@ -90,40 +85,36 @@ export function equals(a, b){
90
85
  const aType = type(a)
91
86
 
92
87
  if (aType !== type(b)) return false
93
- if (aType === 'Function'){
88
+ if (aType === 'Function')
94
89
  return a.name === undefined ? false : a.name === b.name
95
- }
96
90
 
97
- if ([ 'NaN', 'Undefined', 'Null' ].includes(aType)) return true
91
+ if ([ 'NaN', 'Null', 'Undefined' ].includes(aType)) return true
98
92
 
99
- if (aType === 'Number'){
93
+ if ([ 'BigInt', 'Number' ].includes(aType)){
100
94
  if (Object.is(-0, a) !== Object.is(-0, b)) return false
101
95
 
102
96
  return a.toString() === b.toString()
103
97
  }
104
98
 
105
- if ([ 'String', 'Boolean' ].includes(aType)){
99
+ if ([ 'Boolean', 'String' ].includes(aType))
106
100
  return a.toString() === b.toString()
107
- }
108
101
 
109
102
  if (aType === 'Array'){
110
103
  const aClone = Array.from(a)
111
104
  const bClone = Array.from(b)
112
105
 
113
- if (aClone.toString() !== bClone.toString()){
106
+ if (aClone.toString() !== bClone.toString())
114
107
  return false
115
- }
116
108
 
117
109
  let loopArrayFlag = true
118
110
  aClone.forEach((aCloneInstance, aCloneIndex) => {
119
- if (loopArrayFlag){
111
+ if (loopArrayFlag)
120
112
  if (
121
113
  aCloneInstance !== bClone[ aCloneIndex ] &&
122
114
  !equals(aCloneInstance, bClone[ aCloneIndex ])
123
- ){
115
+ )
124
116
  loopArrayFlag = false
125
- }
126
- }
117
+
127
118
  })
128
119
 
129
120
  return loopArrayFlag
@@ -132,34 +123,31 @@ export function equals(a, b){
132
123
  const aRegex = parseRegex(a)
133
124
  const bRegex = parseRegex(b)
134
125
 
135
- if (aRegex[ 0 ]){
126
+ if (aRegex[ 0 ])
136
127
  return bRegex[ 0 ] ? aRegex[ 1 ] === bRegex[ 1 ] : false
137
- } else if (bRegex[ 0 ]) return false
128
+ else if (bRegex[ 0 ]) return false
138
129
 
139
130
  const aDate = parseDate(a)
140
131
  const bDate = parseDate(b)
141
132
 
142
- if (aDate[ 0 ]){
133
+ if (aDate[ 0 ])
143
134
  return bDate[ 0 ] ? aDate[ 1 ] === bDate[ 1 ] : false
144
- } else if (bDate[ 0 ]) return false
135
+ else if (bDate[ 0 ]) return false
145
136
 
146
- const aError = parseError(a)
147
- const bError = parseError(b)
137
+ if (a instanceof Error){
138
+ if (!(b instanceof Error)) return false
148
139
 
149
- if (aError[ 0 ]){
150
- return bError[ 0 ] ?
151
- aError[ 0 ] === bError[ 0 ] && aError[ 1 ] === bError[ 1 ] :
152
- false
153
- }
154
- if (aType === 'Set'){
155
- return _equalsSets(a, b)
140
+ return compareErrors(a, b)
156
141
  }
142
+
143
+ if (aType === 'Set')
144
+ return _compareSets(a, b)
145
+
157
146
  if (aType === 'Object'){
158
147
  const aKeys = Object.keys(a)
159
148
 
160
- if (aKeys.length !== Object.keys(b).length){
149
+ if (aKeys.length !== Object.keys(b).length)
161
150
  return false
162
- }
163
151
 
164
152
  let loopObjectFlag = true
165
153
  aKeys.forEach(aKeyInstance => {
@@ -167,9 +155,9 @@ export function equals(a, b){
167
155
  const aValue = a[ aKeyInstance ]
168
156
  const bValue = b[ aKeyInstance ]
169
157
 
170
- if (aValue !== bValue && !equals(aValue, bValue)){
158
+ if (aValue !== bValue && !equals(aValue, bValue))
171
159
  loopObjectFlag = false
172
- }
160
+
173
161
  }
174
162
  })
175
163