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

fix(isEqual): isEqual should compare AbortController #892

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions src/compat/_internal/tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ export const int32ArrayTag = '[object Int32Array]';
export const bigInt64ArrayTag = '[object BigInt64Array]';
export const float32ArrayTag = '[object Float32Array]';
export const float64ArrayTag = '[object Float64Array]';
export const abortSignalTag = '[object AbortSignal]';
14 changes: 14 additions & 0 deletions src/predicate/isEqual.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,18 @@ describe('isEqual', () => {

expect(isEqual(buffer3, buffer4)).toBe(false);
});

it('should compare AbortSignal objects', () => {
const controller1 = new AbortController();
const controller2 = new AbortController();

const signal1 = controller1.signal;
const signal2 = controller2.signal;

expect(isEqual(signal1, signal2)).toBe(true);

controller1.abort();

expect(isEqual(signal1, signal2)).toBe(false);
});
});
5 changes: 5 additions & 0 deletions src/predicate/isEqualWith.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { isPlainObject } from './isPlainObject.ts';
import { getSymbols } from '../compat/_internal/getSymbols.ts';
import { getTag } from '../compat/_internal/getTag.ts';
import {
abortSignalTag,
argumentsTag,
arrayBufferTag,
arrayTag,
Expand Down Expand Up @@ -188,6 +189,10 @@ function areObjectsEqual(
case functionTag: {
return a === b;
}

case abortSignalTag: {
return a.aborted === b.aborted;
}
}

stack = stack ?? new Map();
Expand Down
Loading