-
Notifications
You must be signed in to change notification settings - Fork 1
/
dev_deps.js
41 lines (38 loc) · 1019 Bytes
/
dev_deps.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import {
ok as assert,
deepEqual as assertEquals,
notDeepEqual as assertNotEquals,
rejects as assertRejects,
} from "node:assert/strict";
export { assert, assertEquals, assertNotEquals, assertRejects };
/**
* Asserts a header
* @param {Headers} headers
* @param {string} name
* @param {string} [value]
*/
export function assertHeader(headers, name, value) {
if (value !== undefined) {
assertEquals(
headers.get(name),
value,
`should have ${name} header of ${value} instead of ${headers.get(name)}`,
);
} else {
assert(headers.get(name), `should have ${name} header`);
}
}
/**
* Checks if two byte arrays are equal
* @param {Uint8Array} a
* @param {Uint8Array} b
* @returns {boolean}
*/
export function equalBytes(a, b) {
// Should not happen
if (a.length !== b.length) return false;
let isSame = true;
for (let i = 0; i < a.length; i++) isSame &&= a[i] === b[i]; // Lets hope JIT won't optimize away.
return isSame;
}
export * as fc from "fast-check";