feat: make consumable writable streams also accept raw values

This commit is contained in:
Simon Chan 2024-04-16 14:01:30 +08:00
parent d60ac95f47
commit d06b5f2ed6
No known key found for this signature in database
GPG key ID: A8B69F750B9BCEDD
31 changed files with 387 additions and 346 deletions

View file

@ -3,15 +3,12 @@ import {
PromiseResolver,
delay,
} from "@yume-chan/async";
import type {
Consumable,
ReadableWritablePair,
WritableStreamDefaultWriter,
} from "@yume-chan/stream-extra";
import {
AbortController,
ConsumableWritableStream,
Consumable,
WritableStream,
type ReadableWritablePair,
type WritableStreamDefaultWriter,
} from "@yume-chan/stream-extra";
import { EMPTY_UINT8_ARRAY, NumberFieldType } from "@yume-chan/struct";
@ -231,7 +228,10 @@ export class AdbPacketDispatcher implements Closeable {
let payload: Uint8Array;
if (this.options.initialDelayedAckBytes !== 0) {
payload = new Uint8Array(4);
new DataView(payload.buffer).setUint32(0, ackBytes, true);
payload[0] = ackBytes & 0xff;
payload[1] = (ackBytes >> 8) & 0xff;
payload[2] = (ackBytes >> 16) & 0xff;
payload[3] = (ackBytes >> 24) & 0xff;
} else {
payload = EMPTY_UINT8_ARRAY;
}
@ -374,7 +374,7 @@ export class AdbPacketDispatcher implements Closeable {
throw new Error("payload too large");
}
await ConsumableWritableStream.write(this.#writer, {
await Consumable.WritableStream.write(this.#writer, {
command,
arg0,
arg1,