Skip to content

feat(nodejs): protocol version option, binary protocol for doubles #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: sender_transport
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
441 changes: 441 additions & 0 deletions src/buffer/base.ts

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions src/buffer/bufferv1.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// @ts-check
import { SenderOptions } from "../options";
import { SenderBuffer } from "./index";
import { SenderBufferBase } from "./base";

class SenderBufferV1 extends SenderBufferBase {
constructor(options: SenderOptions) {
super(options);
}

floatColumn(name: string, value: number): SenderBuffer {
this.writeColumn(
name,
value,
() => {
const valueStr = value.toString();
this.checkCapacity([valueStr]);
this.write(valueStr);
},
"number",
);
return this;
}
}

export { SenderBufferV1 };
30 changes: 30 additions & 0 deletions src/buffer/bufferv2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// @ts-check
import { SenderOptions } from "../options";
import { SenderBuffer } from "./index";
import { SenderBufferBase } from "./base";

const ENTITY_TYPE_DOUBLE: number = 16;
const EQUALS_SIGN: number = "=".charCodeAt(0);

class SenderBufferV2 extends SenderBufferBase {
constructor(options: SenderOptions) {
super(options);
}

floatColumn(name: string, value: number): SenderBuffer {
this.writeColumn(
name,
value,
() => {
this.checkCapacity([], 10);
this.writeByte(EQUALS_SIGN);
this.writeByte(ENTITY_TYPE_DOUBLE);
this.writeDouble(value);
},
"number",
);
return this;
}
}

export { SenderBufferV2 };
Loading