mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-20 12:00:53 +08:00
Merge pull request #4376 from YuichiNukiyama/localforage
Update localForage to 1.2
This commit is contained in:
@@ -1,34 +1,68 @@
|
||||
/// <reference path="localForage.d.ts" />
|
||||
/// <reference path="localForage.d.ts" />
|
||||
|
||||
declare var localForage: lf.ILocalForage<string>
|
||||
declare var callback: lf.ICallback<string>
|
||||
declare var promise: lf.IPromise<string>
|
||||
declare var localForage: lf.ILocalForage<string>;
|
||||
declare var callback: lf.ICallback<string>;
|
||||
declare var iterateCallback: lf.IIterateCallback<string>;
|
||||
declare var errorCallback: lf.IErrorCallback;
|
||||
declare var keyCallback: lf.IKeyCallback;
|
||||
declare var keysCallback: lf.IKeysCallback;
|
||||
declare var numberCallback: lf.INumberCallback;
|
||||
declare var promise: lf.IPromise<string>;
|
||||
|
||||
() => {
|
||||
localForage.clear()
|
||||
localForage.length
|
||||
localForage.key(0)
|
||||
localForage.clear((err: any) => {
|
||||
var newError: any = err;
|
||||
});
|
||||
|
||||
localForage.iterate((str: string, key: string, num: number) => {
|
||||
var newStr: string = str;
|
||||
var newKey: string = key;
|
||||
var newNum: number = num;
|
||||
});
|
||||
|
||||
localForage.length((err: any, num: number) => {
|
||||
var newError: any = err;
|
||||
var newNumber: number = num;
|
||||
});
|
||||
|
||||
localForage.key(0,(err: any, value: string) => {
|
||||
var newError: any = err;
|
||||
var newValue: string = value;
|
||||
});
|
||||
|
||||
localForage.keys((err: any, keys: Array<string>) => {
|
||||
var newError: any = err;
|
||||
var newArray: Array<string> = keys;
|
||||
});
|
||||
|
||||
localForage.getItem("key",(err: any, str: string) => {
|
||||
var newError: any = err;
|
||||
var newStr: string = str
|
||||
});
|
||||
|
||||
localForage.getItem("key").then((err: any, str: string) => {
|
||||
var newError: any = err;
|
||||
var newStr: string = str
|
||||
});
|
||||
|
||||
localForage.getItem("key", (str: string) => {
|
||||
var newStr: string = str
|
||||
})
|
||||
localForage.getItem("key").then((str: string) => {
|
||||
var newStr: string = str
|
||||
})
|
||||
localForage.setItem("key", "value",(err: any, str: string) => {
|
||||
var newError: any = err;
|
||||
var newStr: string = str
|
||||
});
|
||||
|
||||
localForage.setItem("key", "value").then((err: any, str: string) => {
|
||||
var newError: any = err;
|
||||
var newStr: string = str;
|
||||
});
|
||||
|
||||
localForage.setItem("key", "value", (str: string) => {
|
||||
var newStr: string = str
|
||||
})
|
||||
localForage.setItem("key", "value").then((str: string) => {
|
||||
var newStr: string = str
|
||||
})
|
||||
localForage.removeItem("key",(err: any) => {
|
||||
var newError: any = err;
|
||||
});
|
||||
|
||||
localForage.removeItem("key").then((err: any, str: string) => {
|
||||
var newError: any = err;
|
||||
var newStr: string = str
|
||||
});
|
||||
|
||||
localForage.removeItem("key", (str: string) => {
|
||||
var newStr: string = str
|
||||
})
|
||||
localForage.removeItem("key").then((str: string) => {
|
||||
var newStr: string = str
|
||||
})
|
||||
|
||||
promise.then(callback)
|
||||
promise.then(callback);
|
||||
}
|
||||
|
||||
Vendored
+54
-7
@@ -1,23 +1,70 @@
|
||||
// Type definitions for Mozilla's localForage
|
||||
// Type definitions for Mozilla's localForage
|
||||
// Project: https://github.com/mozilla/localforage
|
||||
// Definitions by: david pichsenmeister <https://github.com/3x14159265>
|
||||
// Definitions by: yuichi david pichsenmeister <https://github.com/3x14159265>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module lf {
|
||||
interface ILocalForage<T> {
|
||||
clear(): void
|
||||
key(index: number): T
|
||||
length: number
|
||||
/**
|
||||
* Removes every key from the database, returning it to a blank slate.
|
||||
*/
|
||||
clear(callback: IErrorCallback): void
|
||||
/**
|
||||
* Iterate over all value/key pairs in datastore.
|
||||
*/
|
||||
iterate(iterateCallback: IIterateCallback<T>): void
|
||||
/**
|
||||
* Get the name of a key based on its ID.
|
||||
*/
|
||||
key(keyIndex: number, callback: IKeyCallback): void
|
||||
/**
|
||||
* Get the list of all keys in the datastore.
|
||||
*/
|
||||
keys(callback: IKeysCallback): void;
|
||||
/**
|
||||
* Gets the number of keys in the offline store (i.e. its “length”).
|
||||
*/
|
||||
length(callback: INumberCallback): void
|
||||
/**
|
||||
* Gets an item from the storage library and supplies the result to a callback.
|
||||
* If the key does not exist, getItem() will return null.
|
||||
*/
|
||||
getItem(key: string, callback: ICallback<T>): void
|
||||
getItem(key: string): IPromise<T>
|
||||
/**
|
||||
* Saves data to an offline store.
|
||||
*/
|
||||
setItem(key: string, value: T, callback: ICallback<T>): void
|
||||
setItem(key: string, value: T): IPromise<T>
|
||||
removeItem(key: string, callback: ICallback<T>): void
|
||||
/**
|
||||
* Removes the value of a key from the offline store.
|
||||
*/
|
||||
removeItem(key: string, callback: IErrorCallback): void
|
||||
removeItem(key: string): IPromise<T>
|
||||
}
|
||||
|
||||
interface ICallback<T> {
|
||||
(data: T): void
|
||||
(err: any, value: T): void
|
||||
}
|
||||
|
||||
interface IIterateCallback<T> {
|
||||
(value: T, key: string, iterationNumber: number): void
|
||||
}
|
||||
|
||||
interface IErrorCallback {
|
||||
(err: any): void
|
||||
}
|
||||
|
||||
interface IKeyCallback {
|
||||
(err: any, keyName: string): void
|
||||
}
|
||||
|
||||
interface IKeysCallback {
|
||||
(err: any, keys: Array<string>): void
|
||||
}
|
||||
|
||||
interface INumberCallback {
|
||||
(err: any, numberOfKeys: number): void
|
||||
}
|
||||
|
||||
interface IPromise<T> {
|
||||
|
||||
Reference in New Issue
Block a user