improved localforage to use default exports (the way it usually should be imported)

This commit is contained in:
Stephen Lautier
2015-09-15 23:23:06 +02:00
parent efa4f9d532
commit 1f88c485c4
2 changed files with 17 additions and 9 deletions
+5 -5
View File
@@ -1,6 +1,6 @@
/// <reference path="localForage.d.ts" />
import * as localForage from "localforage";
import {default as localForage} from "localforage";
() => {
localForage.clear((err: any) => {
@@ -63,13 +63,13 @@ import * as localForage from "localforage";
});
var config = localForage.default.config({
var config = localForage.config({
name: "testyo",
driver: localForage.default.LOCALSTORAGE
driver: localForage.LOCALSTORAGE
});
var store = localForage.default.createInstance({
var store = localForage.createInstance({
name: "da instance",
driver: localForage.default.LOCALSTORAGE
driver: localForage.LOCALSTORAGE
});
}
+12 -4
View File
@@ -7,8 +7,7 @@
declare module lf {
interface ILocalForage {
default: ILocalForageStatic;
interface ILocalForage extends ILocalForageStatic {
/**
* Removes every key from the database, returning it to a blank slate.
*/
@@ -52,9 +51,18 @@ declare module lf {
LOCALSTORAGE: string;
WEBSQL: string;
/**
* 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?: ILocalForageConfig): boolean;
createInstance(options?: ILocalForageConfig): ILocalForage;
defineDriver(driverObject?: any): void;
/**
* Force usage of a particular driver or drivers, if available.
* @param {string} driver
*/
setDriver(driver: string): void;
supports(driverName: string): boolean;
}
@@ -94,6 +102,6 @@ declare module lf {
}
declare module "localforage" {
var tmp: lf.ILocalForage;
export = tmp;
var localforage: lf.ILocalForage;
export default localforage;
}