Skip to content

Commit 0772b41

Browse files
committed
refactor(test): Move isSameArray test into JSDoc
1 parent 12efbd4 commit 0772b41

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

websocket/isSameArray.test.ts

Lines changed: 0 additions & 10 deletions
This file was deleted.

websocket/isSameArray.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,21 @@
1+
/**
2+
* Compare two arrays to see if they are the same.
3+
*
4+
* This function only checks each element's reference, not the content.
5+
*
6+
* ```ts
7+
* import { assert } from "@std/assert/assert";
8+
*
9+
* assert(isSameArray([1, 2, 3], [1, 2, 3]));
10+
* assert(isSameArray([1, 2, 3], [3, 2, 1]));
11+
* assert(!isSameArray([1, 2, 3], [3, 2, 3]));
12+
* assert(!isSameArray([1, 2, 3], [1, 2]));
13+
* assert(isSameArray([], []));
14+
* ```
15+
*
16+
* @param a
17+
* @param b
18+
* @returns
19+
*/
120
export const isSameArray = <T>(a: T[], b: T[]): boolean =>
221
a.length === b.length && a.every((x) => b.includes(x));

0 commit comments

Comments
 (0)