diff --git a/types/electron-store/index.d.ts b/types/electron-store/index.d.ts index e15a8aa7e7..6a30daa8fc 100644 --- a/types/electron-store/index.d.ts +++ b/types/electron-store/index.d.ts @@ -14,83 +14,87 @@ declare module 'electron-store' { interface JSONArray extends Array {} interface ElectronStoreOptions { - /** - * Default config. - */ - defaults?: T; + /** + * Default data. + */ + defaults?: T; - /** - * Name of the config file (without extension). - */ - name?: string; + /** + * Name of the storage file (without extension). + */ + name?: string; - /** - * Storage file location. *Don't specify this unless absolutely necessary!* - */ - cwd?: string; + /** + * Storage file location. Don't specify this unless absolutely necessary! + */ + cwd?: string; } class ElectronStore implements Iterable<[keyof T, JSONValue]> { - constructor(options?: ElectronStoreOptions); + constructor(options?: ElectronStoreOptions); - /** - * Sets an item. - */ - set(key: K, value: T[K]): void; - set(key: string, value: any): void; + /** + * Set an item. + */ + set(key: K, value: T[K]): void; + set(key: string, value: any): void; - /** - * Sets multiple items at once. - */ - set(object: Pick | T): void; - set(object: JSONObject): void + /** + * Set multiple items at once. + */ + set(object: Pick | T): void; + set(object: JSONObject): void - /** - * Retrieves an item. - */ - get(key: K, defaultValue?: JSONValue): T[K]; - get(key: string, defaultValue?: any): any; + /** + * Get an item or defaultValue if the item does not exist. + */ + get(key: K, defaultValue?: JSONValue): T[K]; + get(key: string, defaultValue?: any): any; - /** - * Checks if an item exists. - */ - has(key: K | string): boolean; + /** + * Check if an item exists. + */ + has(key: K | string): boolean; - /** - * Deletes an item. - */ - delete(key: K | string): void; + /** + * Delete an item. + */ + delete(key: K | string): void; - /** - * Deletes all items. - */ - clear(): void; + /** + * Delete all items. + */ + clear(): void; - /** - * Open the storage file in the user's editor. - */ - openInEditor(): void; + /** + * Watches the given key, calling callback on any changes. When a key is first set oldValue + * will be undefined, and when a key is deleted newValue will be undefined. + */ + onDidChange(key: K, callback: (newValue: T[K], oldValue: T[K]) => void): void; + onDidChange(key: string, callback: (newValue: JSONValue, oldValue: JSONValue) => void): void; - onDidChange(key: K, callback: (newValue: T[K], oldValue: T[K]) => void): void; - onDidChange(key: string, callback: (newValue: JSONValue, oldValue: JSONValue) => void): void; + /** + * Get the item count. + */ + size: number; - /** - * Gets the item count. - */ - size: number; + /** + * Get all the data as an object or replace the current data with an object. + */ + store: T; - /** - * Gets all the config as an object or replace the current config with an object. - */ - store: T; + /** + * Get the path to the storage file. + */ + path: string; - /** - * Gets the path to the config file. - */ - path: string; + /** + * Open the storage file in the user's editor. + */ + openInEditor(): void; - [Symbol.iterator](): Iterator<[keyof T, JSONValue]>; + [Symbol.iterator](): Iterator<[keyof T, JSONValue]>; } export = ElectronStore; -} + }