Skip to content

Commit

Permalink
feat: add node localstorage quota option (#47)
Browse files Browse the repository at this point in the history
* feat: add store quota option to @kvs/node-localstorage

* chore: probably a side-effect from previous pr that wasn't committed
  • Loading branch information
toniopelo committed Jan 26, 2024
1 parent bd85ca1 commit aebcd61
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
4 changes: 3 additions & 1 deletion packages/node-localstorage/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type KvsLocalStorage<Schema extends KvsLocalStorageSchema> = KVS<Schema>;
export type KvsLocalStorageOptions<Schema extends KvsLocalStorageSchema> = KVSOptions<Schema> & {
kvsVersionKey?: string;
storeFilePath?: string;
storeQuota?: number;
};
export const kvsLocalStorage = async <Schema extends KvsLocalStorageSchema>(
options: KvsLocalStorageOptions<Schema>
Expand All @@ -27,8 +28,9 @@ export const kvsLocalStorage = async <Schema extends KvsLocalStorageSchema>(
const saveFilePath = options.storeFilePath
? options.storeFilePath
: path.join(defaultCacheDir, "kvs-node-localstorage");
const storeQuota = options.storeQuota ? options.storeQuota : 5 * 1024 * 1024;
return kvsStorage({
...options,
storage: new LocalStorage(saveFilePath)
storage: new LocalStorage(saveFilePath, storeQuota)
});
};
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4627,11 +4627,6 @@ mkdirp@^1.0.3:
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e"
integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==

mkdirp@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-3.0.1.tgz#e44e4c5607fb279c168241713cc6e0fea9adcb50"
integrity sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg==

mocha@^10.2.0:
version "10.2.0"
resolved "https://registry.yarnpkg.com/mocha/-/mocha-10.2.0.tgz#1fd4a7c32ba5ac372e03a17eef435bd00e5c68b8"
Expand Down

0 comments on commit aebcd61

Please sign in to comment.