From bb05b91c9ca3e806ecb0471166a2edcc3b2ec5a1 Mon Sep 17 00:00:00 2001 From: JeremyCBrooks Date: Sun, 13 Apr 2014 11:24:48 -0400 Subject: [PATCH] added definition for jquery total-storage fixed failing test updated CONTRIBUTORS --- CONTRIBUTORS.md | 1 + .../jquery.total-storage-tests.ts | 21 ++++++ .../jquery.total-storage.d.ts | 64 +++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 jquery.total-storage/jquery.total-storage-tests.ts create mode 100644 jquery.total-storage/jquery.total-storage.d.ts diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index d68e3061cc..dd09cf2830 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -151,6 +151,7 @@ All definitions files include a header with the author and editors, so at some p * [jQuery.TinyCarousel](http://baijs.nl/tinycarousel/) (by [Christiaan Rakowski](https://github.com/csrakowski)) * [jQuery.TinyScrollbar](http://baijs.nl/tinyscrollbar/) (by [Christiaan Rakowski](https://github.com/csrakowski)) * [jQuery.tooltipster](https://github.com/iamceege/tooltipster) (by [Patrick Magee](https://github.com/pjmagee)) +* [jQuery.total-storage](https://github.com/Upstatement/jquery-total-storage) (by [Jeremy Brooks](https://github.com/JeremyCBrooks/)) * [jQuery.Transit](http://ricostacruz.com/jquery.transit/) (by [MrBigDog2U](https://github.com/MrBigDog2U)) * [jQuery.Validation](http://bassistance.de/jquery-plugins/jquery-plugin-validation/) (by [Boris Yankov](https://github.com/borisyankov)) * [jQuery.Watermark](http://jquery-watermark.googlecode.com) (by [Anwar Javed](https://github.com/anwarjaved)) diff --git a/jquery.total-storage/jquery.total-storage-tests.ts b/jquery.total-storage/jquery.total-storage-tests.ts new file mode 100644 index 0000000000..0ba3700eee --- /dev/null +++ b/jquery.total-storage/jquery.total-storage-tests.ts @@ -0,0 +1,21 @@ +// Type definitions for jQueryTotalStorage 1.1.2 +// Project: https://github.com/Upstatement/jquery-total-storage +// Definitions by: Jeremy Brooks +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +//direct call +$.totalStorage("test_key1", "test_value"); +var val1:string = $.totalStorage("test_key"); + +//set/get +$.totalStorage.setItem("test_key2", 123); +var val2:number = $.totalStorage.getItem("test_key2"); + +//get all items +var list = $.totalStorage.getAll(); + +//delete item +var deleted = $.totalStorage.deleteItem("test_key1"); \ No newline at end of file diff --git a/jquery.total-storage/jquery.total-storage.d.ts b/jquery.total-storage/jquery.total-storage.d.ts new file mode 100644 index 0000000000..8bfed0a4d3 --- /dev/null +++ b/jquery.total-storage/jquery.total-storage.d.ts @@ -0,0 +1,64 @@ +// Type definitions for jQueryTotalStorage 1.1.2 +// Project: https://github.com/Upstatement/jquery-total-storage +// Definitions by: Jeremy Brooks +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +/** +* @desc Set the value of a key to a string +* @example $.totalStorage('the_key', 'the_value'); +* @desc Set the value of a key to a number +* @example $.totalStorage('the_key', 800.2); +* @desc Set the value of a key to a complex Array +* @example var myArray = new Array(); +* myArray.push({name:'Jared', company:'Upstatement', zip:63124}); +* myArray.push({name:'McGruff', company:'Police', zip:60652}; +* $.totalStorage('people', myArray); +* //to return: +* $.totalStorage('people'); +* +*/ + +interface JQueryTotalStorage { + + /** + * @desc Set or get a key's value + * @param key Key to set. + * @param value Value to set for key. If ommited, current value for key is returned. + * @param options Not implemented. + */ + (key: string, value?: any, options?: JQueryTotalStorageOptions): any; + + /** + * @desc Set a key's value + * @param key Key to set. + * @param value Value to set for key. + */ + setItem(key: string, value: any): any; + + /** + * @desc Get a key's value + * @param key Key to get. + */ + getItem(key: string): any; + + /** + * @desc Get all set values + */ + getAll(): any[]; + + /** + * @desc Delete item by key + * @param key Key of item to delete + */ + deleteItem(key: string): boolean; +} + +interface JQueryTotalStorageOptions { + //not implemented... +} + +interface JQueryStatic { + totalStorage: JQueryTotalStorage; +} \ No newline at end of file