import { type OnDidChangeCallback, type Options, type Unsubscribe, type OnDidAnyChangeCallback, type DotNotationKeyOf, type DotNotationValueOf, type DefaultsOf, type ArrayItemsOf } from './types.js'; export default class Conf = Record> implements Iterable<[keyof T, T[keyof T]]> { #private; /** Get the path to the config file. */ readonly path: string; /** Dispatches a `change` event on every write of this instance, and when the `watch` option reports a change to the config file. `onDidChange()` and `onDidAnyChange()` listen on it, and you can also listen to it directly. */ readonly events: EventTarget; constructor(partialOptions?: Readonly>>); /** Get an item. @param key - The key of the item to get. @param defaultValue - The default value if the item does not exist. Tip: To get all items, see `.store`. */ get(key: Key): T[Key]; get(key: Key, defaultValue: Exclude): Exclude; get>(key: Key): DotNotationValueOf; get>(key: Key, defaultValue: Exclude, undefined>): Exclude, undefined>; get(key: Exclude>, defaultValue?: Value): Value; /** Set an item or multiple items at once. @param key - The key of the item to set. You can use [dot-notation](https://github.com/sindresorhus/dot-prop) in a key to access nested properties. Or an object of items to set at once, where each key replaces the whole value it names, and with dot notation a key can be a path, such as `{'foo.bar': 1}`. @param value - Must be JSON serializable. Trying to set a value of type `undefined`, `function`, or `symbol` will result in a `TypeError`, and so will a `bigint` unless you use a custom `serialize`. */ set(key: Key, value: Exclude): void; set>(key: Key, value: Exclude, undefined>): void; set(key: Key & (string extends Key ? Key : Exclude>), value: unknown): void; set(object: DefaultsOf): void; /** Check if an item exists. @param key - The key of the item to check. */ has(key: Key): boolean; has>(key: Key): boolean; /** Append an item to an array. If the key doesn't exist, it will be created as an array. If the key exists and is not an array, a `TypeError` will be thrown. The `value` must be JSON serializable. Trying to set a value of type `undefined`, `function`, or `symbol` will result in a `TypeError`, and so will a `bigint` unless you use a custom `serialize`. @param key - The key of the array to append to. You can use [dot-notation](https://github.com/sindresorhus/dot-prop) to access nested properties. @param value - The item to append. Must be JSON serializable. @example ``` config.set('items', [{name: 'foo'}]); config.appendToArray('items', {name: 'bar'}); console.log(config.get('items')); //=> [{name: 'foo'}, {name: 'bar'}] // Creates array if key doesn't exist config.appendToArray('newItems', 'first'); console.log(config.get('newItems')); //=> ['first'] ``` */ appendToArray(key: Key, value: ArrayItemsOf): void; appendToArray>(key: Key, value: ArrayItemsOf>): void; /** Reset items to their default values, as defined by the `defaults` or `schema` option. The `default` values of the `schema` option are not used when `ajvOptions.useDefaults` is `false`. With dot notation, schema defaults below an optional object with no default of its own are unavailable to `reset()` when a parent default omits that object. Include the object in the parent default to reset its descendants individually. @see `clear()` to reset all items. @param keys - The keys of the items to reset. */ reset(...keys: Key[]): void; reset>(...keys: Key[]): void; /** Delete an item. @param key - The key of the item to delete. */ delete(key: Key): void; delete>(key: Key): void; /** Delete all items. This resets known items to their default values, if defined by the `defaults` or `schema` option. The `default` values of the `schema` option are not used when `ajvOptions.useDefaults` is `false`. */ clear(): void; /** Watches the given `key`, calling `callback` on any changes. A change noticed while the config file cannot be read, for example while another process is writing it, is not reported. @param key - The key to watch. @param callback - A callback function that is called on any changes. When a key is first set, `oldValue` will be `undefined`, and when a key is deleted, `newValue` will be `undefined`. @returns A function that unsubscribes when called. @example ``` const unsubscribe = config.onDidChange(key, callback); unsubscribe(); ``` */ onDidChange(key: Key, callback: OnDidChangeCallback): Unsubscribe; onDidChange>(key: Key, callback: OnDidChangeCallback>): Unsubscribe; /** Watches the whole config object, calling `callback` on any changes. A change noticed while the config file cannot be read, for example while another process is writing it, is not reported. `oldValue` and `newValue` will be the config object before and after the change, respectively. You must compare `oldValue` to `newValue` to find out what changed. @param callback - A callback function that is called on any changes. @returns A function that unsubscribes when called. @example ``` const unsubscribe = config.onDidAnyChange(callback); unsubscribe(); ``` */ onDidAnyChange(callback: OnDidAnyChangeCallback): Unsubscribe; /** Get the item count. */ get size(): number; /** Get all the config as an object or replace the current config with an object. @example ``` console.log(config.store); //=> [Object: null prototype] {name: 'John', age: 30} ``` Unlike `set()`, a whole-store write drops a function or a symbol, like `JSON.stringify` does, instead of throwing. A `bigint` still throws, unless you use a custom `serialize`. @example ``` config.store = { hello: 'world' }; ``` */ get store(): T; set store(value: T); [Symbol.iterator](): IterableIterator<[keyof T, T[keyof T]]>; /** Close the file watcher if one exists. This is useful in tests to prevent the process from hanging. */ _closeWatcher(): void; } export type { Options, Schema } from './types.js';