@types/cookie_js
TypeScript icon, indicating that this package has built-in type declarations

1.2.4 • Public • Published

Installation

npm install --save @types/cookie_js

Summary

This package contains type definitions for cookie_js (https://github.com/florian/cookie.js).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/cookie_js.

index.d.ts

declare module "cookie_js" {
    export = cookie;
}

/**
 * https://github.com/DefinitelyTyped/DefinitelyTyped/pull/16025#issuecomment-295784660
 */
declare module "cookiejs" {
    export = cookie;
}

declare function cookie(key: string, fallback?: string): string;
declare function cookie(keys: string[], fallback?: string): string;

interface UtilStatic {
    isArray: (value: any) => boolean;
    isObject: (value: any) => boolean;
    toArray: (...args: any[]) => any[];
    getKeys: (value: {}) => any[];
    encode: (value: string) => string;
    decode: (value: string) => string;
    retrieve: (x: string, y: string) => string;
}

interface Options {
    expires: number | string | Date;
    domain: string;
    path: string;
    secure: boolean;
}

declare namespace cookie {
    /**
     * Create a cookie. The value will automatically be escaped.
     */
    export function set(key: string, value: string, options?: any): void;
    /**
     * Set several cookies at once
     */
    export function set(obj: any, options?: any): void;
    /**
     * Remove cookies
     */
    export function remove(key: string): void;
    export function remove(keys: string[]): void;
    export function remove(...args: string[]): void;
    /**
     * Remove cookies that were set with custom options (e.g. specifing domain or path)
     */
    export function removeSpecific(key: string, options?: any): void;
    export function removeSpecific(keys: string[], options?: any): void;
    /**
     * Remove all cookies
     */
    export function empty(): void;
    /**
     * Retrieve the value of the cookie
     */
    export function get(key: string, fallback?: string): string;
    /**
     * Retrieve values of several cookies
     */
    export function get(keys: string[], fallback?: string): any;
    /**
     * Get all currently saved cookies
     */
    export function all(): any;
    /**
     * Test if cookies are enabled
     */
    export function enabled(): boolean;
    /**
     * Utility methods
     */
    export var utils: UtilStatic;
    /**
     * Set default options
     */
    export var defaults: Options;
}

Additional Details

  • Last updated: Mon, 06 Nov 2023 22:41:05 GMT
  • Dependencies: none

Credits

These definitions were written by slawiko.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/cookie_js

Weekly Downloads

11,677

Version

1.2.4

License

MIT

Unpacked Size

6.79 kB

Total Files

5

Last publish

Collaborators

  • types