Skip to content

Commit 1b4633a

Browse files
committed
fix pr comments
1 parent 2a0533b commit 1b4633a

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/core/tests/utils.test.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
matchMutation,
77
scheduleMicrotask,
88
sleep,
9+
isPlainArray,
910
} from '../utils'
1011
import { Mutation } from '../mutation'
1112
import { createQueryClient } from '../../tests/utils'
@@ -56,6 +57,16 @@ describe('core/utils', () => {
5657
})
5758
})
5859

60+
describe('isPlainArray', () => {
61+
it('should return `true` for plain arrays', () => {
62+
expect(isPlainArray([1, 2])).toEqual(true)
63+
})
64+
65+
it('should return `false` for non plain arrays', () => {
66+
expect(isPlainArray(Object.assign([1, 2], { a: 'b' }))).toEqual(false)
67+
})
68+
})
69+
5970
describe('partialDeepEqual', () => {
6071
it('should return `true` if a includes b', () => {
6172
const a = { a: { b: 'b' }, c: 'c', d: [{ d: 'd ' }] }

src/core/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,8 @@ export function shallowEqualObjects<T>(a: T, b: T): boolean {
355355
return true
356356
}
357357

358-
export function isPlainArray(a: any) {
359-
return Array.isArray(a) && a.length === Object.keys(a).length
358+
export function isPlainArray(value: unknown) {
359+
return Array.isArray(value) && value.length === Object.keys(value).length
360360
}
361361

362362
// Copied from: https://github.com/jonschlinkert/is-plain-object

0 commit comments

Comments
 (0)