Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(assert): remove unnecessary getValFromKeyedCollection() #5921

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions assert/equal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@
// This module is browser compatible.

type KeyedCollection = Set<unknown> | Map<unknown, unknown>;

function isKeyedCollection(x: unknown): x is KeyedCollection {
return x instanceof Set || x instanceof Map;
}

function getValFromKeyedCollection(kc: KeyedCollection, key: unknown) {
return kc instanceof Map ? kc.get(key) : key;
}

function constructorsEqual(a: object, b: object) {
return a.constructor === b.constructor ||
a.constructor === Object && !b.constructor ||
Expand Down Expand Up @@ -106,10 +101,7 @@ export function equal(c: unknown, d: unknown): boolean {
for (const key of aKeys) {
if (
!b.has(key) ||
!compare(
getValFromKeyedCollection(a, key),
getValFromKeyedCollection(b, key),
)
!compare(a.get(key), (b as Map<unknown, unknown>).get(key))
) {
return false;
}
Expand Down