Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #216 from vbortone/master

store.js Type Definitions
  • Loading branch information...
commit ce7f8cb859242f545b95246d3732860d348e1b68 2 parents e2ee972 + 77b4830
@borisyankov authored
Showing with 43 additions and 0 deletions.
  1. +23 −0 storejs/storejs-tests.ts
  2. +20 −0 storejs/storejs.d.ts
View
23 storejs/storejs-tests.ts
@@ -0,0 +1,23 @@
+// Tests for storagejs.d.ts
+///<reference path="storejs.d.ts" />
+
+// Store 'marcus' at 'username'
+store.set('username', 'marcus');
+
+// Get 'username'
+var userName:any = store.get('username');
+
+var all: Object = store.getAll();
+
+// Remove 'username'
+store.remove('username');
+
+// Clear all keys
+store.clear();
+
+// Store an object literal - store.js uses JSON.stringify under the hood
+store.set('user', { name: 'marcus', likes: 'javascript' });
+
+// Get the stored object - store.js uses JSON.parse under the hood
+var user: any = store.get('user');
+alert(user.name + ' likes ' + user.likes);
View
20 storejs/storejs.d.ts
@@ -0,0 +1,20 @@
+// Type definitions for store.js
+// store.js exposes a simple API for cross browser local storage
+// Project: https://github.com/marcuswestin/store.js/
+// Definitions by: Vincent Bortone <https://github.com/vbortone/>
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+interface StoreJSStatic {
+ set(key: string, value: any): any;
+ get(key: string): any;
+ remove(key: string): void;
+ clear(): void;
+ enabled: bool;
+ disabled: bool;
+ transact(key: string, defaultValue: any, transactionFn?: (val: any) => void): void;
+ getAll(): any;
+ serialize(value: any): string;
+ deserialize(value: string): any;
+}
+
+declare var store: StoreJSStatic;
Please sign in to comment.
Something went wrong with that request. Please try again.