Move RiffWriter into separate file

This commit is contained in:
Vanilagy
2025-01-07 22:20:33 +01:00
parent 9d51a896ae
commit e1c070fe7b
2 changed files with 46 additions and 49 deletions
+22
View File
@@ -0,0 +1,22 @@
import { Writer } from '../writer';
export class RiffWriter {
private helper = new Uint8Array(8);
private helperView = new DataView(this.helper.buffer);
constructor(private writer: Writer) {}
writeU32(value: number) {
this.helperView.setUint32(0, value, true);
this.writer.write(this.helper.subarray(0, 4));
}
writeU16(value: number) {
this.helperView.setUint16(0, value, true);
this.writer.write(this.helper.subarray(0, 2));
}
writeAscii(text: string) {
this.writer.write(new TextEncoder().encode(text));
}
}