diff --git a/lockr/lockr.d.ts b/lockr/lockr.d.ts new file mode 100644 index 0000000000..eba2b85609 --- /dev/null +++ b/lockr/lockr.d.ts @@ -0,0 +1,108 @@ +// Type definitions for lockr 0.8.3 +// Project: https://github.com/tsironis/lockr +// Definitions by: Dror Weiss +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare var Lockr: lockr.ILockrStatic; + +declare module lockr { + interface ILockrStatic { + + /** + * Set a key to a particular value or a hash object (Object or Array) under a hash key. + * @param key + * @param value + */ + set(key: string, value: string | number | Object); + + /** + * Set a key to a particular value or a hash object (Object or Array) under a hash key. + * @param key + * @param value + */ + set(key: string, value: Array); + + /** + * Removes all data associated to a key. + * @param key + */ + rm(key: string); + + /** + * Returns the saved value for given key, even if the saved value is hash object. + * If value is null or undefined it returns a default value. + * @param key + * @param defaultValue + */ + get(key: string, defaultValue?: T): T; + + /** + * Adds a unique value to a particular set under a hash key. + * @param key + * @param value + */ + sadd(key: string, value: string | number | Object); + + /** + * Adds a unique value to a particular set under a hash key. + * @param key + * @param value + */ + sadd(key: string, value: Array); + + /** + * Returns the values of a particular set under a hash key. + * @param key + */ + smembers(key: string): (string | number | Object)[]; + + /** + * Returns the values of a particular set under a hash key. + * @param key + */ + smembers(key: string): Array; + + /** + * Returns whether the value exists in a particular set under a hash key. + * @param key + * @param value + */ + sismember(key: string, value: string | number | Object): boolean; + + /** + * Returns whether the value exists in a particular set under a hash key. + * @param key + * @param value + */ + sismember(key: string, value: Array): boolean; + + /** + * Removes a value from a particular set under a hash key. + * @param key + * @param value + */ + srem(key: string, value: string | number | Object); + + /** + * Removes a value from a particular set under a hash key. + * @param key + * @param value + */ + srem(key: string, value: Array); + + /** + * Returns all saved values & objects, in an Array. + */ + getAll(): (string | number | Object)[]; + + /** + * Empties localStorage. + */ + flush(); + } +} + + +declare module "lockr" { + export = Lockr; +}