diff --git a/types/angular-local-storage/index.d.ts b/types/angular-local-storage/index.d.ts index a3bd35d048..f403126d7a 100644 --- a/types/angular-local-storage/index.d.ts +++ b/types/angular-local-storage/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for angular-local-storage v0.1.5 +// Type definitions for angular-local-storage v0.1.6 // Project: https://github.com/grevory/angular-local-storage // Definitions by: Ken Fukuyama // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -60,19 +60,19 @@ declare module 'angular' { */ set(key: string, val: string): boolean; /** - * Directly adds a value to cookies with an expiration. - * Note: Typically used as a fallback if local storage is not supported. - * Returns: Boolean - * @param key - * @param val - * @param daysToExpiry - */ + * Directly adds a value to cookies with an expiration. + * Note: Typically used as a fallback if local storage is not supported. + * Returns: Boolean + * @param key + * @param val + * @param daysToExpiry + */ set(key: string, val: string, daysToExpiry: number): boolean; /** - * Directly get a value from a cookie. - * Returns: value from local storage - * @param key - */ + * Directly get a value from a cookie. + * Returns: value from local storage + * @param key + */ get(key: string): string; /** * Remove directly value from a cookie. @@ -84,8 +84,9 @@ declare module 'angular' { * Remove all data for this app from cookie. */ clearAll(): any; - } + + type StorageType = 'localStorage' | 'sessionStorage'; interface ILocalStorageService { /** @@ -104,19 +105,19 @@ declare module 'angular' { * @param key * @param value */ - set(key: string, value: T): boolean; + set(key: string, value: T, storageType?: StorageType): boolean; /** * Directly get a value from local storage. * If local storage is not supported, use cookies instead. * Returns: value from local storage * @param key */ - get(key: string): T; + get(key: string, storageType?: StorageType): T; /** * Return array of keys for local storage, ignore keys that not owned. * Returns: value from local storage */ - keys(): string[]; + keys(storageType?: StorageType): string[]; /** * Remove an item from local storage by key. * If local storage is not supported, use cookies instead. @@ -131,7 +132,7 @@ declare module 'angular' { * Returns: Boolean * @param regularExpression */ - clearAll(regularExpression?: RegExp): boolean; + clearAll(regularExpression?: RegExp, storageType?: StorageType): boolean; /** * Bind $scope key to localStorageService. * Usage: localStorageService.bind(scope, property, value[optional], key[optional]) @@ -141,7 +142,7 @@ declare module 'angular' { * @param value optional * @param key The corresponding key used in local storage */ - bind(scope: angular.IScope, property: string, value?: any, key?: string): Function; + bind(scope: angular.IScope, property: string, value?: any, key?: string, storageType?: StorageType): Function; /** * Return the derive key * Returns String @@ -152,7 +153,7 @@ declare module 'angular' { * Return localStorageService.length, ignore keys that not owned. * Returns Number */ - length(): number; + length(storageType?: StorageType): number; /** * Deal with browser's cookies directly. */