Skip to content

Commit 03ab706

Browse files
authored
fix: write string into output buffer as uint8array (#118)
We cannot call `.write` on `buf` as it is a `Uint8Array` not a node buffer
1 parent 1d6e843 commit 03ab706

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/protons-runtime/src/utils/writer.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { allocUnsafe } from 'uint8arrays/alloc'
2+
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
23
import { writeFloatLE, writeDoubleLE } from './float.js'
34
import { LongBits } from './longbits.js'
45
import pool from './pool.js'
@@ -424,8 +425,7 @@ function writeStringBuffer (val: string, buf: Uint8Array, pos: number): void {
424425
// @ts-expect-error buf isn't a Uint8Array?
425426
buf.utf8Write(val, pos)
426427
} else {
427-
// @ts-expect-error .write is a function on node Buffers
428-
buf.write(val, pos)
428+
buf.set(uint8ArrayFromString(val), pos)
429429
}
430430
}
431431

0 commit comments

Comments
 (0)