@pointerstack/ngx-cookie-storage
Version:
An Angular cookie service
108 lines (107 loc) • 2.75 kB
TypeScript
export declare class NgxCookieStorageService {
private document;
private documentIsAccessible;
constructor(document: any);
/**
* PARSER
*
* Function to parse document.cookie string and extract
* cookiename:value pairs.
*/
private parser;
/**
* GET
*
* Function to get value from cookie
*
* @param name Cookie Name
* @param parsedCookie Parsed Cookie
*/
get(name: string, parsedCookie?: {}): void | string;
/**
* GETALL
*
* Function to get all stored cookie.
*/
getAll(): void | {};
/**
* GET-ASYNC
*
* Function to get cookie value as promise.
*
* @param name {string}
* @returns
*/
getAsync(name: string): Promise<void | string | Error>;
/**
* GETALL-ASYNC
*
* Function to get all stored cookie value as promise.
*
*/
getAllAsync(): Promise<void | string | Error>;
/**
* SET
*
* Function to set cookie
*
* @param name Cookie name
* @param value Cookie value
* @param expires Number of days until the cookies expires or an actual `Date`
* @param path Cookie path
* @param domain Cookie domain
* @param secure Secure flag
*/
set(name: string, value: string, expires?: number | Date, path?: string, domain?: string, secure?: boolean): void;
/**
* SET-ASYNC
*
* Function to set cookie asynchronously.
*
* @param name
* @param value
* @param expires
* @param path
* @param domain
* @param secure
*/
setAsync(name: string, value: string, expires?: number | Date, path?: string, domain?: string, secure?: boolean): Promise<void | Error>;
/**
* DELETE
*
* Function to delete a cookie
*
* @param name Cookie name
* @param path Cookie path
* @param domain Cookie domain
*/
delete(name: string, path?: string, domain?: string): void;
/**
* DELETEALL
*
* Function to delete all cookie
*
* @param path Cookie path
* @param domain Cookie domain
*/
deleteAll(path?: string, domain?: string): void;
/**
* DELETE-ASYNC
*
* Function to delete a cookie asynchronously.
*
* @param name Cookie name
* @param path Cookie path
* @param domain Cookie domain
*/
deleteAsync(name: string, path?: string, domain?: string): Promise<void | Error>;
/**
* DELETEALL-ASYNC
*
* Function to delete all cookie asynchronously.
*
* @param path Cookie path
* @param domain Cookie domain
*/
deleteAllAsync(path?: string, domain?: string): Promise<void | Error>;
}