1 |
|
2 | import { type OnDidChangeCallback, type Options, type Unsubscribe, type OnDidAnyChangeCallback } from './types.js';
|
3 | export default class Conf<T extends Record<string, any> = Record<string, unknown>> implements Iterable<[keyof T, T[keyof T]]> {
|
4 | #private;
|
5 | readonly path: string;
|
6 | readonly events: EventTarget;
|
7 | constructor(partialOptions?: Readonly<Partial<Options<T>>>);
|
8 | /**
|
9 | Get an item.
|
10 |
|
11 | @param key - The key of the item to get.
|
12 | @param defaultValue - The default value if the item does not exist.
|
13 | */
|
14 | get<Key extends keyof T>(key: Key): T[Key];
|
15 | get<Key extends keyof T>(key: Key, defaultValue: Required<T>[Key]): Required<T>[Key];
|
16 | get<Key extends string, Value = unknown>(key: Exclude<Key, keyof T>, defaultValue?: Value): Value;
|
17 | /**
|
18 | Set an item or multiple items at once.
|
19 |
|
20 | @param {key|object} - You can use [dot-notation](https:
|
21 | @param value - Must be JSON serializable. Trying to set the type `undefined`, `function`, or `symbol` will result in a `TypeError`.
|
22 | */
|
23 | set<Key extends keyof T>(key: Key, value?: T[Key]): void;
|
24 | set(key: string, value: unknown): void;
|
25 | set(object: Partial<T>): void;
|
26 | |
27 |
|
28 |
|
29 |
|
30 |
|
31 | has<Key extends keyof T>(key: Key | string): boolean;
|
32 | |
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 | reset<Key extends keyof T>(...keys: Key[]): void;
|
40 | |
41 |
|
42 |
|
43 |
|
44 |
|
45 | delete<Key extends keyof T>(key: Key): void;
|
46 | |
47 |
|
48 |
|
49 |
|
50 |
|
51 | clear(): void;
|
52 | |
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 | onDidChange<Key extends keyof T>(key: Key, callback: OnDidChangeCallback<T[Key]>): Unsubscribe;
|
60 | |
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 | onDidAnyChange(callback: OnDidAnyChangeCallback<T>): Unsubscribe;
|
67 | get size(): number;
|
68 | get store(): T;
|
69 | set store(value: T);
|
70 | [Symbol.iterator](): IterableIterator<[keyof T, T[keyof T]]>;
|
71 | private _encryptData;
|
72 | private _handleChange;
|
73 | private readonly _deserialize;
|
74 | private readonly _serialize;
|
75 | private _validate;
|
76 | private _ensureDirectory;
|
77 | private _write;
|
78 | private _watch;
|
79 | private _migrate;
|
80 | private _containsReservedKey;
|
81 | private _isVersionInRangeFormat;
|
82 | private _shouldPerformMigration;
|
83 | private _get;
|
84 | private _set;
|
85 | }
|
86 | export type { Options, Schema } from './types.js';
|