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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { assertThrows, unitTest } from "./test_util.ts";
unitTest(function streamReadableHwmError() {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const invalidHwm: any[] = [NaN, Number("NaN"), {}, -1, "two"];
for (const highWaterMark of invalidHwm) {
assertThrows(
() => {
new ReadableStream<number>(undefined, { highWaterMark });
},
RangeError,
"highWaterMark must be a positive number or Infinity. Received:",
);
}
assertThrows(() => {
new ReadableStream<number>(
undefined,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
{ highWaterMark: Symbol("hwk") as any },
);
}, TypeError);
});
unitTest(function streamWriteableHwmError() {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const invalidHwm: any[] = [NaN, Number("NaN"), {}, -1, "two"];
for (const highWaterMark of invalidHwm) {
assertThrows(
() => {
new WritableStream(
undefined,
new CountQueuingStrategy({ highWaterMark }),
);
},
RangeError,
"highWaterMark must be a positive number or Infinity. Received:",
);
}
assertThrows(() => {
new WritableStream(
undefined,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
new CountQueuingStrategy({ highWaterMark: Symbol("hwmk") as any }),
);
}, TypeError);
});
unitTest(function streamTransformHwmError() {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const invalidHwm: any[] = [NaN, Number("NaN"), {}, -1, "two"];
for (const highWaterMark of invalidHwm) {
assertThrows(
() => {
new TransformStream(undefined, undefined, { highWaterMark });
},
RangeError,
"highWaterMark must be a positive number or Infinity. Received:",
);
}
assertThrows(() => {
new TransformStream(
undefined,
undefined,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
{ highWaterMark: Symbol("hwmk") as any },
);
}, TypeError);
});
|