diff --git a/jstorage/jstorage-tests.ts b/jstorage/jstorage-tests.ts
index a8bd01af4..e86e9ffd4 100644
--- a/jstorage/jstorage-tests.ts
+++ b/jstorage/jstorage-tests.ts
@@ -1,3 +1,4 @@
+///
///
// Test set first overload
diff --git a/jstorage/jstorage.d.ts b/jstorage/jstorage.d.ts
index 0acc93fbd..8e99a08a7 100644
--- a/jstorage/jstorage.d.ts
+++ b/jstorage/jstorage.d.ts
@@ -3,15 +3,15 @@
// Definitions by: Danil Flores
// Definitions: https://github.com/borisyankov/DefinitelyTyped
-declare module $.jStorage {
+interface JStorageOptions {
+ TTL: number;
+}
- class IStorageOptions {
- TTL: number;
- }
+interface JStorageReadonlyStore {
+ [key: string]: any;
+}
- interface IJStorage {
- [key: string]: any;
- }
+interface JStorageStatic {
/**
* Sets a key's value.
@@ -24,7 +24,7 @@ declare module $.jStorage {
* @param [options.TTL] - optional TTL value
* @return the used value
*/
- function set (key: string, value: TValue, options?: IStorageOptions): TValue;
+ set(key: string, value: TValue, options?: JStorageOptions): TValue;
/**
* Looks up a key in cache
@@ -33,7 +33,7 @@ declare module $.jStorage {
* @param defaultIfNotFound - Default value to return, if key didn't exist.
* @return the key value, default value or null
*/
- function get (key: string, defaultIfNotFound?: TValue): TValue;
+ get (key: string, defaultIfNotFound?: TValue): TValue;
/**
* Deletes a key from cache.
@@ -41,7 +41,7 @@ declare module $.jStorage {
* @param key - Key to delete.
* @return true if key existed or false if it didn't
*/
- function deleteKey(key: string): boolean;
+ deleteKey(key: string): boolean;
/**
* Sets a TTL for a key, or remove it if ttl value is 0 or below
@@ -50,7 +50,7 @@ declare module $.jStorage {
* @param ttl - TTL timeout in milliseconds
* @return true if key existed or false if it didn't
*/
- function setTTL(key: string, ttl: number): boolean;
+ setTTL(key: string, ttl: number): boolean;
/**
* Gets remaining TTL (in milliseconds) for a key or 0 when no TTL has been set
@@ -58,21 +58,21 @@ declare module $.jStorage {
* @param key Key to check
* @return Remaining TTL in milliseconds
*/
- function getTTL(key: string): number;
+ getTTL(key: string): number;
/**
* Deletes everything in cache.
*
* @return Always true
*/
- function flush(): boolean;
+ flush(): boolean;
/**
* Returns a read-only copy of _storage
*
* @return Read-only copy of _storage
*/
- function storageObj(): IJStorage
+ storageObj(): JStorageReadonlyStore
/**
* Returns an index of all used keys as an array
@@ -80,7 +80,7 @@ declare module $.jStorage {
*
* @return Used keys
*/
- function index(): string[];
+ index(): string[];
/**
* How much space in bytes does the storage take?
@@ -88,21 +88,21 @@ declare module $.jStorage {
* @return Storage size in chars (not the same as in bytes,
* since some chars may take several bytes)
*/
- function storageSize(): number;
+ storageSize(): number;
/**
* Which backend is currently in use?
*
* @return Backend name
*/
- function currentBackend(): Storage;
+ currentBackend(): Storage;
/**
* Test if storage is available
*
* @return True if storage can be used
*/
- function storageAvailable(): boolean;
+ storageAvailable(): boolean;
/**
* Register change listeners
@@ -110,7 +110,7 @@ declare module $.jStorage {
* @param key Key name
* @param callback Function to run when the key changes
*/
- function listenKeyChange(key: string, callback: (key: string, value: any) => void ): void;
+ listenKeyChange(key: string, callback: (key: string, value: any) => void ): void;
/**
* Register change listeners
@@ -118,7 +118,7 @@ declare module $.jStorage {
* @param key Key name
* @param callback Function to run when the key changes
*/
- function listenKeyChange(key: string, callback: (key: string, value: TValue) => void ): void;
+ listenKeyChange(key: string, callback: (key: string, value: TValue) => void ): void;
/**
* Remove change listeners
@@ -126,7 +126,7 @@ declare module $.jStorage {
* @param key Key name to unregister listeners against
* @param [callback] If set, unregister the callback, if not - unregister all
*/
- function stopListening(key: string, callback?: Function): void;
+ stopListening(key: string, callback?: Function): void;
/**
* Subscribe to a Publish/Subscribe event stream
@@ -134,7 +134,7 @@ declare module $.jStorage {
* @param channel Channel name
* @param callback Function to run when the something is published to the channel
*/
- function subscribe(channel: string, callback: (channel: string, value: any) => void ): void;
+ subscribe(channel: string, callback: (channel: string, value: any) => void ): void;
/**
* Subscribe to a Publish/Subscribe event stream
@@ -142,7 +142,7 @@ declare module $.jStorage {
* @param channel Channel name
* @param callback Function to run when the something is published to the channel
*/
- function subscribe(channel: string, callback: (channel: string, value: TValue) => void ): void;
+ subscribe(channel: string, callback: (channel: string, value: TValue) => void ): void;
/**
* Publish data to an event stream
@@ -150,10 +150,14 @@ declare module $.jStorage {
* @param channel Channel name
* @param payload Payload to deliver
*/
- function publish(channel: string, payload: any): void;
+ publish(channel: string, payload: any): void;
/**
* Reloads the data from browser storage
*/
- function reInit(): void;
+ reInit(): void;
+}
+
+interface JQueryStatic {
+ jStorage: JStorageStatic;
}
\ No newline at end of file