Skip to content

Commit b00f82a

Browse files
committed
add writeString that is needed for raknet
1 parent ccae2a2 commit b00f82a

File tree

1 file changed

+9
-21
lines changed

1 file changed

+9
-21
lines changed

src/BinaryStream.js

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -449,27 +449,6 @@ class BinaryStream {
449449
return this;
450450
}
451451

452-
/*readString(returnBuffer = false){
453-
let buffer = this.read(this.readUnsignedVarInt());
454-
return returnBuffer === true ? buffer : buffer.toString();
455-
}
456-
457-
/**
458-
* @param v {string}
459-
* @return {BinaryStream}
460-
*
461-
writeString(v){
462-
this.writeUnsignedVarInt(v.length);
463-
464-
if(v.length === 0) return this;
465-
466-
let buf = Buffer.alloc(v.length);
467-
buf.write(v);
468-
469-
this.append(buf);
470-
return this;
471-
}*/
472-
473452
/**
474453
* @return {number}
475454
*/
@@ -627,6 +606,15 @@ class BinaryStream {
627606
return this;
628607
}
629608

609+
/**
610+
* @param v {string}
611+
* @return {BinaryStream}
612+
*/
613+
writeString(v){
614+
this.append(Buffer.from(v));
615+
return this;
616+
}
617+
630618
flip(){
631619
this.offset = 0;
632620
return this;

0 commit comments

Comments
 (0)