Skip to content

Commit 81cb20e

Browse files
committed
feat(utils): [equal] support circular references
Signed-off-by: Lexus Drumgold <[email protected]>
1 parent ac17bfd commit 81cb20e

File tree

8 files changed

+846
-56
lines changed

8 files changed

+846
-56
lines changed

.dictionary.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ gpgsign
2121
hmarr
2222
iife
2323
infile
24+
isequal
2425
jsonifiable
2526
keyid
2627
ksort

.github/dependabot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ updates:
4343
- conventional-changelog-core
4444
- conventional-changelog-writer
4545
- conventional-recommended-bump
46+
lodash:
47+
patterns:
48+
- '@types/lodash.*'
49+
- lodash.*
4650
typescript-eslint:
4751
patterns:
4852
- '@typescript-eslint/*'

__fixtures__/vehicle.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@ import type Vehicle from './types/vehicle'
1313
*/
1414
export const VEHICLE_TAG: symbol = Symbol('vehicle')
1515

16-
export default {
17-
[VEHICLE_TAG]: 'vehicle',
18-
make: faker.vehicle.manufacturer(),
19-
model: faker.vehicle.model(),
20-
vin: '0WBW1G4D29TC62167',
21-
year: faker.date.past({ years: 3 }).getFullYear()
22-
} as Opaque<Vehicle, 'vehicle'>
16+
export default Object.defineProperty(
17+
{
18+
make: faker.vehicle.manufacturer(),
19+
model: faker.vehicle.model(),
20+
vin: '0WBW1G4D29TC62167',
21+
year: faker.date.past({ years: 3 }).getFullYear()
22+
},
23+
VEHICLE_TAG,
24+
{ configurable: true, value: 'vehicle' }
25+
) as Opaque<Vehicle, 'vehicle'>

__tests__/setup/matchers/descriptor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import type { PropertyDescriptor } from '#src/interfaces'
77
import type { Optional } from '#src/types'
88
import type { MatcherState, SyncExpectationResult } from '@vitest/expect'
9-
import { dequal } from 'dequal'
9+
import isEqual from 'lodash.isequal'
1010

1111
/**
1212
* Asserts `target` has its own property descriptor for the given `key`.
@@ -62,7 +62,7 @@ function descriptor<T = any>(
6262
actual ? `${this.isNot ? 'not ' : ''}deeply equal ${expected}` : ''
6363
].join(' ')
6464
},
65-
pass: dequal(actual, descriptor)
65+
pass: isEqual(actual, descriptor)
6666
}
6767
}
6868

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33
"description": "TypeScript-friendly utilities",
44
"version": "6.0.0-alpha.18",
55
"keywords": [
6+
"clone",
67
"deep",
8+
"deep-clone",
9+
"deep-equal",
710
"definitions",
811
"enums",
12+
"equal",
913
"get",
1014
"interfaces",
1115
"partial",
@@ -81,9 +85,6 @@
8185
"typecheck": "vitest typecheck --run",
8286
"typecheck:watch": "vitest typecheck"
8387
},
84-
"dependencies": {
85-
"dequal": "2.0.3"
86-
},
8788
"devDependencies": {
8889
"@arethetypeswrong/cli": "0.7.1",
8990
"@commitlint/cli": "17.7.0",
@@ -109,6 +110,7 @@
109110
"@types/fs-extra": "11.0.1",
110111
"@types/git-raw-commits": "2.0.1",
111112
"@types/is-ci": "3.0.0",
113+
"@types/lodash.isequal": "4.5.6",
112114
"@types/node-notifier": "8.0.2",
113115
"@types/prettier": "2.7.3",
114116
"@types/semver": "7.5.0",
@@ -152,6 +154,7 @@
152154
"is-ci": "3.0.1",
153155
"jsonc-eslint-parser": "2.3.0",
154156
"lint-staged": "13.2.3",
157+
"lodash.isequal": "4.5.0",
155158
"mri": "1.2.0",
156159
"node-notifier": "10.0.1",
157160
"pkg-size": "2.4.0",

0 commit comments

Comments
 (0)