/** * cookie函数可选参数 * @internal * @category cookie */ interface IOptions { /** * 传入数字以天为单位。或者自行通过Date创建过期时间 */ expires?: number | Date; /** * If not specified, defaults to the current path of the current document location. */ path?: string; /** * If not specified, this defaults to the host portion of the current document location. Contrary to earlier specifications, leading dots in domain names are ignored, but browsers may decline to set the cookie containing such dots. If a domain is specified, subdomains are always included. * Note: The domain must match the domain of the JavaScript origin. Setting cookies to foreign domains will be silently ignored. */ domain?: string; /** * Cookie to only be transmitted over secure protocol as https. Before Chrome 52, this flag could appear with cookies from http domains. */ secure?: boolean; /** * raw为true是则不会encodeURIComponent */ raw?: boolean; /** * 在一些非浏览器环境中,请传入cookie字符串。否则默认读取document.cookie */ cookie?: string; } /** * 对cookie进行读取,设置操作 * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie | Document.cookie} * @category cookie */ export declare function cookie(...args: [key: string, value?: any | IOptions, options?: IOptions]): any; /** * 读取cookie * * ```ts * import { setCookie, getCookie } from 'sunny-js' * setCookie('key', 'value') * getCookie('key') * // => 'value' * ``` * * @see {@link setCookie} * @category cookie */ export declare function getCookie(...args: [key: string, options?: IOptions]): string | undefined; /** * 设置cookie * * ```ts * import { setCookie, getCookie } from 'sunny-js' * // a session cookie * setCookie('key', 'value') * // expired after 1 day * setCookie('key', 'value', { expires: 1 }) * ``` * * @see {@link getCookie} * @category cookie */ export declare function setCookie(key: string, value: unknown, options?: IOptions): void; /** * 删除cookie * * ```ts * import { delCookie } from 'sunny-js' * delCookie('key') * ``` * * @category cookie */ export declare function delCookie(key: string, options?: IOptions): void; export {};