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

superkv

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

superkv - npm Package Compare versions

Comparing version 1.9.0 to 1.9.1

21

dist/index.js

@@ -117,2 +117,4 @@ var __defProp = Object.defineProperty;

keysToDelete;
tableWriteStore;
tableDeleteStore;
constructor(args, options = {}) {

@@ -124,2 +126,4 @@ const { kvApi } = args;

this.keysToDelete = /* @__PURE__ */ new Map();
this.tableWriteStore = /* @__PURE__ */ new Map();
this.tableDeleteStore = /* @__PURE__ */ new Map();
}

@@ -130,2 +134,4 @@ send = async ({ force } = { force: false }) => {

await this.kvApi.writeMultipleKeyValuePairs(keyValuePairs);
this.dataToWrite.clear();
this.tableWriteStore.clear();
}

@@ -135,2 +141,4 @@ if (this.keysToDelete.size >= this.options.chunkSize || force) {

await this.kvApi.deleteMultipleKeyValuePairs(keys);
this.keysToDelete.clear();
this.tableDeleteStore.clear();
}

@@ -140,8 +148,21 @@ };

const { dataToWrite, keysToDelete } = await kvTable.prepareSet(key, metadata, value, options);
this.cleanKeyFromTableStore(key);
await this.delMulti(keysToDelete);
await this.setMulti(dataToWrite);
this.tableWriteStore.set(key, dataToWrite);
this.tableDeleteStore.set(key, keysToDelete);
};
cleanKeyFromTableStore = (key) => {
const currentDataToWrite = this.tableWriteStore.get(key);
if (currentDataToWrite)
currentDataToWrite.forEach((keyValuePair) => this.dataToWrite.delete(keyValuePair.key));
const currentKeysToDelete = this.tableDeleteStore.get(key);
if (currentKeysToDelete)
currentKeysToDelete.forEach((k) => this.keysToDelete.delete(k));
};
delFromTable = async (kvTable, key) => {
const keysToDelete = await kvTable.prepareDel(key);
this.cleanKeyFromTableStore(key);
await this.delMulti(keysToDelete);
this.tableDeleteStore.set(key, keysToDelete);
};

@@ -148,0 +169,0 @@ setMulti = async (keyValuePairs) => {

3

dist/kvBatch.d.ts

@@ -14,2 +14,4 @@ import KVApi, { KeyValuePair, SetOptions } from './kvApi';

keysToDelete: Map<string, void>;
tableWriteStore: Map<string, KeyValuePair[]>;
tableDeleteStore: Map<string, string[]>;
constructor(args: KVBatchArgs, options?: KVBatchOptions);

@@ -20,2 +22,3 @@ send: ({ force }?: {

setToTable: <Metadata, Value>(kvTable: KVTable<Metadata, Value>, key: string, metadata: Metadata, value?: Value, options?: SetOptions) => Promise<void>;
cleanKeyFromTableStore: (key: string) => void;
delFromTable: (kvTable: KVTable<any, any>, key: string) => Promise<void>;

@@ -22,0 +25,0 @@ setMulti: (keyValuePairs: KeyValuePair[]) => Promise<void>;

5

package.json
{
"name": "superkv",
"version": "1.9.0",
"version": "1.9.1",
"author": "g45t345rt",

@@ -22,2 +22,3 @@ "license": "ISC",

"test:kvBatch": "jest -i test/kvBatch.test.ts",
"test:kvBatchTable": "jest -i test/kvBatchTable.test.ts",
"test:kvItem": "jest -i test/kvItem.test.ts",

@@ -42,2 +43,2 @@ "test:delUpdatePrefix": "jest -i test/delUpdatePrefix.test.ts",

}
}
}

@@ -19,8 +19,10 @@ # SUPERKV - Supercharge Clouflare KeyValue store (experimental)

- If you have ideas or you know how to optimize/fix things please help :)
- KV uses ascending lexicographical order. You have to use ULID to sort descending <https://www.npmjs.com/package/ulidx>
- KV uses ascending lexicographical order. You can use ULID <https://www.npmjs.com/package/ulidx> or reverse the number to sort descending.
- I have no prior knowledge in making a tool for data management and this is the best I could come up with.
- Reads will sometimes reflect older state and write can take up to 60 seconds before reads in all edge locations are guaranteed <https://developers.cloudflare.com/workers/platform/limits#kv>
## TODO
- Local KV api emulator
- [] Local KV api emulator
- [] KV triggers

@@ -27,0 +29,0 @@ ## How to use it

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