found some more cases of direct Buffer usages
This commit is contained in:
parent
242b3f512b
commit
24f26db2c1
1 changed files with 9 additions and 8 deletions
|
@ -3,11 +3,12 @@
|
|||
|
||||
import { IWriter } from "./IWriter";
|
||||
import { WriterBase } from "../base/WriterBase";
|
||||
import { getBufferClass } from "../base/BufferShim";
|
||||
|
||||
export class WriterBE extends WriterBase implements IWriter {
|
||||
public writeShort(value:number) {
|
||||
if (this.resizable) {
|
||||
const buffer = Buffer.alloc(2);
|
||||
const buffer = getBufferClass().alloc(2);
|
||||
buffer.writeInt16BE(value);
|
||||
this.writeBuffer(buffer);
|
||||
} else {
|
||||
|
@ -20,7 +21,7 @@ export class WriterBE extends WriterBase implements IWriter {
|
|||
|
||||
public writeUShort(value:number) {
|
||||
if (this.resizable) {
|
||||
const buffer = Buffer.alloc(2);
|
||||
const buffer = getBufferClass().alloc(2);
|
||||
buffer.writeUInt16BE(value);
|
||||
this.writeBuffer(buffer);
|
||||
} else {
|
||||
|
@ -33,7 +34,7 @@ export class WriterBE extends WriterBase implements IWriter {
|
|||
|
||||
public writeInt(value:number) {
|
||||
if (this.resizable) {
|
||||
const buffer = Buffer.alloc(4);
|
||||
const buffer = getBufferClass().alloc(4);
|
||||
buffer.writeInt32BE(value);
|
||||
this.writeBuffer(buffer);
|
||||
} else {
|
||||
|
@ -46,7 +47,7 @@ export class WriterBE extends WriterBase implements IWriter {
|
|||
|
||||
public writeUInt(value:number) {
|
||||
if (this.resizable) {
|
||||
const buffer = Buffer.alloc(4);
|
||||
const buffer = getBufferClass().alloc(4);
|
||||
buffer.writeUInt32BE(value);
|
||||
this.writeBuffer(buffer);
|
||||
} else {
|
||||
|
@ -63,7 +64,7 @@ export class WriterBE extends WriterBase implements IWriter {
|
|||
}
|
||||
|
||||
if (this.resizable) {
|
||||
const buffer = Buffer.alloc(8);
|
||||
const buffer = getBufferClass().alloc(8);
|
||||
buffer.writeBigInt64BE(value);
|
||||
this.writeBuffer(buffer);
|
||||
} else {
|
||||
|
@ -80,7 +81,7 @@ export class WriterBE extends WriterBase implements IWriter {
|
|||
}
|
||||
|
||||
if (this.resizable) {
|
||||
const buffer = Buffer.alloc(8);
|
||||
const buffer = getBufferClass().alloc(8);
|
||||
buffer.writeBigUint64BE(value);
|
||||
this.writeBuffer(buffer);
|
||||
} else {
|
||||
|
@ -93,7 +94,7 @@ export class WriterBE extends WriterBase implements IWriter {
|
|||
|
||||
public writeFloat(value:number) {
|
||||
if (this.resizable) {
|
||||
const buffer = Buffer.alloc(4);
|
||||
const buffer = getBufferClass().alloc(4);
|
||||
buffer.writeFloatBE(value);
|
||||
this.writeBuffer(buffer);
|
||||
} else {
|
||||
|
@ -106,7 +107,7 @@ export class WriterBE extends WriterBase implements IWriter {
|
|||
|
||||
public writeDouble(value:number) {
|
||||
if (this.resizable) {
|
||||
const buffer = Buffer.alloc(8);
|
||||
const buffer = getBufferClass().alloc(8);
|
||||
buffer.writeDoubleBE(value);
|
||||
this.writeBuffer(buffer);
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue