Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ferrum-db-client

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ferrum-db-client - npm Package Compare versions

Comparing version 0.2.8 to 0.2.9

1

dist/client.d.ts

@@ -9,3 +9,2 @@ /// <reference types="node" />

protected pending: Map<number, (buffer: Buffer) => void>;
private writeBuffer;
private lengthBuffer;

@@ -12,0 +11,0 @@ private heartBeatPending;

@@ -22,3 +22,2 @@ "use strict";

this.port = socket.remotePort;
this.writeBuffer = Buffer.alloc(8192);
this.lengthBuffer = Buffer.alloc(4);

@@ -134,6 +133,3 @@ this.socket = socket;

getSendWriter(messageType, payloadSize) {
while (payloadSize > this.writeBuffer.length) {
this.writeBuffer = this.expandBuffer(this.writeBuffer, MAX_BUFFER_SIZE);
}
const buffer = this.writeBuffer;
const buffer = Buffer.alloc(payloadSize + 24);
//Hack to skip the constructor of BinaryWriter because it does unecessairy and expensive copying

@@ -140,0 +136,0 @@ const bw = new csharp_binary_stream_1.BinaryWriter();

10

dist/collection_remote.js

@@ -24,3 +24,3 @@ "use strict";

async hasTag(tag = '') {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.COLLECTION_HAS_TAG, this.database.length + this.collectionKey.length + 1 + tag.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.COLLECTION_HAS_TAG, this.database.length + this.collectionKey.length + 1 + tag.length + 12);
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8);

@@ -42,3 +42,3 @@ bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8);

async getTagEntry(tag = '', encoding = 'json', compression = 'gzip') {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.COLLECTION_GET_TAG_ENTRY, this.database.length + this.collectionKey.length + 1 + tag.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.COLLECTION_GET_TAG_ENTRY, this.database.length + this.collectionKey.length + 1 + tag.length + 12);
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8);

@@ -65,3 +65,3 @@ bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8);

async deleteTag(tag = '') {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.COLLECTION_DELETE_TAG, this.database.length + this.collectionKey.length + 1 + tag.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.COLLECTION_DELETE_TAG, this.database.length + this.collectionKey.length + 1 + tag.length + 12);
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8);

@@ -83,3 +83,3 @@ bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8);

async getTags() {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.COLLECTION_GET_TAGS, this.database.length + this.collectionKey.length + 1);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.COLLECTION_GET_TAGS, this.database.length + this.collectionKey.length + 1 + 8);
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8);

@@ -106,3 +106,3 @@ bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8);

const encodedData = await (0, utils_1.encodeData)(value, encoding, compression);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.COLLECTION_SET_TAG, this.database.length + this.collectionKey.length + key.length + encodedData.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.COLLECTION_SET_TAG, this.database.length + this.collectionKey.length + key.length + encodedData.length + 16);
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8);

@@ -109,0 +109,0 @@ bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8);

@@ -16,3 +16,3 @@ "use strict";

async createIndexIfNotExist(index, encoding = 'bson', compression = 'gzip', pageFileSize = 0) {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.CREATE_INDEX_IF_NOT_EXIST, this.name.length + index.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.CREATE_INDEX_IF_NOT_EXIST, this.name.length + index.length + 8);
bw.writeString(this.name, csharp_binary_stream_1.Encoding.Utf8);

@@ -36,3 +36,3 @@ bw.writeString(index, csharp_binary_stream_1.Encoding.Utf8);

async deleteIndex(index) {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.DELETE_INDEX, index.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.DELETE_INDEX, index.length + this.name.length + 8);
bw.writeString(this.name, csharp_binary_stream_1.Encoding.Utf8);

@@ -52,3 +52,3 @@ bw.writeString(index, csharp_binary_stream_1.Encoding.Utf8);

async createIndex(index, encoding = 'bson', compression = 'gzip', pageFileSize = 0) {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.CREATE_INDEX, index.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.CREATE_INDEX, index.length + this.name.length + 8);
bw.writeString(this.name, csharp_binary_stream_1.Encoding.Utf8);

@@ -69,3 +69,3 @@ bw.writeString(index, csharp_binary_stream_1.Encoding.Utf8);

async hasIndex(index) {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.HAS_INDEX, index.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.HAS_INDEX, index.length + this.name.length + 8);
bw.writeString(this.name, csharp_binary_stream_1.Encoding.Utf8);

@@ -85,3 +85,3 @@ bw.writeString(index, csharp_binary_stream_1.Encoding.Utf8);

async getIndexes() {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.GET_INDEXES, 0);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.GET_INDEXES, this.name.length + 4);
bw.writeString(this.name, csharp_binary_stream_1.Encoding.Utf8);

@@ -105,3 +105,3 @@ this.client.sendMsg(bw);

async createSetIfNotExist(set) {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.CREATE_SET_IF_NOT_EXIST, this.name.length + set.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.CREATE_SET_IF_NOT_EXIST, this.name.length + set.length + 8);
bw.writeString(this.name, csharp_binary_stream_1.Encoding.Utf8);

@@ -124,3 +124,3 @@ bw.writeString(set, csharp_binary_stream_1.Encoding.Utf8);

async deleteSet(set) {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.DELETE_SET, set.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.DELETE_SET, set.length + this.name.length + 8);
bw.writeString(this.name, csharp_binary_stream_1.Encoding.Utf8);

@@ -140,3 +140,3 @@ bw.writeString(set, csharp_binary_stream_1.Encoding.Utf8);

async createSet(set) {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.CREATE_SET, set.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.CREATE_SET, set.length + this.name.length + 8);
bw.writeString(this.name, csharp_binary_stream_1.Encoding.Utf8);

@@ -156,3 +156,3 @@ bw.writeString(set, csharp_binary_stream_1.Encoding.Utf8);

async hasSet(set) {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.HAS_SET, set.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.HAS_SET, set.length + this.name.length + 8);
bw.writeString(this.name, csharp_binary_stream_1.Encoding.Utf8);

@@ -172,3 +172,3 @@ bw.writeString(set, csharp_binary_stream_1.Encoding.Utf8);

async getSets() {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.GET_SETS, 0);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.GET_SETS, this.name.length + 4);
bw.writeString(this.name, csharp_binary_stream_1.Encoding.Utf8);

@@ -192,3 +192,3 @@ this.client.sendMsg(bw);

async createTimeSeriesIfNotExist(name, encoding = 'bson', compression = 'gzip', pageFileSize = 0) {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.CREATE_TIME_SERIES_IF_NOT_EXIST, this.name.length + name.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.CREATE_TIME_SERIES_IF_NOT_EXIST, this.name.length + name.length + 8);
bw.writeString(this.name, csharp_binary_stream_1.Encoding.Utf8);

@@ -212,3 +212,3 @@ bw.writeString(name, csharp_binary_stream_1.Encoding.Utf8);

async deleteTimeSeries(name) {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.DELETE_TIME_SERIES, name.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.DELETE_TIME_SERIES, name.length + this.name.length + 8);
bw.writeString(this.name, csharp_binary_stream_1.Encoding.Utf8);

@@ -228,3 +228,3 @@ bw.writeString(name, csharp_binary_stream_1.Encoding.Utf8);

async createTimeSeries(name, encoding = 'bson', compression = 'gzip', pageFileSize = 0) {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.CREATE_TIME_SERIES, name.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.CREATE_TIME_SERIES, name.length + this.name.length + 8);
bw.writeString(this.name, csharp_binary_stream_1.Encoding.Utf8);

@@ -245,3 +245,3 @@ bw.writeString(name, csharp_binary_stream_1.Encoding.Utf8);

async hasTimeSeries(name) {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.HAS_TIME_SERIES, name.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.HAS_TIME_SERIES, name.length + this.name.length + 8);
bw.writeString(this.name, csharp_binary_stream_1.Encoding.Utf8);

@@ -261,3 +261,3 @@ bw.writeString(name, csharp_binary_stream_1.Encoding.Utf8);

async getListOfTimeSeries() {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.GET_TIME_SERIES, 0);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.GET_TIME_SERIES, this.name.length + 4);
bw.writeString(this.name, csharp_binary_stream_1.Encoding.Utf8);

@@ -281,3 +281,3 @@ this.client.sendMsg(bw);

async compact() {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.COMPACT, 0);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.COMPACT, this.name.length + 4);
bw.writeString(this.name, csharp_binary_stream_1.Encoding.Utf8);

@@ -284,0 +284,0 @@ this.client.sendMsg(bw);

@@ -15,3 +15,3 @@ "use strict";

async has(key) {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.INDEX_HAS, this.database.length + this.collectionKey.length + key.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.INDEX_HAS, this.database.length + this.collectionKey.length + key.length + 12);
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8);

@@ -32,3 +32,3 @@ bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8);

async getRecordSize(key) {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.INDEX_GET_RECORD_SIZE, this.database.length + this.collectionKey.length + key.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.INDEX_GET_RECORD_SIZE, this.database.length + this.collectionKey.length + key.length + 12);
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8);

@@ -50,3 +50,3 @@ bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8);

async getRecordCount() {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.INDEX_GET_RECORD_COUNT, this.database.length + this.collectionKey.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.INDEX_GET_RECORD_COUNT, this.database.length + this.collectionKey.length + 8);
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8);

@@ -67,3 +67,3 @@ bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8);

async get(key) {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.INDEX_GET, this.database.length + this.collectionKey.length + key.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.INDEX_GET, this.database.length + this.collectionKey.length + key.length + 12);
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8);

@@ -89,3 +89,3 @@ bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8);

async delete(key) {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.INDEX_DELETE, this.database.length + this.collectionKey.length + key.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.INDEX_DELETE, this.database.length + this.collectionKey.length + key.length + 12);
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8);

@@ -106,3 +106,3 @@ bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8);

async readChunk(key, offset, size) {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.INDEX_GET, this.database.length + this.collectionKey.length + key.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.INDEX_GET, this.database.length + this.collectionKey.length + key.length + 12);
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8);

@@ -132,3 +132,3 @@ bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8);

const encodedData = await (0, utils_1.encodeData)(value, this.encoding, this.compression);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.INDEX_SET, this.database.length + this.collectionKey.length + key.length + encodedData.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.INDEX_SET, this.database.length + this.collectionKey.length + key.length + encodedData.length + 12);
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8);

@@ -151,3 +151,3 @@ bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8);

async clear() {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.INDEX_CLEAR, this.database.length + this.collectionKey.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.INDEX_CLEAR, this.database.length + this.collectionKey.length + 8);
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8);

@@ -167,3 +167,3 @@ bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8);

async getKeys() {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.INDEX_GET_KEYS, this.database.length + this.collectionKey.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.INDEX_GET_KEYS, this.database.length + this.collectionKey.length + 8);
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8);

@@ -170,0 +170,0 @@ bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8);

@@ -45,3 +45,3 @@ "use strict";

async createDatabaseIfNotExists(dbName) {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.CREATE_DATABASE_IF_NOT_EXIST, dbName.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.CREATE_DATABASE_IF_NOT_EXIST, dbName.length + 4);
bw.writeString(dbName, csharp_binary_stream_1.Encoding.Utf8);

@@ -60,3 +60,3 @@ this.client.sendMsg(bw);

async createDatabase(dbName) {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.CREATE_DATABASE, dbName.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.CREATE_DATABASE, dbName.length + 4);
bw.writeString(dbName, csharp_binary_stream_1.Encoding.Utf8);

@@ -63,0 +63,0 @@ this.client.sendMsg(bw);

@@ -13,3 +13,3 @@ "use strict";

async has(key) {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.SET_HAS, this.database.length + this.collectionKey.length + key.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.SET_HAS, this.database.length + this.collectionKey.length + key.length + 12);
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8);

@@ -30,3 +30,3 @@ bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8);

async getRecordCount() {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.SET_GET_RECORD_COUNT, this.database.length + this.collectionKey.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.SET_GET_RECORD_COUNT, this.database.length + this.collectionKey.length + 8);
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8);

@@ -51,3 +51,3 @@ bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8);

async add(key) {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.SET_ADD, this.database.length + this.collectionKey.length + key.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.SET_ADD, this.database.length + this.collectionKey.length + key.length + 12);
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8);

@@ -68,3 +68,3 @@ bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8);

async clear() {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.SET_CLEAR, this.database.length + this.collectionKey.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.SET_CLEAR, this.database.length + this.collectionKey.length + 8);
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8);

@@ -84,3 +84,3 @@ bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8);

async delete(key) {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.SET_DELETE, this.database.length + this.collectionKey.length + key.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.SET_DELETE, this.database.length + this.collectionKey.length + key.length + 12);
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8);

@@ -101,3 +101,3 @@ bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8);

async getKeys() {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.SET_GET_KEYS, this.database.length + this.collectionKey.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.SET_GET_KEYS, this.database.length + this.collectionKey.length + 8);
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8);

@@ -104,0 +104,0 @@ bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8);

@@ -15,3 +15,3 @@ "use strict";

async hasSerie(serie) {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_HAS_SERIE, this.database.length + this.collectionKey.length + serie.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_HAS_SERIE, this.database.length + this.collectionKey.length + serie.length + 12);
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8);

@@ -32,3 +32,3 @@ bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8);

async getEntry(serie, timestamp) {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_GET_ENTRY, this.database.length + this.collectionKey.length + 8 + serie.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_GET_ENTRY, this.database.length + this.collectionKey.length + 8 + serie.length + 12);
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8);

@@ -55,3 +55,3 @@ bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8);

async hasEntry(serie, timestamp) {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_HAS_ENTRY, this.database.length + this.collectionKey.length + 8 + serie.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_HAS_ENTRY, this.database.length + this.collectionKey.length + 8 + serie.length + 12);
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8);

@@ -73,3 +73,3 @@ bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8);

async deleteEntry(serie, timestamp) {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_DELETE_ENTRY, this.database.length + this.collectionKey.length + 8 + serie.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_DELETE_ENTRY, this.database.length + this.collectionKey.length + 8 + serie.length + 12);
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8);

@@ -89,3 +89,3 @@ bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8);

async getFullSerie(serie) {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_GET_FULL_SERIE, this.database.length + this.collectionKey.length + serie.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_GET_FULL_SERIE, this.database.length + this.collectionKey.length + serie.length + 12);
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8);

@@ -116,3 +116,3 @@ bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8);

async getFullSerieEntries(serie) {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_GET_FULL_SERIE_ENTRIES, this.database.length + this.collectionKey.length + serie.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_GET_FULL_SERIE_ENTRIES, this.database.length + this.collectionKey.length + serie.length + 12);
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8);

@@ -138,3 +138,3 @@ bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8);

async getNearestEntryToTimestamp(serie, timestamp) {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_GET_NEAREST_ENTRY_TO_TIMESTAMP, this.database.length + this.collectionKey.length + 8 + serie.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_GET_NEAREST_ENTRY_TO_TIMESTAMP, this.database.length + this.collectionKey.length + 8 + serie.length + 12);
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8);

@@ -161,3 +161,3 @@ bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8);

async getFirstEntryBeforeTimestamp(serie, timestamp) {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_GET_FIRST_ENTRY_BEFORE_TIMESTAMP, this.database.length + this.collectionKey.length + 8 + serie.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_GET_FIRST_ENTRY_BEFORE_TIMESTAMP, this.database.length + this.collectionKey.length + 8 + serie.length + 12);
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8);

@@ -184,3 +184,3 @@ bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8);

async getFirstEntryAfterTimestamp(serie, timestamp) {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_GET_FIRST_ENTRY_AFTER_TIMESTAMP, this.database.length + this.collectionKey.length + 8 + serie.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_GET_FIRST_ENTRY_AFTER_TIMESTAMP, this.database.length + this.collectionKey.length + 8 + serie.length + 12);
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8);

@@ -207,3 +207,3 @@ bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8);

async getLastEntry(serie) {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_GET_LATEST_ENTRY, this.database.length + this.collectionKey.length + serie.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_GET_LATEST_ENTRY, this.database.length + this.collectionKey.length + serie.length + 12);
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8);

@@ -229,3 +229,3 @@ bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8);

async getFirstEntry(serie) {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_GET_EARLIEST_ENTRY, this.database.length + this.collectionKey.length + serie.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_GET_EARLIEST_ENTRY, this.database.length + this.collectionKey.length + serie.length + 12);
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8);

@@ -251,3 +251,3 @@ bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8);

async getLastNEntries(serie, count) {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_GET_LAST_N_ENTRIES, this.database.length + this.collectionKey.length + serie.length + 4);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_GET_LAST_N_ENTRIES, this.database.length + this.collectionKey.length + serie.length + 4 + 12);
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8);

@@ -274,3 +274,3 @@ bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8);

async getEntriesBeforeTimestamp(serie, timestamp) {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_GET_ENTRIES_BEFORE_TIMESTAMP, this.database.length + this.collectionKey.length + 8 + serie.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_GET_ENTRIES_BEFORE_TIMESTAMP, this.database.length + this.collectionKey.length + 8 + serie.length + 12);
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8);

@@ -297,3 +297,3 @@ bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8);

async getEntriesAfterTimestamp(serie, timestamp) {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_GET_ENTRIES_AFTER_TIMESTAMP, this.database.length + this.collectionKey.length + 8 + serie.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_GET_ENTRIES_AFTER_TIMESTAMP, this.database.length + this.collectionKey.length + 8 + serie.length + 12);
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8);

@@ -320,3 +320,3 @@ bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8);

async getEntriesBetween(serie, start, end) {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_GET_ENTRIES_BETWEEN_TIMESTAMPS, this.database.length + this.collectionKey.length + 16 + serie.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_GET_ENTRIES_BETWEEN_TIMESTAMPS, this.database.length + this.collectionKey.length + 16 + serie.length + 12);
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8);

@@ -344,3 +344,3 @@ bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8);

async deleteSerie(serie) {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_DELETE_SERIE, this.database.length + this.collectionKey.length + serie.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_DELETE_SERIE, this.database.length + this.collectionKey.length + serie.length + 12);
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8);

@@ -366,3 +366,3 @@ bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8);

let encodedData = await (0, utils_1.encodeData)(value, this.encoding, this.compression);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_PUT_ENTRY, this.database.length + this.collectionKey.length + serie.length + 8 + encodedData.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_PUT_ENTRY, this.database.length + this.collectionKey.length + serie.length + 8 + encodedData.length + 12);
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8);

@@ -386,3 +386,3 @@ bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8);

async clear() {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_CLEAR, this.database.length + this.collectionKey.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_CLEAR, this.database.length + this.collectionKey.length + 8);
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8);

@@ -402,3 +402,3 @@ bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8);

async getSeries() {
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_GET_SERIES, this.database.length + this.collectionKey.length);
const { bw, myId } = this.client.getSendWriter(protcol_1.ApiMessageType.TIME_SERIES_GET_SERIES, this.database.length + this.collectionKey.length + 8);
bw.writeString(this.database, csharp_binary_stream_1.Encoding.Utf8);

@@ -405,0 +405,0 @@ bw.writeString(this.collectionKey, csharp_binary_stream_1.Encoding.Utf8);

{
"name": "ferrum-db-client",
"version": "0.2.8",
"version": "0.2.9",
"main": "dist/index.js",

@@ -5,0 +5,0 @@ "typings": "dist/index.d.ts",

@@ -12,3 +12,2 @@ import { BinaryWriter, Encoding } from 'csharp-binary-stream';

protected pending: Map<number, (buffer: Buffer) => void>;
private writeBuffer: Buffer;
private lengthBuffer: Buffer;

@@ -33,3 +32,2 @@ private heartBeatPending: boolean = false;

this.port = socket.remotePort;
this.writeBuffer = Buffer.alloc(8192);
this.lengthBuffer = Buffer.alloc(4);

@@ -158,8 +156,4 @@ this.socket = socket;

public getSendWriter(messageType: ApiMessageType, payloadSize: number): { bw: BinaryWriter; myId: number } {
while (payloadSize > this.writeBuffer.length) {
this.writeBuffer = this.expandBuffer(this.writeBuffer, MAX_BUFFER_SIZE);
}
const buffer = Buffer.alloc(payloadSize + 24);
const buffer = this.writeBuffer;
//Hack to skip the constructor of BinaryWriter because it does unecessairy and expensive copying

@@ -166,0 +160,0 @@ const bw = new BinaryWriter();

@@ -29,3 +29,6 @@ import { Encoding } from 'csharp-binary-stream';

public async hasTag(tag: string = ''): Promise<boolean> {
const { bw, myId } = this.client.getSendWriter(ApiMessageType.COLLECTION_HAS_TAG, this.database.length + this.collectionKey.length + 1 + tag.length);
const { bw, myId } = this.client.getSendWriter(
ApiMessageType.COLLECTION_HAS_TAG,
this.database.length + this.collectionKey.length + 1 + tag.length + 12,
);
bw.writeString(this.database, Encoding.Utf8);

@@ -51,3 +54,3 @@ bw.writeString(this.collectionKey, Encoding.Utf8);

ApiMessageType.COLLECTION_GET_TAG_ENTRY,
this.database.length + this.collectionKey.length + 1 + tag.length,
this.database.length + this.collectionKey.length + 1 + tag.length + 12,
);

@@ -76,3 +79,6 @@ bw.writeString(this.database, Encoding.Utf8);

public async deleteTag(tag: string = ''): Promise<void> {
const { bw, myId } = this.client.getSendWriter(ApiMessageType.COLLECTION_DELETE_TAG, this.database.length + this.collectionKey.length + 1 + tag.length);
const { bw, myId } = this.client.getSendWriter(
ApiMessageType.COLLECTION_DELETE_TAG,
this.database.length + this.collectionKey.length + 1 + tag.length + 12,
);
bw.writeString(this.database, Encoding.Utf8);

@@ -96,3 +102,3 @@ bw.writeString(this.collectionKey, Encoding.Utf8);

public async getTags(): Promise<string[]> {
const { bw, myId } = this.client.getSendWriter(ApiMessageType.COLLECTION_GET_TAGS, this.database.length + this.collectionKey.length + 1);
const { bw, myId } = this.client.getSendWriter(ApiMessageType.COLLECTION_GET_TAGS, this.database.length + this.collectionKey.length + 1 + 8);
bw.writeString(this.database, Encoding.Utf8);

@@ -124,3 +130,3 @@ bw.writeString(this.collectionKey, Encoding.Utf8);

ApiMessageType.COLLECTION_SET_TAG,
this.database.length + this.collectionKey.length + key.length + encodedData.length,
this.database.length + this.collectionKey.length + key.length + encodedData.length + 16,
);

@@ -127,0 +133,0 @@ bw.writeString(this.database, Encoding.Utf8);

@@ -24,3 +24,3 @@ import { Encoding } from 'csharp-binary-stream';

): Promise<IndexRemote<T>> {
const { bw, myId } = this.client.getSendWriter(ApiMessageType.CREATE_INDEX_IF_NOT_EXIST, this.name.length + index.length);
const { bw, myId } = this.client.getSendWriter(ApiMessageType.CREATE_INDEX_IF_NOT_EXIST, this.name.length + index.length + 8);
bw.writeString(this.name, Encoding.Utf8);

@@ -48,3 +48,3 @@ bw.writeString(index, Encoding.Utf8);

public async deleteIndex(index: string): Promise<void> {
const { bw, myId } = this.client.getSendWriter(ApiMessageType.DELETE_INDEX, index.length);
const { bw, myId } = this.client.getSendWriter(ApiMessageType.DELETE_INDEX, index.length + this.name.length + 8);
bw.writeString(this.name, Encoding.Utf8);

@@ -72,3 +72,3 @@ bw.writeString(index, Encoding.Utf8);

): Promise<IndexRemote<T>> {
const { bw, myId } = this.client.getSendWriter(ApiMessageType.CREATE_INDEX, index.length);
const { bw, myId } = this.client.getSendWriter(ApiMessageType.CREATE_INDEX, index.length + this.name.length + 8);
bw.writeString(this.name, Encoding.Utf8);

@@ -92,3 +92,3 @@ bw.writeString(index, Encoding.Utf8);

public async hasIndex(index: string): Promise<boolean> {
const { bw, myId } = this.client.getSendWriter(ApiMessageType.HAS_INDEX, index.length);
const { bw, myId } = this.client.getSendWriter(ApiMessageType.HAS_INDEX, index.length + this.name.length + 8);
bw.writeString(this.name, Encoding.Utf8);

@@ -110,3 +110,3 @@ bw.writeString(index, Encoding.Utf8);

public async getIndexes(): Promise<string[]> {
const { bw, myId } = this.client.getSendWriter(ApiMessageType.GET_INDEXES, 0);
const { bw, myId } = this.client.getSendWriter(ApiMessageType.GET_INDEXES, this.name.length + 4);
bw.writeString(this.name, Encoding.Utf8);

@@ -132,3 +132,3 @@ this.client.sendMsg(bw);

public async createSetIfNotExist(set: string): Promise<SetRemote> {
const { bw, myId } = this.client.getSendWriter(ApiMessageType.CREATE_SET_IF_NOT_EXIST, this.name.length + set.length);
const { bw, myId } = this.client.getSendWriter(ApiMessageType.CREATE_SET_IF_NOT_EXIST, this.name.length + set.length + 8);
bw.writeString(this.name, Encoding.Utf8);

@@ -155,3 +155,3 @@ bw.writeString(set, Encoding.Utf8);

public async deleteSet(set: string): Promise<void> {
const { bw, myId } = this.client.getSendWriter(ApiMessageType.DELETE_SET, set.length);
const { bw, myId } = this.client.getSendWriter(ApiMessageType.DELETE_SET, set.length + this.name.length + 8);
bw.writeString(this.name, Encoding.Utf8);

@@ -174,3 +174,3 @@ bw.writeString(set, Encoding.Utf8);

public async createSet(set: string): Promise<SetRemote> {
const { bw, myId } = this.client.getSendWriter(ApiMessageType.CREATE_SET, set.length);
const { bw, myId } = this.client.getSendWriter(ApiMessageType.CREATE_SET, set.length + this.name.length + 8);
bw.writeString(this.name, Encoding.Utf8);

@@ -193,3 +193,3 @@ bw.writeString(set, Encoding.Utf8);

public async hasSet(set: string): Promise<boolean> {
const { bw, myId } = this.client.getSendWriter(ApiMessageType.HAS_SET, set.length);
const { bw, myId } = this.client.getSendWriter(ApiMessageType.HAS_SET, set.length + this.name.length + 8);
bw.writeString(this.name, Encoding.Utf8);

@@ -211,3 +211,3 @@ bw.writeString(set, Encoding.Utf8);

public async getSets(): Promise<string[]> {
const { bw, myId } = this.client.getSendWriter(ApiMessageType.GET_SETS, 0);
const { bw, myId } = this.client.getSendWriter(ApiMessageType.GET_SETS, this.name.length + 4);
bw.writeString(this.name, Encoding.Utf8);

@@ -238,3 +238,3 @@ this.client.sendMsg(bw);

): Promise<TimeSeriesRemote<T>> {
const { bw, myId } = this.client.getSendWriter(ApiMessageType.CREATE_TIME_SERIES_IF_NOT_EXIST, this.name.length + name.length);
const { bw, myId } = this.client.getSendWriter(ApiMessageType.CREATE_TIME_SERIES_IF_NOT_EXIST, this.name.length + name.length + 8);
bw.writeString(this.name, Encoding.Utf8);

@@ -262,3 +262,3 @@ bw.writeString(name, Encoding.Utf8);

public async deleteTimeSeries(name: string): Promise<void> {
const { bw, myId } = this.client.getSendWriter(ApiMessageType.DELETE_TIME_SERIES, name.length);
const { bw, myId } = this.client.getSendWriter(ApiMessageType.DELETE_TIME_SERIES, name.length + this.name.length + 8);
bw.writeString(this.name, Encoding.Utf8);

@@ -286,3 +286,3 @@ bw.writeString(name, Encoding.Utf8);

): Promise<TimeSeriesRemote<T>> {
const { bw, myId } = this.client.getSendWriter(ApiMessageType.CREATE_TIME_SERIES, name.length);
const { bw, myId } = this.client.getSendWriter(ApiMessageType.CREATE_TIME_SERIES, name.length + this.name.length + 8);
bw.writeString(this.name, Encoding.Utf8);

@@ -306,3 +306,3 @@ bw.writeString(name, Encoding.Utf8);

public async hasTimeSeries(name: string): Promise<boolean> {
const { bw, myId } = this.client.getSendWriter(ApiMessageType.HAS_TIME_SERIES, name.length);
const { bw, myId } = this.client.getSendWriter(ApiMessageType.HAS_TIME_SERIES, name.length + this.name.length + 8);
bw.writeString(this.name, Encoding.Utf8);

@@ -324,3 +324,3 @@ bw.writeString(name, Encoding.Utf8);

public async getListOfTimeSeries(): Promise<string[]> {
const { bw, myId } = this.client.getSendWriter(ApiMessageType.GET_TIME_SERIES, 0);
const { bw, myId } = this.client.getSendWriter(ApiMessageType.GET_TIME_SERIES, this.name.length + 4);
bw.writeString(this.name, Encoding.Utf8);

@@ -345,3 +345,3 @@ this.client.sendMsg(bw);

public async compact(): Promise<void> {
const { bw, myId } = this.client.getSendWriter(ApiMessageType.COMPACT, 0);
const { bw, myId } = this.client.getSendWriter(ApiMessageType.COMPACT, this.name.length + 4);
bw.writeString(this.name, Encoding.Utf8);

@@ -348,0 +348,0 @@ this.client.sendMsg(bw);

@@ -18,3 +18,3 @@ import { Encoding } from 'csharp-binary-stream';

public async has(key: string): Promise<boolean> {
const { bw, myId } = this.client.getSendWriter(ApiMessageType.INDEX_HAS, this.database.length + this.collectionKey.length + key.length);
const { bw, myId } = this.client.getSendWriter(ApiMessageType.INDEX_HAS, this.database.length + this.collectionKey.length + key.length + 12);
bw.writeString(this.database, Encoding.Utf8);

@@ -37,3 +37,6 @@ bw.writeString(this.collectionKey, Encoding.Utf8);

public async getRecordSize(key: string): Promise<number> {
const { bw, myId } = this.client.getSendWriter(ApiMessageType.INDEX_GET_RECORD_SIZE, this.database.length + this.collectionKey.length + key.length);
const { bw, myId } = this.client.getSendWriter(
ApiMessageType.INDEX_GET_RECORD_SIZE,
this.database.length + this.collectionKey.length + key.length + 12,
);
bw.writeString(this.database, Encoding.Utf8);

@@ -57,3 +60,3 @@ bw.writeString(this.collectionKey, Encoding.Utf8);

public async getRecordCount(): Promise<number> {
const { bw, myId } = this.client.getSendWriter(ApiMessageType.INDEX_GET_RECORD_COUNT, this.database.length + this.collectionKey.length);
const { bw, myId } = this.client.getSendWriter(ApiMessageType.INDEX_GET_RECORD_COUNT, this.database.length + this.collectionKey.length + 8);
bw.writeString(this.database, Encoding.Utf8);

@@ -76,3 +79,3 @@ bw.writeString(this.collectionKey, Encoding.Utf8);

public async get(key: string): Promise<T> {
const { bw, myId } = this.client.getSendWriter(ApiMessageType.INDEX_GET, this.database.length + this.collectionKey.length + key.length);
const { bw, myId } = this.client.getSendWriter(ApiMessageType.INDEX_GET, this.database.length + this.collectionKey.length + key.length + 12);
bw.writeString(this.database, Encoding.Utf8);

@@ -99,3 +102,3 @@ bw.writeString(this.collectionKey, Encoding.Utf8);

public async delete(key: string): Promise<void> {
const { bw, myId } = this.client.getSendWriter(ApiMessageType.INDEX_DELETE, this.database.length + this.collectionKey.length + key.length);
const { bw, myId } = this.client.getSendWriter(ApiMessageType.INDEX_DELETE, this.database.length + this.collectionKey.length + key.length + 12);
bw.writeString(this.database, Encoding.Utf8);

@@ -118,3 +121,3 @@ bw.writeString(this.collectionKey, Encoding.Utf8);

public async readChunk(key: string, offset: number, size: number): Promise<Buffer> {
const { bw, myId } = this.client.getSendWriter(ApiMessageType.INDEX_GET, this.database.length + this.collectionKey.length + key.length);
const { bw, myId } = this.client.getSendWriter(ApiMessageType.INDEX_GET, this.database.length + this.collectionKey.length + key.length + 12);
bw.writeString(this.database, Encoding.Utf8);

@@ -150,3 +153,3 @@ bw.writeString(this.collectionKey, Encoding.Utf8);

ApiMessageType.INDEX_SET,
this.database.length + this.collectionKey.length + key.length + encodedData.length,
this.database.length + this.collectionKey.length + key.length + encodedData.length + 12,
);

@@ -172,3 +175,3 @@ bw.writeString(this.database, Encoding.Utf8);

public async clear(): Promise<void> {
const { bw, myId } = this.client.getSendWriter(ApiMessageType.INDEX_CLEAR, this.database.length + this.collectionKey.length);
const { bw, myId } = this.client.getSendWriter(ApiMessageType.INDEX_CLEAR, this.database.length + this.collectionKey.length + 8);
bw.writeString(this.database, Encoding.Utf8);

@@ -190,3 +193,3 @@ bw.writeString(this.collectionKey, Encoding.Utf8);

public async getKeys(): Promise<string[]> {
const { bw, myId } = this.client.getSendWriter(ApiMessageType.INDEX_GET_KEYS, this.database.length + this.collectionKey.length);
const { bw, myId } = this.client.getSendWriter(ApiMessageType.INDEX_GET_KEYS, this.database.length + this.collectionKey.length + 8);
bw.writeString(this.database, Encoding.Utf8);

@@ -193,0 +196,0 @@ bw.writeString(this.collectionKey, Encoding.Utf8);

@@ -46,3 +46,3 @@ import { Encoding } from 'csharp-binary-stream';

public async createDatabaseIfNotExists(dbName: string): Promise<FerrumDBRemote> {
const { bw, myId } = this.client.getSendWriter(ApiMessageType.CREATE_DATABASE_IF_NOT_EXIST, dbName.length);
const { bw, myId } = this.client.getSendWriter(ApiMessageType.CREATE_DATABASE_IF_NOT_EXIST, dbName.length + 4);
bw.writeString(dbName, Encoding.Utf8);

@@ -63,3 +63,3 @@ this.client.sendMsg(bw);

public async createDatabase(dbName: string): Promise<FerrumDBRemote> {
const { bw, myId } = this.client.getSendWriter(ApiMessageType.CREATE_DATABASE, dbName.length);
const { bw, myId } = this.client.getSendWriter(ApiMessageType.CREATE_DATABASE, dbName.length + 4);
bw.writeString(dbName, Encoding.Utf8);

@@ -66,0 +66,0 @@ this.client.sendMsg(bw);

@@ -13,3 +13,3 @@ import { Encoding } from 'csharp-binary-stream';

public async has(key: string): Promise<boolean> {
const { bw, myId } = this.client.getSendWriter(ApiMessageType.SET_HAS, this.database.length + this.collectionKey.length + key.length);
const { bw, myId } = this.client.getSendWriter(ApiMessageType.SET_HAS, this.database.length + this.collectionKey.length + key.length + 12);
bw.writeString(this.database, Encoding.Utf8);

@@ -32,3 +32,3 @@ bw.writeString(this.collectionKey, Encoding.Utf8);

public async getRecordCount(): Promise<number> {
const { bw, myId } = this.client.getSendWriter(ApiMessageType.SET_GET_RECORD_COUNT, this.database.length + this.collectionKey.length);
const { bw, myId } = this.client.getSendWriter(ApiMessageType.SET_GET_RECORD_COUNT, this.database.length + this.collectionKey.length + 8);
bw.writeString(this.database, Encoding.Utf8);

@@ -56,3 +56,3 @@ bw.writeString(this.collectionKey, Encoding.Utf8);

public async add(key: string): Promise<void> {
const { bw, myId } = this.client.getSendWriter(ApiMessageType.SET_ADD, this.database.length + this.collectionKey.length + key.length);
const { bw, myId } = this.client.getSendWriter(ApiMessageType.SET_ADD, this.database.length + this.collectionKey.length + key.length + 12);
bw.writeString(this.database, Encoding.Utf8);

@@ -75,3 +75,3 @@ bw.writeString(this.collectionKey, Encoding.Utf8);

public async clear(): Promise<void> {
const { bw, myId } = this.client.getSendWriter(ApiMessageType.SET_CLEAR, this.database.length + this.collectionKey.length);
const { bw, myId } = this.client.getSendWriter(ApiMessageType.SET_CLEAR, this.database.length + this.collectionKey.length + 8);
bw.writeString(this.database, Encoding.Utf8);

@@ -93,3 +93,3 @@ bw.writeString(this.collectionKey, Encoding.Utf8);

public async delete(key: string): Promise<void> {
const { bw, myId } = this.client.getSendWriter(ApiMessageType.SET_DELETE, this.database.length + this.collectionKey.length + key.length);
const { bw, myId } = this.client.getSendWriter(ApiMessageType.SET_DELETE, this.database.length + this.collectionKey.length + key.length + 12);
bw.writeString(this.database, Encoding.Utf8);

@@ -112,3 +112,3 @@ bw.writeString(this.collectionKey, Encoding.Utf8);

public async getKeys(): Promise<string[]> {
const { bw, myId } = this.client.getSendWriter(ApiMessageType.SET_GET_KEYS, this.database.length + this.collectionKey.length);
const { bw, myId } = this.client.getSendWriter(ApiMessageType.SET_GET_KEYS, this.database.length + this.collectionKey.length + 8);
bw.writeString(this.database, Encoding.Utf8);

@@ -115,0 +115,0 @@ bw.writeString(this.collectionKey, Encoding.Utf8);

@@ -26,3 +26,6 @@ import { Encoding } from 'csharp-binary-stream';

public async hasSerie(serie: string): Promise<boolean> {
const { bw, myId } = this.client.getSendWriter(ApiMessageType.TIME_SERIES_HAS_SERIE, this.database.length + this.collectionKey.length + serie.length);
const { bw, myId } = this.client.getSendWriter(
ApiMessageType.TIME_SERIES_HAS_SERIE,
this.database.length + this.collectionKey.length + serie.length + 12,
);
bw.writeString(this.database, Encoding.Utf8);

@@ -47,3 +50,3 @@ bw.writeString(this.collectionKey, Encoding.Utf8);

ApiMessageType.TIME_SERIES_GET_ENTRY,
this.database.length + this.collectionKey.length + 8 + serie.length,
this.database.length + this.collectionKey.length + 8 + serie.length + 12,
);

@@ -74,3 +77,3 @@ bw.writeString(this.database, Encoding.Utf8);

ApiMessageType.TIME_SERIES_HAS_ENTRY,
this.database.length + this.collectionKey.length + 8 + serie.length,
this.database.length + this.collectionKey.length + 8 + serie.length + 12,
);

@@ -97,3 +100,3 @@ bw.writeString(this.database, Encoding.Utf8);

ApiMessageType.TIME_SERIES_DELETE_ENTRY,
this.database.length + this.collectionKey.length + 8 + serie.length,
this.database.length + this.collectionKey.length + 8 + serie.length + 12,
);

@@ -120,3 +123,3 @@ bw.writeString(this.database, Encoding.Utf8);

ApiMessageType.TIME_SERIES_GET_FULL_SERIE,
this.database.length + this.collectionKey.length + serie.length,
this.database.length + this.collectionKey.length + serie.length + 12,
);

@@ -152,3 +155,3 @@ bw.writeString(this.database, Encoding.Utf8);

ApiMessageType.TIME_SERIES_GET_FULL_SERIE_ENTRIES,
this.database.length + this.collectionKey.length + serie.length,
this.database.length + this.collectionKey.length + serie.length + 12,
);

@@ -178,3 +181,3 @@ bw.writeString(this.database, Encoding.Utf8);

ApiMessageType.TIME_SERIES_GET_NEAREST_ENTRY_TO_TIMESTAMP,
this.database.length + this.collectionKey.length + 8 + serie.length,
this.database.length + this.collectionKey.length + 8 + serie.length + 12,
);

@@ -204,3 +207,3 @@ bw.writeString(this.database, Encoding.Utf8);

ApiMessageType.TIME_SERIES_GET_FIRST_ENTRY_BEFORE_TIMESTAMP,
this.database.length + this.collectionKey.length + 8 + serie.length,
this.database.length + this.collectionKey.length + 8 + serie.length + 12,
);

@@ -231,3 +234,3 @@ bw.writeString(this.database, Encoding.Utf8);

ApiMessageType.TIME_SERIES_GET_FIRST_ENTRY_AFTER_TIMESTAMP,
this.database.length + this.collectionKey.length + 8 + serie.length,
this.database.length + this.collectionKey.length + 8 + serie.length + 12,
);

@@ -258,3 +261,3 @@ bw.writeString(this.database, Encoding.Utf8);

ApiMessageType.TIME_SERIES_GET_LATEST_ENTRY,
this.database.length + this.collectionKey.length + serie.length,
this.database.length + this.collectionKey.length + serie.length + 12,
);

@@ -284,3 +287,3 @@ bw.writeString(this.database, Encoding.Utf8);

ApiMessageType.TIME_SERIES_GET_EARLIEST_ENTRY,
this.database.length + this.collectionKey.length + serie.length,
this.database.length + this.collectionKey.length + serie.length + 12,
);

@@ -310,3 +313,3 @@ bw.writeString(this.database, Encoding.Utf8);

ApiMessageType.TIME_SERIES_GET_LAST_N_ENTRIES,
this.database.length + this.collectionKey.length + serie.length + 4,
this.database.length + this.collectionKey.length + serie.length + 4 + 12,
);

@@ -337,3 +340,3 @@ bw.writeString(this.database, Encoding.Utf8);

ApiMessageType.TIME_SERIES_GET_ENTRIES_BEFORE_TIMESTAMP,
this.database.length + this.collectionKey.length + 8 + serie.length,
this.database.length + this.collectionKey.length + 8 + serie.length + 12,
);

@@ -364,3 +367,3 @@ bw.writeString(this.database, Encoding.Utf8);

ApiMessageType.TIME_SERIES_GET_ENTRIES_AFTER_TIMESTAMP,
this.database.length + this.collectionKey.length + 8 + serie.length,
this.database.length + this.collectionKey.length + 8 + serie.length + 12,
);

@@ -391,3 +394,3 @@ bw.writeString(this.database, Encoding.Utf8);

ApiMessageType.TIME_SERIES_GET_ENTRIES_BETWEEN_TIMESTAMPS,
this.database.length + this.collectionKey.length + 16 + serie.length,
this.database.length + this.collectionKey.length + 16 + serie.length + 12,
);

@@ -419,3 +422,3 @@ bw.writeString(this.database, Encoding.Utf8);

ApiMessageType.TIME_SERIES_DELETE_SERIE,
this.database.length + this.collectionKey.length + serie.length,
this.database.length + this.collectionKey.length + serie.length + 12,
);

@@ -448,3 +451,3 @@ bw.writeString(this.database, Encoding.Utf8);

ApiMessageType.TIME_SERIES_PUT_ENTRY,
this.database.length + this.collectionKey.length + serie.length + 8 + encodedData.length,
this.database.length + this.collectionKey.length + serie.length + 8 + encodedData.length + 12,
);

@@ -471,3 +474,3 @@ bw.writeString(this.database, Encoding.Utf8);

public async clear(): Promise<void> {
const { bw, myId } = this.client.getSendWriter(ApiMessageType.TIME_SERIES_CLEAR, this.database.length + this.collectionKey.length);
const { bw, myId } = this.client.getSendWriter(ApiMessageType.TIME_SERIES_CLEAR, this.database.length + this.collectionKey.length + 8);
bw.writeString(this.database, Encoding.Utf8);

@@ -489,3 +492,3 @@ bw.writeString(this.collectionKey, Encoding.Utf8);

public async getSeries(): Promise<string[]> {
const { bw, myId } = this.client.getSendWriter(ApiMessageType.TIME_SERIES_GET_SERIES, this.database.length + this.collectionKey.length);
const { bw, myId } = this.client.getSendWriter(ApiMessageType.TIME_SERIES_GET_SERIES, this.database.length + this.collectionKey.length + 8);
bw.writeString(this.database, Encoding.Utf8);

@@ -492,0 +495,0 @@ bw.writeString(this.collectionKey, Encoding.Utf8);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc