diff --git a/README.md b/README.md index 2628d4b8f9..1ad14a26c8 100755 --- a/README.md +++ b/README.md @@ -181,6 +181,7 @@ List of Definitions * [Levelup](https://github.com/rvagg/node-levelup) (by [Bret Little](https://github.com/blittle)) * [linq.js](http://linqjs.codeplex.com/) (by [Marcin Najder](https://github.com/marcinnajder)) * [Livestamp.js](https://github.com/mattbradley/livestampjs) (by [Vincent Bortone](https://github.com/vbortone)) +* [localForage](https://github.com/mozilla/localForage) (by [david pichsenmeister](https://github.com/3x14159265)) * [Lodash](http://lodash.com/) (by [Brian Zengel](https://github.com/bczengel)) * [Logg](https://github.com/dpup/node-logg) (by [Bret Little](https://github.com/blittle)) * [Marked](https://github.com/chjj/marked) (by [William Orr](https://github.com/worr)) diff --git a/localForage/localForage-tests.ts b/localForage/localForage-tests.ts new file mode 100644 index 0000000000..f1a416dcf7 --- /dev/null +++ b/localForage/localForage-tests.ts @@ -0,0 +1,34 @@ +/// + +declare var localForage: lf.ILocalForage +declare var callback: lf.ICallback +declare var promise: lf.IPromise + +() => { + localForage.clear() + localForage.length + localForage.key(0) + + localForage.getItem("key", (str: string) => { + var newStr: string = str + }) + localForage.getItem("key").then((str: string) => { + 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", (str: string) => { + var newStr: string = str + }) + localForage.removeItem("key").then((str: string) => { + var newStr: string = str + }) + + promise.then(callback) +} diff --git a/localForage/localForage.d.ts b/localForage/localForage.d.ts new file mode 100644 index 0000000000..c3d0371d00 --- /dev/null +++ b/localForage/localForage.d.ts @@ -0,0 +1,26 @@ +// Type definitions for Mozilla's localForage +// Project: https://github.com/mozilla/localforage +// Definitions by: david pichsenmeister +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module lf { + interface ILocalForage { + clear(): void + key(index: number): T + length: number + getItem(key: string, callback: ICallback): void + getItem(key: string): IPromise + setItem(key: string, value: T, callback: ICallback): void + setItem(key: string, value: T): IPromise + removeItem(key: string, callback: ICallback): void + removeItem(key: string): IPromise + } + + interface ICallback { + (data: T): void + } + + interface IPromise { + then(callback: ICallback): void + } +} \ No newline at end of file