Update comments using official package docs

This commit is contained in:
Jakub Synowiec
2018-02-17 16:38:37 +01:00
parent 5ff2de3ce7
commit 60f12b7641

View File

@@ -14,83 +14,87 @@ declare module 'electron-store' {
interface JSONArray extends Array<JSONValue> {}
interface ElectronStoreOptions<T = JSONObject> {
/**
* 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<T> implements Iterable<[keyof T, JSONValue]> {
constructor(options?: ElectronStoreOptions<T>);
constructor(options?: ElectronStoreOptions<T>);
/**
* Sets an item.
*/
set<K extends keyof T>(key: K, value: T[K]): void;
set(key: string, value: any): void;
/**
* Set an item.
*/
set<K extends keyof T>(key: K, value: T[K]): void;
set(key: string, value: any): void;
/**
* Sets multiple items at once.
*/
set<K extends keyof T>(object: Pick<T, K> | T): void;
set(object: JSONObject): void
/**
* Set multiple items at once.
*/
set<K extends keyof T>(object: Pick<T, K> | T): void;
set(object: JSONObject): void
/**
* Retrieves an item.
*/
get<K extends keyof T>(key: K, defaultValue?: JSONValue): T[K];
get(key: string, defaultValue?: any): any;
/**
* Get an item or defaultValue if the item does not exist.
*/
get<K extends keyof T>(key: K, defaultValue?: JSONValue): T[K];
get(key: string, defaultValue?: any): any;
/**
* Checks if an item exists.
*/
has<K extends keyof T>(key: K | string): boolean;
/**
* Check if an item exists.
*/
has<K extends keyof T>(key: K | string): boolean;
/**
* Deletes an item.
*/
delete<K extends keyof T>(key: K | string): void;
/**
* Delete an item.
*/
delete<K extends keyof T>(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<K extends keyof T>(key: K, callback: (newValue: T[K], oldValue: T[K]) => void): void;
onDidChange(key: string, callback: (newValue: JSONValue, oldValue: JSONValue) => void): void;
onDidChange<K extends keyof T>(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;
}
}