deno.land / std@0.224.0 / io / _test_common.ts

_test_common.ts
View Documentation
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
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import type { Reader } from "./types.ts";
export const MIN_READ_BUFFER_SIZE = 16;export const bufsizes: number[] = [ 0, MIN_READ_BUFFER_SIZE, 23, 32, 46, 64, 93, 128, 1024, 4096,];
export class BinaryReader implements Reader { index = 0;
constructor(private bytes: Uint8Array = new Uint8Array(0)) {}
read(p: Uint8Array): Promise<number | null> { p.set(this.bytes.subarray(this.index, p.byteLength)); this.index += p.byteLength; return Promise.resolve(p.byteLength); }}
// N controls how many iterations of certain checks are performed.const N = 100;
export function init(): Uint8Array { const testBytes = new Uint8Array(N); for (let i = 0; i < N; i++) { testBytes[i] = "a".charCodeAt(0) + (i % 26); } return testBytes;}
std

Version Info

Tagged at
6 months ago