@kvs/node-localstorage 2.1.4 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.ts CHANGED
@@ -7,5 +7,6 @@ export type KvsLocalStorage<Schema extends KvsLocalStorageSchema> = KVS<Schema>;
7
7
  export type KvsLocalStorageOptions<Schema extends KvsLocalStorageSchema> = KVSOptions<Schema> & {
8
8
  kvsVersionKey?: string;
9
9
  storeFilePath?: string;
10
+ storeQuota?: number;
10
11
  };
11
12
  export declare const kvsLocalStorage: <Schema extends KvsLocalStorageSchema>(options: KvsLocalStorageOptions<Schema>) => Promise<KvsStorage<Schema>>;
package/lib/index.js CHANGED
@@ -6,22 +6,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.kvsLocalStorage = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const storage_1 = require("@kvs/storage");
9
+ const promises_1 = __importDefault(require("node:fs/promises"));
9
10
  // @ts-ignore
10
11
  const node_localstorage_1 = require("node-localstorage");
11
12
  // @ts-ignore
12
13
  const app_root_path_1 = __importDefault(require("app-root-path"));
13
- const mkdirp_1 = require("mkdirp");
14
14
  const kvsLocalStorage = async (options) => {
15
15
  const defaultCacheDir = path_1.default.join(app_root_path_1.default.toString(), ".cache");
16
16
  if (!options.storeFilePath) {
17
- await (0, mkdirp_1.mkdirp)(defaultCacheDir);
17
+ await promises_1.default.mkdir(defaultCacheDir, {
18
+ recursive: true
19
+ });
18
20
  }
19
21
  const saveFilePath = options.storeFilePath
20
22
  ? options.storeFilePath
21
23
  : path_1.default.join(defaultCacheDir, "kvs-node-localstorage");
24
+ const storeQuota = options.storeQuota ? options.storeQuota : 5 * 1024 * 1024;
22
25
  return (0, storage_1.kvsStorage)({
23
26
  ...options,
24
- storage: new node_localstorage_1.LocalStorage(saveFilePath)
27
+ storage: new node_localstorage_1.LocalStorage(saveFilePath, storeQuota)
25
28
  });
26
29
  };
27
30
  exports.kvsLocalStorage = kvsLocalStorage;
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,0CAAiE;AAEjE,aAAa;AACb,yDAAiD;AACjD,aAAa;AACb,kEAAoC;AACpC,mCAAgC;AAUzB,MAAM,eAAe,GAAG,KAAK,EAChC,OAAuC,EACZ,EAAE;IAC7B,MAAM,eAAe,GAAG,cAAI,CAAC,IAAI,CAAC,uBAAO,CAAC,QAAQ,EAAE,EAAE,QAAQ,CAAC,CAAC;IAChE,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE;QACxB,MAAM,IAAA,eAAM,EAAC,eAAe,CAAC,CAAC;KACjC;IACD,MAAM,YAAY,GAAG,OAAO,CAAC,aAAa;QACtC,CAAC,CAAC,OAAO,CAAC,aAAa;QACvB,CAAC,CAAC,cAAI,CAAC,IAAI,CAAC,eAAe,EAAE,uBAAuB,CAAC,CAAC;IAC1D,OAAO,IAAA,oBAAU,EAAC;QACd,GAAG,OAAO;QACV,OAAO,EAAE,IAAI,gCAAY,CAAC,YAAY,CAAC;KAC1C,CAAC,CAAC;AACP,CAAC,CAAC;AAdW,QAAA,eAAe,mBAc1B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,0CAAiE;AAEjE,gEAAkC;AAClC,aAAa;AACb,yDAAiD;AACjD,aAAa;AACb,kEAAoC;AAW7B,MAAM,eAAe,GAAG,KAAK,EAChC,OAAuC,EACZ,EAAE;IAC7B,MAAM,eAAe,GAAG,cAAI,CAAC,IAAI,CAAC,uBAAO,CAAC,QAAQ,EAAE,EAAE,QAAQ,CAAC,CAAC;IAChE,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;QACzB,MAAM,kBAAE,CAAC,KAAK,CAAC,eAAe,EAAE;YAC5B,SAAS,EAAE,IAAI;SAClB,CAAC,CAAC;IACP,CAAC;IACD,MAAM,YAAY,GAAG,OAAO,CAAC,aAAa;QACtC,CAAC,CAAC,OAAO,CAAC,aAAa;QACvB,CAAC,CAAC,cAAI,CAAC,IAAI,CAAC,eAAe,EAAE,uBAAuB,CAAC,CAAC;IAC1D,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;IAC7E,OAAO,IAAA,oBAAU,EAAC;QACd,GAAG,OAAO;QACV,OAAO,EAAE,IAAI,gCAAY,CAAC,YAAY,EAAE,UAAU,CAAC;KACtD,CAAC,CAAC;AACP,CAAC,CAAC;AAjBW,QAAA,eAAe,mBAiB1B"}
package/module/index.d.ts CHANGED
@@ -7,5 +7,6 @@ export type KvsLocalStorage<Schema extends KvsLocalStorageSchema> = KVS<Schema>;
7
7
  export type KvsLocalStorageOptions<Schema extends KvsLocalStorageSchema> = KVSOptions<Schema> & {
8
8
  kvsVersionKey?: string;
9
9
  storeFilePath?: string;
10
+ storeQuota?: number;
10
11
  };
11
12
  export declare const kvsLocalStorage: <Schema extends KvsLocalStorageSchema>(options: KvsLocalStorageOptions<Schema>) => Promise<KvsStorage<Schema>>;
package/module/index.js CHANGED
@@ -1,21 +1,24 @@
1
1
  import path from "path";
2
2
  import { kvsStorage } from "@kvs/storage";
3
+ import fs from "node:fs/promises";
3
4
  // @ts-ignore
4
5
  import { LocalStorage } from "node-localstorage";
5
6
  // @ts-ignore
6
7
  import appRoot from "app-root-path";
7
- import { mkdirp } from "mkdirp";
8
8
  export const kvsLocalStorage = async (options) => {
9
9
  const defaultCacheDir = path.join(appRoot.toString(), ".cache");
10
10
  if (!options.storeFilePath) {
11
- await mkdirp(defaultCacheDir);
11
+ await fs.mkdir(defaultCacheDir, {
12
+ recursive: true
13
+ });
12
14
  }
13
15
  const saveFilePath = options.storeFilePath
14
16
  ? options.storeFilePath
15
17
  : path.join(defaultCacheDir, "kvs-node-localstorage");
18
+ const storeQuota = options.storeQuota ? options.storeQuota : 5 * 1024 * 1024;
16
19
  return kvsStorage({
17
20
  ...options,
18
- storage: new LocalStorage(saveFilePath)
21
+ storage: new LocalStorage(saveFilePath, storeQuota)
19
22
  });
20
23
  };
21
24
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAyB,UAAU,EAAE,MAAM,cAAc,CAAC;AAEjE,aAAa;AACb,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,aAAa;AACb,OAAO,OAAO,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAUhC,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAChC,OAAuC,EACZ,EAAE;IAC7B,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,QAAQ,CAAC,CAAC;IAChE,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE;QACxB,MAAM,MAAM,CAAC,eAAe,CAAC,CAAC;KACjC;IACD,MAAM,YAAY,GAAG,OAAO,CAAC,aAAa;QACtC,CAAC,CAAC,OAAO,CAAC,aAAa;QACvB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,uBAAuB,CAAC,CAAC;IAC1D,OAAO,UAAU,CAAC;QACd,GAAG,OAAO;QACV,OAAO,EAAE,IAAI,YAAY,CAAC,YAAY,CAAC;KAC1C,CAAC,CAAC;AACP,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAyB,UAAU,EAAE,MAAM,cAAc,CAAC;AAEjE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,aAAa;AACb,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,aAAa;AACb,OAAO,OAAO,MAAM,eAAe,CAAC;AAWpC,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAChC,OAAuC,EACZ,EAAE;IAC7B,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,QAAQ,CAAC,CAAC;IAChE,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;QACzB,MAAM,EAAE,CAAC,KAAK,CAAC,eAAe,EAAE;YAC5B,SAAS,EAAE,IAAI;SAClB,CAAC,CAAC;IACP,CAAC;IACD,MAAM,YAAY,GAAG,OAAO,CAAC,aAAa;QACtC,CAAC,CAAC,OAAO,CAAC,aAAa;QACvB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,uBAAuB,CAAC,CAAC;IAC1D,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;IAC7E,OAAO,UAAU,CAAC;QACd,GAAG,OAAO;QACV,OAAO,EAAE,IAAI,YAAY,CAAC,YAAY,EAAE,UAAU,CAAC;KACtD,CAAC,CAAC;AACP,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,67 +1,66 @@
1
1
  {
2
- "name": "@kvs/node-localstorage",
3
- "version": "2.1.4",
4
- "description": "Node.js localstorage for KVS.",
5
- "keywords": [
6
- "kvs",
7
- "browser",
8
- "localstorage"
9
- ],
10
- "homepage": "https://github.com/azu/kvs/tree/master/packages/node-localstorage/",
11
- "bugs": {
12
- "url": "https://github.com/azu/kvs/issues"
13
- },
14
- "repository": {
15
- "type": "git",
16
- "url": "https://github.com/azu/kvs.git"
17
- },
18
- "license": "MIT",
19
- "author": "azu",
20
- "sideEffects": false,
21
- "main": "lib/index.js",
22
- "module": "module/index.js",
23
- "types": "lib/index.d.ts",
24
- "directories": {
25
- "lib": "lib",
26
- "test": "test"
27
- },
28
- "files": [
29
- "bin/",
30
- "lib/",
31
- "module"
32
- ],
33
- "scripts": {
34
- "build": "tsc -p . && tsc --project ./tsconfig.module.json",
35
- "clean": "rimraf lib/ module/",
36
- "prettier": "prettier --write \"**/*.{js,jsx,ts,tsx,css}\"",
37
- "prepublishOnly": "npm run clean && npm run build",
38
- "test": "mocha \"test/**/*.ts\"",
39
- "watch": "tsc -p . --watch"
40
- },
41
- "prettier": {
42
- "printWidth": 120,
43
- "singleQuote": false,
44
- "tabWidth": 4,
45
- "trailingComma": "none"
46
- },
47
- "dependencies": {
48
- "@kvs/storage": "^2.1.4",
49
- "app-root-path": "^3.1.0",
50
- "mkdirp": "^3.0.1",
51
- "node-localstorage": "^2.1.6"
52
- },
53
- "devDependencies": {
54
- "@kvs/common-test-case": "^2.1.4",
55
- "@types/mocha": "^10.0.1",
56
- "@types/node": "^20.4.2",
57
- "mocha": "^10.2.0",
58
- "prettier": "^3.0.0",
59
- "rimraf": "^5.0.1",
60
- "ts-loader": "^9.4.4",
61
- "typescript": "^5.1.6"
62
- },
63
- "publishConfig": {
64
- "access": "public"
65
- },
66
- "gitHead": "d7a5ac9d3c859cceaa75711916bc6bb4e6cd61be"
2
+ "name": "@kvs/node-localstorage",
3
+ "version": "2.2.0",
4
+ "description": "Node.js localstorage for KVS.",
5
+ "keywords": [
6
+ "kvs",
7
+ "browser",
8
+ "localstorage"
9
+ ],
10
+ "homepage": "https://github.com/azu/kvs/tree/master/packages/node-localstorage/",
11
+ "bugs": {
12
+ "url": "https://github.com/azu/kvs/issues"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/azu/kvs.git"
17
+ },
18
+ "license": "MIT",
19
+ "author": "azu",
20
+ "sideEffects": false,
21
+ "main": "lib/index.js",
22
+ "module": "module/index.js",
23
+ "types": "lib/index.d.ts",
24
+ "directories": {
25
+ "lib": "lib",
26
+ "test": "test"
27
+ },
28
+ "files": [
29
+ "bin/",
30
+ "lib/",
31
+ "module"
32
+ ],
33
+ "scripts": {
34
+ "build": "tsc -p . && tsc --project ./tsconfig.module.json",
35
+ "clean": "rimraf lib/ module/",
36
+ "prettier": "prettier --write \"**/*.{js,jsx,ts,tsx,css}\"",
37
+ "prepublishOnly": "npm run clean && npm run build",
38
+ "test": "mocha \"test/**/*.ts\"",
39
+ "watch": "tsc -p . --watch"
40
+ },
41
+ "prettier": {
42
+ "printWidth": 120,
43
+ "singleQuote": false,
44
+ "tabWidth": 4,
45
+ "trailingComma": "none"
46
+ },
47
+ "dependencies": {
48
+ "@kvs/storage": "^2.1.4",
49
+ "app-root-path": "^3.1.0",
50
+ "node-localstorage": "^2.1.6"
51
+ },
52
+ "devDependencies": {
53
+ "@kvs/common-test-case": "^2.1.4",
54
+ "@types/mocha": "^10.0.1",
55
+ "@types/node": "^20.4.2",
56
+ "mocha": "^10.2.0",
57
+ "prettier": "^3.0.0",
58
+ "rimraf": "^5.0.1",
59
+ "ts-loader": "^9.4.4",
60
+ "typescript": "^5.1.6"
61
+ },
62
+ "publishConfig": {
63
+ "access": "public"
64
+ },
65
+ "gitHead": "b7d5841d3a745e4645cfd3e1a9f06b4d3e6730e0"
67
66
  }