Skip to content

Commit 30b3a7c

Browse files
committed
refactor: rename interfaces away from the 'store' terminology to simply 'keyval' or 'kv'. BREAKING CHANGE
1 parent d4450a1 commit 30b3a7c

File tree

16 files changed

+77
-77
lines changed

16 files changed

+77
-77
lines changed

dist/idb.js.map

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/main.js.map

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"keyval",
1010
"redis",
1111
"indexeddb",
12-
"memory-store",
12+
"object-store",
1313
"file-store",
1414
"nosql"
1515
],
@@ -27,14 +27,14 @@
2727
"type": "module",
2828
"exports": {
2929
".": "./src/index.js",
30-
"./memory": "./src/MemoryStore.js",
31-
"./redis": "./src/RedisStore.js",
32-
"./idb": "./src/IDBStore.js",
33-
"./file": "./src/FileStore.js"
30+
"./file": "./src/FileKV.js",
31+
".//indexeddb": "./src/IndexedDBKV.js",
32+
"./inmemory": "./src/InMemoryKV.js",
33+
"./redis": "./src/RedisKV.js"
3434
},
3535
"scripts": {
3636
"test": "mocha --extension .test.js --recursive --timeout 5000 --exit",
37-
"build": "esbuild main=src/MemoryStore.js idb=src/IDBStore.js --bundle --minify --sourcemap --outdir=dist",
37+
"build": "esbuild main=src/InMemoryKV.js idb=src/IndexedDBKV.js --bundle --minify --sourcemap --outdir=dist",
3838
"preversion": "npm run test && npm run build && git add -A dist",
3939
"postversion": "git push && git push --tags",
4040
"version:next": "npm version prerelease --preid=next"

src/FileStore.js renamed to src/FileKV.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import fs from 'fs/promises';
22
import Path from 'path';
3-
import { Store } from './Store.js';
4-
export { Store };
3+
import { KV } from './KV.js';
4+
export { KV };
55

6-
export class FileStore extends Store {
6+
export class FileKV extends KV {
77

88
#file;
99

10-
constructor({ dir = '.webqit_store', ...options }) {
10+
constructor({ dir = '.webqit_keyval', ...options }) {
1111
super(options);
1212
const safePath = this.path.map(p =>
1313
p.replace(/[\/\\]/g, '_')
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { Store } from './Store.js';
2-
export { Store };
1+
import { KV } from './KV.js';
2+
export { KV };
33

4-
export class MemoryStore extends Store {
4+
export class InMemoryKV extends KV {
55

66
#exists(node) {
77
if (!node?.subtree.has('value')) return;

src/IDBStore.js renamed to src/IndexedDBKV.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { Store } from './Store.js';
2-
export { Store };
1+
import { KV } from './KV.js';
2+
export { KV };
33

4-
export class IDBStore extends Store {
4+
export class IndexedDBKV extends KV {
55

66
static #dbCache = new Map;
77

@@ -10,7 +10,7 @@ export class IDBStore extends Store {
1010
#storeName;
1111
#channel;
1212

13-
constructor({ dbName = 'webqit_store', channel = null, ...options }) {
13+
constructor({ dbName = 'webqit_keyval', channel = null, ...options }) {
1414
super(options);
1515
this.#dbName = dbName;
1616
this.#storeName = this.path.join(':');
@@ -27,7 +27,7 @@ export class IDBStore extends Store {
2727
db.close();
2828

2929
// Invalidate local handle so next op reopens
30-
IDBStore.#dbCache.delete(this.#dbName);
30+
IndexedDBKV.#dbCache.delete(this.#dbName);
3131

3232
this.#db = null;
3333
};
@@ -36,8 +36,8 @@ export class IDBStore extends Store {
3636
async #open() {
3737
const cacheKey = this.#dbName;
3838

39-
if (IDBStore.#dbCache.has(cacheKey)) {
40-
this.#db = IDBStore.#dbCache.get(cacheKey);
39+
if (IndexedDBKV.#dbCache.has(cacheKey)) {
40+
this.#db = IndexedDBKV.#dbCache.get(cacheKey);
4141
if (this.#db.objectStoreNames.contains(this.#storeName)) {
4242
return this.#db;
4343
}
@@ -75,7 +75,7 @@ export class IDBStore extends Store {
7575
this.#db = initialDB;
7676
}
7777

78-
IDBStore.#dbCache.set(cacheKey, this.#db);
78+
IndexedDBKV.#dbCache.set(cacheKey, this.#db);
7979
this.#attachDBLifecycle(this.#db);
8080
return this.#db;
8181
}
@@ -103,7 +103,7 @@ export class IDBStore extends Store {
103103
this.#channel?.close();
104104
this.#db?.close();
105105

106-
IDBStore.#dbCache.delete(this.#dbName);
106+
IndexedDBKV.#dbCache.delete(this.#dbName);
107107
this.#db = null;
108108

109109
await super.close();

src/Store.js renamed to src/KV.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export class Store {
1+
export class KV {
22

33
static create(options) { return new this(options); }
44

src/RedisStore.js renamed to src/RedisKV.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { Store } from './Store.js';
1+
import { KV } from './KV.js';
22
import { createClient } from 'redis';
33
export { createClient };
4-
export { Store };
4+
export { KV };
55

6-
export class RedisStore extends Store {
6+
export class RedisKV extends KV {
77

88
#redis;
99
#redisPath;

src/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
export * from './Store.js';
2-
export * from './MemoryStore.js';
3-
export * from './RedisStore.js';
4-
export * from './IDBStore.js';
5-
export * from './FileStore.js';
1+
export * from './KV.js';
2+
export * from './FileKV.js';
3+
export * from './IndexedDBKV.js';
4+
export * from './InMemoryKV.js';
5+
export * from './RedisKV.js';

test/file.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import fs from 'fs/promises';
22
import os from 'os';
33
import path from 'path';
4-
import { FileStore } from '../src/FileStore.js';
5-
import { runStoreContract } from './helpers/storeContract.js';
4+
import { FileKV } from '../src/FileKV.js';
5+
import { runKVContract } from './helpers/kvContract.js';
66

7-
describe('FileStore', () => {
7+
describe('FileKV', () => {
88

99
let dir;
1010
let store;
@@ -14,7 +14,7 @@ describe('FileStore', () => {
1414
path.join(os.tmpdir(), 'filestore-test-')
1515
);
1616

17-
store = new FileStore({
17+
store = new FileKV({
1818
dir,
1919
path: ['test'],
2020
ttl: 1
@@ -26,5 +26,5 @@ describe('FileStore', () => {
2626
await fs.rm(dir, { recursive: true, force: true });
2727
});
2828

29-
runStoreContract(async () => store);
29+
runKVContract(async () => store);
3030
});

0 commit comments

Comments
 (0)