Skip to content

Commit

Permalink
bad typesafety for using writer in browser
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr Martian committed Jan 12, 2025
1 parent 1252694 commit 17d25dd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
Binary file modified bun.lockb
Binary file not shown.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pbf-ts",
"version": "1.0.2",
"version": "1.0.3",
"description": "A low-level, fast, ultra-lightweight typescript library for decoding and encoding protocol buffers.",
"type": "module",
"keywords": [
Expand Down Expand Up @@ -56,18 +56,18 @@
"homepage": "https://github.com/Open-S2/s2-tools#readme",
"devDependencies": {
"@skypack/package-check": "^0.2.2",
"@types/bun": "^1.1.15",
"@types/bun": "^1.1.16",
"@types/node": "^22.10.5",
"coveralls": "^3.1.1",
"eslint": "^9.17.0",
"eslint": "^9.18.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jsdoc": "^50.6.1",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-tsdoc": "^0.4.0",
"prettier": "^3.4.2",
"typedoc": "^0.27.6",
"typedoc-plugin-coverage": "^3.4.1",
"typescript": "^5.7.2",
"typescript": "^5.7.3",
"typescript-eslint": "^8.19.1"
}
}
7 changes: 4 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -632,10 +632,11 @@ export class Pbf {

/**
* Write a byte array
* @param buf - a Buffer to write. Will write the length of the buffer first.
* @param inBuf - a Buffer to write. Will write the length of the buffer first.
* After that, the buffer will be written byte by byte.
*/
writeBytes(buf: Buffer): void {
writeBytes(inBuf: Buffer | Uint8Array | ArrayBuffer): void {
const buf = ArrayBuffer.isView(inBuf) ? inBuf : new Uint8Array(inBuf);
const len = buf.length;
this.writeVarint(len);
this.realloc(len);
Expand Down Expand Up @@ -767,7 +768,7 @@ export class Pbf {
* @param tag - the tag to write to associate with the value.
* @param buffer - the buffer of bytes to write.
*/
writeBytesField(tag: number, buffer: Buffer): void {
writeBytesField(tag: number, buffer: Buffer | Uint8Array | ArrayBuffer): void {
this.writeTag(tag, Pbf.Bytes);
this.writeBytes(buffer);
}
Expand Down

0 comments on commit 17d25dd

Please sign in to comment.