mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
changes:
- added default export for localforage module (for style es6 imports) - added createInstance method - some minor doc - changed driver to accept also a string (to use their property e.g. localforage.LOCALSTORAGE - added some minor tests
This commit is contained in:
parent
f0fee739c3
commit
c192586e9e
@ -52,4 +52,14 @@ declare var localForage: LocalForage;
|
||||
|
||||
localForage.removeItem("key").then(() => {
|
||||
});
|
||||
|
||||
var config = localForage.config({
|
||||
name: "testyo",
|
||||
driver: localForage.LOCALSTORAGE
|
||||
});
|
||||
|
||||
var store = localForage.createInstance({
|
||||
name: "da instance",
|
||||
driver: localForage.LOCALSTORAGE
|
||||
});
|
||||
}
|
||||
19
localForage/localForage.d.ts
vendored
19
localForage/localForage.d.ts
vendored
@ -6,7 +6,7 @@
|
||||
/// <reference path="../es6-promise/es6-promise.d.ts" />
|
||||
|
||||
interface LocalForageOptions {
|
||||
driver?: LocalForageDriver | LocalForageDriver[];
|
||||
driver?: string | LocalForageDriver | LocalForageDriver[];
|
||||
|
||||
name?: string;
|
||||
|
||||
@ -46,9 +46,19 @@ interface LocalForage {
|
||||
WEBSQL: string;
|
||||
INDEXEDDB: string;
|
||||
|
||||
config(options: LocalForageOptions): void;
|
||||
/**
|
||||
* Set and persist localForage options. This must be called before any other calls to localForage are made, but can be called after localForage is loaded.
|
||||
* If you set any config values with this method they will persist after driver changes, so you can call config() then setDriver()
|
||||
* @param {ILocalForageConfig} options?
|
||||
*/
|
||||
config(options: LocalForageOptions): boolean;
|
||||
createInstance(options: LocalForageOptions): LocalForage;
|
||||
|
||||
driver(): LocalForageDriver;
|
||||
/**
|
||||
* Force usage of a particular driver or drivers, if available.
|
||||
* @param {string} driver
|
||||
*/
|
||||
setDriver(driver: string | string[]): Promise<void>;
|
||||
setDriver(driver: string | string[], callback: () => void, errorCallback: (error: any) => void): void;
|
||||
defineDriver(driver: LocalForageDriver): Promise<void>;
|
||||
@ -79,3 +89,8 @@ interface LocalForage {
|
||||
iterate(iteratee: (value: any, key: string, iterationNumber: number) => any,
|
||||
callback: (err: any, result: any) => void): void;
|
||||
}
|
||||
|
||||
declare module "localforage" {
|
||||
var localforage: LocalForage;
|
||||
export default localforage;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user