Skip to content

Commit

Permalink
fix: write string into output buffer as uint8array (#118)
Browse files Browse the repository at this point in the history
We cannot call `.write` on `buf` as it is a `Uint8Array` not a node buffer
  • Loading branch information
achingbrain authored Oct 13, 2023
1 parent 1d6e843 commit 03ab706
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/protons-runtime/src/utils/writer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { allocUnsafe } from 'uint8arrays/alloc'
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
import { writeFloatLE, writeDoubleLE } from './float.js'
import { LongBits } from './longbits.js'
import pool from './pool.js'
Expand Down Expand Up @@ -424,8 +425,7 @@ function writeStringBuffer (val: string, buf: Uint8Array, pos: number): void {
// @ts-expect-error buf isn't a Uint8Array?
buf.utf8Write(val, pos)
} else {
// @ts-expect-error .write is a function on node Buffers
buf.write(val, pos)
buf.set(uint8ArrayFromString(val), pos)
}
}

Expand Down

0 comments on commit 03ab706

Please sign in to comment.