rm logging
This commit is contained in:
parent
d89fcfb76f
commit
ec035e9a5d
|
@ -21,6 +21,7 @@ export const Lang = {
|
||||||
ELIXIR: 0,
|
ELIXIR: 0,
|
||||||
ERLANG: 1,
|
ERLANG: 1,
|
||||||
};
|
};
|
||||||
|
const log = (msg) => process.stderr.write(`${msg}\r\n`);
|
||||||
export class Bert {
|
export class Bert {
|
||||||
allBinariesAsString;
|
allBinariesAsString;
|
||||||
mapKeyAsAtom;
|
mapKeyAsAtom;
|
||||||
|
@ -40,7 +41,7 @@ export class Bert {
|
||||||
#encode = (obj, buffer) => this[`encode_${typeof obj}`](obj, buffer);
|
#encode = (obj, buffer) => this[`encode_${typeof obj}`](obj, buffer);
|
||||||
encode = (obj, copy = true) => {
|
encode = (obj, copy = true) => {
|
||||||
const tailBuffer = this.#encode(obj, this.outputBuffer.subarray(1));
|
const tailBuffer = this.#encode(obj, this.outputBuffer.subarray(1));
|
||||||
process.stderr.write(`tailbuffer length: ${tailBuffer.length}\n`);
|
log(`tailbuffer length: ${tailBuffer.length}`);
|
||||||
if (tailBuffer.length === 0) {
|
if (tailBuffer.length === 0) {
|
||||||
throw new Error("Bert encode a too big term, encoding buffer overflow");
|
throw new Error("Bert encode a too big term, encoding buffer overflow");
|
||||||
}
|
}
|
||||||
|
@ -103,7 +104,6 @@ export class Bert {
|
||||||
};
|
};
|
||||||
encode_string = (obj, buffer) => {
|
encode_string = (obj, buffer) => {
|
||||||
if (this.convention === Lang.ELIXIR) {
|
if (this.convention === Lang.ELIXIR) {
|
||||||
process.stderr.write(`encode string as elixir\n`);
|
|
||||||
return this.encode_binary(Buffer.from(obj), buffer);
|
return this.encode_binary(Buffer.from(obj), buffer);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -201,7 +201,6 @@ export class Bert {
|
||||||
return buffer.subarray(0, 3 + len);
|
return buffer.subarray(0, 3 + len);
|
||||||
};
|
};
|
||||||
encode_binary = (obj, buffer) => {
|
encode_binary = (obj, buffer) => {
|
||||||
process.stderr.write(`encode binary\n`);
|
|
||||||
buffer[0] = Types.BINARY;
|
buffer[0] = Types.BINARY;
|
||||||
buffer.writeUInt32BE(obj.length, 1);
|
buffer.writeUInt32BE(obj.length, 1);
|
||||||
const len = obj.copy(buffer, 5);
|
const len = obj.copy(buffer, 5);
|
||||||
|
|
|
@ -23,6 +23,8 @@ export const Lang = {
|
||||||
ERLANG: 1,
|
ERLANG: 1,
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
const log = (msg: string) => process.stderr.write(`${msg}\r\n`);
|
||||||
|
|
||||||
export class Bert {
|
export class Bert {
|
||||||
private allBinariesAsString;
|
private allBinariesAsString;
|
||||||
private mapKeyAsAtom;
|
private mapKeyAsAtom;
|
||||||
|
@ -52,7 +54,7 @@ export class Bert {
|
||||||
|
|
||||||
encode = (obj: any, copy = true) => {
|
encode = (obj: any, copy = true) => {
|
||||||
const tailBuffer = this.#encode(obj, this.outputBuffer.subarray(1));
|
const tailBuffer = this.#encode(obj, this.outputBuffer.subarray(1));
|
||||||
process.stderr.write(`tailbuffer length: ${tailBuffer.length}\n`);
|
log(`tailbuffer length: ${tailBuffer.length}`);
|
||||||
|
|
||||||
if (tailBuffer.length === 0) {
|
if (tailBuffer.length === 0) {
|
||||||
throw new Error("Bert encode a too big term, encoding buffer overflow");
|
throw new Error("Bert encode a too big term, encoding buffer overflow");
|
||||||
|
@ -126,7 +128,6 @@ export class Bert {
|
||||||
|
|
||||||
encode_string = (obj: string, buffer: Buffer) => {
|
encode_string = (obj: string, buffer: Buffer) => {
|
||||||
if (this.convention === Lang.ELIXIR) {
|
if (this.convention === Lang.ELIXIR) {
|
||||||
process.stderr.write(`encode string as elixir\n`);
|
|
||||||
return this.encode_binary(Buffer.from(obj), buffer);
|
return this.encode_binary(Buffer.from(obj), buffer);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -237,7 +238,6 @@ export class Bert {
|
||||||
};
|
};
|
||||||
|
|
||||||
encode_binary = (obj: Buffer, buffer: Buffer) => {
|
encode_binary = (obj: Buffer, buffer: Buffer) => {
|
||||||
process.stderr.write(`encode binary\n`);
|
|
||||||
buffer[0] = Types.BINARY;
|
buffer[0] = Types.BINARY;
|
||||||
buffer.writeUInt32BE(obj.length, 1);
|
buffer.writeUInt32BE(obj.length, 1);
|
||||||
const len = obj.copy(buffer, 5);
|
const len = obj.copy(buffer, 5);
|
||||||
|
|
Loading…
Reference in New Issue