mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-07 00:07:07 +00:00
Add types for electron-store 1.2
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import ElectronStore = require('electron-store');
|
||||
|
||||
new ElectronStore({
|
||||
defaults: {}
|
||||
});
|
||||
|
||||
new ElectronStore({
|
||||
name: 'myConfiguration',
|
||||
cwd: 'unicorn'
|
||||
});
|
||||
|
||||
const electronStore = new ElectronStore();
|
||||
|
||||
electronStore.set('foo', 'bar');
|
||||
electronStore.set({
|
||||
foo: 'bar',
|
||||
foo2: 'bar2'
|
||||
});
|
||||
electronStore.delete('foo');
|
||||
electronStore.get('foo');
|
||||
electronStore.get('foo', 42);
|
||||
electronStore.has('foo');
|
||||
electronStore.clear();
|
||||
|
||||
electronStore.openInEditor();
|
||||
|
||||
electronStore.size;
|
||||
electronStore.store;
|
||||
|
||||
electronStore.store = {
|
||||
foo: 'bar'
|
||||
};
|
||||
|
||||
electronStore.path;
|
||||
Vendored
+79
@@ -0,0 +1,79 @@
|
||||
// Type definitions for electron-store 1.2
|
||||
// Project: https://github.com/sindresorhus/electron-store
|
||||
// Definitions by: Daniel Perez Alvarez <https://github.com/unindented>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
interface ElectronStoreOptions {
|
||||
/**
|
||||
* Default config.
|
||||
*/
|
||||
defaults?: {};
|
||||
|
||||
/**
|
||||
* Name of the config file (without extension).
|
||||
*/
|
||||
name?: string;
|
||||
|
||||
/**
|
||||
* Storage file location. *Don't specify this unless absolutely necessary!*
|
||||
*/
|
||||
cwd?: string;
|
||||
}
|
||||
|
||||
declare class ElectronStore implements Iterable<[string, string | number | boolean | symbol | {}]> {
|
||||
constructor(options?: ElectronStoreOptions);
|
||||
|
||||
/**
|
||||
* Sets an item.
|
||||
*/
|
||||
set(key: string, value: any): void;
|
||||
|
||||
/**
|
||||
* Sets multiple items at once.
|
||||
*/
|
||||
set(object: {}): void;
|
||||
|
||||
/**
|
||||
* Retrieves an item.
|
||||
*/
|
||||
get(key: string, defaultValue?: any): any;
|
||||
|
||||
/**
|
||||
* Checks if an item exists.
|
||||
*/
|
||||
has(key: string): boolean;
|
||||
|
||||
/**
|
||||
* Deletes an item.
|
||||
*/
|
||||
delete(key: string): void;
|
||||
|
||||
/**
|
||||
* Deletes all items.
|
||||
*/
|
||||
clear(): void;
|
||||
|
||||
/**
|
||||
* Open the storage file in the user's editor.
|
||||
*/
|
||||
openInEditor(): void;
|
||||
|
||||
/**
|
||||
* Gets the item count.
|
||||
*/
|
||||
size: number;
|
||||
|
||||
/**
|
||||
* Gets all the config as an object or replace the current config with an object.
|
||||
*/
|
||||
store: {};
|
||||
|
||||
/**
|
||||
* Gets the path to the config file.
|
||||
*/
|
||||
path: string;
|
||||
|
||||
[Symbol.iterator](): Iterator<[string, string | number | boolean | symbol | {}]>;
|
||||
}
|
||||
|
||||
export = ElectronStore;
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"electron-store-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json" ,
|
||||
"rules": {
|
||||
"no-namespace":false,
|
||||
"object-literal-key-quotes": false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user