[angular-local-storage] updates definition to reflect latest changes (#16047)

* updates definition to reflect latest changes

In latest versions of angular-local-storage library it is possible now to pass type of storage to some methods e.g.
https://github.com/grevory/angular-local-storage/blob/master/src/angular-local-storage.js#L147

* improves formatting
This commit is contained in:
Radosław Krzepkowski
2017-04-26 11:43:12 -07:00
committed by Sheetal Nandi
parent 53ada7c0c2
commit 2971c4624a
+20 -19
View File
@@ -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 <https://github.com/kenfdev>
// 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<T>(key: string, value: T): boolean;
set<T>(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<T>(key: string): T;
get<T>(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.
*/