From 17d25dd1e38b866d3cbd650b9c4d4b41c967506e Mon Sep 17 00:00:00 2001 From: Mr Martian Date: Sat, 11 Jan 2025 21:21:32 -0500 Subject: [PATCH] bad typesafety for using writer in browser --- bun.lockb | Bin 85258 -> 88013 bytes package.json | 8 ++++---- src/index.ts | 7 ++++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/bun.lockb b/bun.lockb index 5091b6d50d2c3d88670f699b19fa919cb3124964..3bbd07a830fb70b3eba47503e4afe3abdb0a878b 100755 GIT binary patch delta 7523 zcmeHMcT`l@x4!4X02djhNE1<1Bp@=B0R{zzVucX`HdHJ@85L~EC~6WZDk@lUiz6zE zF&cYAqa?OyG@=q?Z_%ij1WSy@n4dn|?>ke1@2$M`-oJ0HH*0-&pKtGd_u1#1eP_-+ zQ@TP{w?npA;rG*+RxQ-mGY)HiIQHmPL+sw7GjASWUA{Tx)b>YRujYK05S_*Z{`t8q zt+jaW?yjjjE#fM{Z3UrlHl!=$q-i3n6*lI|Bqkf=onC zJd$VUF@7lGxjq%bUc^vJC5dqn{;p0Cv>3Q4WF-kirCqt(bj)zeTE1!bTBaHn&hUEEd zhvW+}bT<0^ZsPTj-2V(D_rGG|Il8gPMi7pI^KtDr$#GfZv;mpJg&p8L zzYN{9@gv4$SxnlXq@z}9Tdm12T}igqtr9QB7;pDNC?38~tg$=Hr6KHPa301B{C#_i zIHMkF!@P&bSLa%PX<@UbePKucV(sv1-zJ63tEO+^Cp+vnzR>j=)9<4$Gm71<(!4!< z^Om~E26`rY&aAE8Xy@Hpib8xD;#ku;SAQyOW+Qo_Ui(99K@RpRwvwcdF=D7UC3aLx zQ&8Z@xv(jvI;*79V3^24ku#Y^dqGfBQmaTQ4y_QQzPU=K1B;@h=8ttXKPAb_Bu-@EDbnvB9 zfofR-9+hNDvX5kkC?P0DwDqIXAT{elwLvk`Q9nT#iF+BPHdl$h9Vjta%`&MZI7Zsk zK@d;?Jby=(^Z+d0;8^CMk~;be0;-(fhDjJiB_T1gR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OWZ?YS#H&~v1P};+BNu;v3P&+6Lp>c z`@%cpjI*G;+RpZ3sJzRjJ#LR;x(}z7X=%s4ezxuaN|t1@@P>6CQ@?y?(wSxc-#p2) z#+ec@?Sl+$s6S>kXJ}>q@D-4yo%I(%-XHSI5q>+pwIBRNrYE;GbAZTnY{$azt-fOZ z=nRV7QnF89s9!dmHGRJ(`0o39|KWn25niXh{NbG5f8$#Is#e>?U01+;F#g8Hkq3uQ zTsieNxF7hI@M^=Nm;tkJ1kWe$(&>J-cm6tP%#n_GHQ@f^D|Y{MbojHqwswbt1GrJT zpwREdA)odE=Ntc)DPt-o4$A6$jo;t!D;c^kuY-t*+;`Y2zVY2xHAoyW8WT;Wlje?} aQ5?&+ajmMS=&a3sUW5wEzMAKSRsI`1#vow; diff --git a/package.json b/package.json index a3f1343..9c577a2 100755 --- a/package.json +++ b/package.json @@ -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": [ @@ -56,10 +56,10 @@ "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", @@ -67,7 +67,7 @@ "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" } } diff --git a/src/index.ts b/src/index.ts index 96af8b6..98f9e75 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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); @@ -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); }