Skip to content

Commit

Permalink
feat(utils): [equal] support circular references
Browse files Browse the repository at this point in the history
Signed-off-by: Lexus Drumgold <[email protected]>
  • Loading branch information
unicornware committed Aug 10, 2023
1 parent ac17bfd commit 81cb20e
Show file tree
Hide file tree
Showing 8 changed files with 846 additions and 56 deletions.
1 change: 1 addition & 0 deletions .dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ gpgsign
hmarr
iife
infile
isequal
jsonifiable
keyid
ksort
Expand Down
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ updates:
- conventional-changelog-core
- conventional-changelog-writer
- conventional-recommended-bump
lodash:
patterns:
- '@types/lodash.*'
- lodash.*
typescript-eslint:
patterns:
- '@typescript-eslint/*'
Expand Down
17 changes: 10 additions & 7 deletions __fixtures__/vehicle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ import type Vehicle from './types/vehicle'
*/
export const VEHICLE_TAG: symbol = Symbol('vehicle')

export default {
[VEHICLE_TAG]: 'vehicle',
make: faker.vehicle.manufacturer(),
model: faker.vehicle.model(),
vin: '0WBW1G4D29TC62167',
year: faker.date.past({ years: 3 }).getFullYear()
} as Opaque<Vehicle, 'vehicle'>
export default Object.defineProperty(
{
make: faker.vehicle.manufacturer(),
model: faker.vehicle.model(),
vin: '0WBW1G4D29TC62167',
year: faker.date.past({ years: 3 }).getFullYear()
},
VEHICLE_TAG,
{ configurable: true, value: 'vehicle' }
) as Opaque<Vehicle, 'vehicle'>
4 changes: 2 additions & 2 deletions __tests__/setup/matchers/descriptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import type { PropertyDescriptor } from '#src/interfaces'
import type { Optional } from '#src/types'
import type { MatcherState, SyncExpectationResult } from '@vitest/expect'
import { dequal } from 'dequal'
import isEqual from 'lodash.isequal'

/**
* Asserts `target` has its own property descriptor for the given `key`.
Expand Down Expand Up @@ -62,7 +62,7 @@ function descriptor<T = any>(
actual ? `${this.isNot ? 'not ' : ''}deeply equal ${expected}` : ''
].join(' ')
},
pass: dequal(actual, descriptor)
pass: isEqual(actual, descriptor)
}
}

Expand Down
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
"description": "TypeScript-friendly utilities",
"version": "6.0.0-alpha.18",
"keywords": [
"clone",
"deep",
"deep-clone",
"deep-equal",
"definitions",
"enums",
"equal",
"get",
"interfaces",
"partial",
Expand Down Expand Up @@ -81,9 +85,6 @@
"typecheck": "vitest typecheck --run",
"typecheck:watch": "vitest typecheck"
},
"dependencies": {
"dequal": "2.0.3"
},
"devDependencies": {
"@arethetypeswrong/cli": "0.7.1",
"@commitlint/cli": "17.7.0",
Expand All @@ -109,6 +110,7 @@
"@types/fs-extra": "11.0.1",
"@types/git-raw-commits": "2.0.1",
"@types/is-ci": "3.0.0",
"@types/lodash.isequal": "4.5.6",
"@types/node-notifier": "8.0.2",
"@types/prettier": "2.7.3",
"@types/semver": "7.5.0",
Expand Down Expand Up @@ -152,6 +154,7 @@
"is-ci": "3.0.1",
"jsonc-eslint-parser": "2.3.0",
"lint-staged": "13.2.3",
"lodash.isequal": "4.5.0",
"mri": "1.2.0",
"node-notifier": "10.0.1",
"pkg-size": "2.4.0",
Expand Down
Loading

0 comments on commit 81cb20e

Please sign in to comment.