Skip to content

Commit

Permalink
perf: remove polyfill of isArray (#1626)
Browse files Browse the repository at this point in the history
  • Loading branch information
hchlq committed May 15, 2022
1 parent b7944c1 commit 71e6dcb
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 12 deletions.
5 changes: 0 additions & 5 deletions packages/hooks/src/utils/__test__/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ describe('shared utils methods', () => {
expect(isArray([])).toBe(true);
expect(isArray({})).toBe(false);
expect(isArray(1)).toBe(false);

(Array as any).isArray = null;
expect(isArray([])).toBe(true);
expect(isArray({})).toBe(false);
expect(isArray(1)).toBe(false);
});

test('isBoolean', () => {
Expand Down
8 changes: 1 addition & 7 deletions packages/hooks/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
export const isArray = (value: unknown): value is any[] => {
if (Array.isArray) {
return Array.isArray(value);
}

return toString.call(value) === '[object Array]';
};
export const isArray = Array.isArray;
export const isObject = (value: unknown): value is Record<any, any> =>
value !== null && typeof value === 'object';
export const isFunction = (value: unknown): value is Function => typeof value === 'function';
Expand Down

0 comments on commit 71e6dcb

Please sign in to comment.