1.7.1
This commit is contained in:
parent
e91d10f694
commit
296e84b4cf
4 changed files with 11 additions and 7 deletions
|
@ -32,6 +32,7 @@ export class WriterBase {
|
||||||
|
|
||||||
public writeBuffer(buffer:Buffer) {
|
public writeBuffer(buffer:Buffer) {
|
||||||
this.buffer = getBufferClass().concat([this.buffer, buffer], this.buffer.length + buffer.length);
|
this.buffer = getBufferClass().concat([this.buffer, buffer], this.buffer.length + buffer.length);
|
||||||
|
this.offset += buffer.length;
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
4
package-lock.json
generated
4
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "bufferstuff",
|
"name": "bufferstuff",
|
||||||
"version": "1.7.0",
|
"version": "1.7.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "bufferstuff",
|
"name": "bufferstuff",
|
||||||
"version": "1.7.0",
|
"version": "1.7.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"check-outdated": "^2.12.0",
|
"check-outdated": "^2.12.0",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "bufferstuff",
|
"name": "bufferstuff",
|
||||||
"version": "1.7.0",
|
"version": "1.7.1",
|
||||||
"description": "A set of utility classes for reading and writing binary data in NodeJS and the browser",
|
"description": "A set of utility classes for reading and writing binary data in NodeJS and the browser",
|
||||||
"main": "./lib/index.js",
|
"main": "./lib/index.js",
|
||||||
"types": "./lib/index.d.ts",
|
"types": "./lib/index.d.ts",
|
||||||
|
|
|
@ -174,18 +174,21 @@ export class WriterBE extends WriterBase implements IWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
public writeJavaUTF(text: string) {
|
public writeJavaUTF(text: string) {
|
||||||
this.writeUShort(text.length);
|
const dataWriter = new WriterBE();
|
||||||
|
|
||||||
for (let i = 0; i < text.length; i++) {
|
for (let i = 0; i < text.length; i++) {
|
||||||
const val = text.charCodeAt(i);
|
const val = text.charCodeAt(i);
|
||||||
if (val === 0) {
|
if (val === 0) {
|
||||||
this.writeByte(0xC0);
|
dataWriter.writeByte(0xC0);
|
||||||
this.writeByte(0X80);
|
dataWriter.writeByte(0X80);
|
||||||
} else {
|
} else {
|
||||||
this.writeByte(val);
|
dataWriter.writeByte(val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.writeUShort(text.length);
|
||||||
|
this.writeBuffer(dataWriter.toBuffer());
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue