1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.HAPStorage = void 0;
|
4 | const tslib_1 = require("tslib");
|
5 |
|
6 |
|
7 | const node_persist_1 = tslib_1.__importDefault(require("node-persist"));
|
8 |
|
9 |
|
10 |
|
11 | class HAPStorage {
|
12 | static INSTANCE = new HAPStorage();
|
13 | localStore;
|
14 | customStoragePath;
|
15 | static storage() {
|
16 | return this.INSTANCE.storage();
|
17 | }
|
18 | static setCustomStoragePath(path) {
|
19 | this.INSTANCE.setCustomStoragePath(path);
|
20 | }
|
21 | storage() {
|
22 | if (!this.localStore) {
|
23 | this.localStore = node_persist_1.default.create();
|
24 | if (this.customStoragePath) {
|
25 | this.localStore.initSync({
|
26 | dir: this.customStoragePath,
|
27 | });
|
28 | }
|
29 | else {
|
30 | this.localStore.initSync();
|
31 | }
|
32 | }
|
33 | return this.localStore;
|
34 | }
|
35 | setCustomStoragePath(path) {
|
36 | if (this.localStore) {
|
37 | throw new Error("Cannot change storage path after it has already been initialized!");
|
38 | }
|
39 | this.customStoragePath = path;
|
40 | }
|
41 | }
|
42 | exports.HAPStorage = HAPStorage;
|
43 |
|
\ | No newline at end of file |