mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 14:20:12 +00:00
16023: creates second types folder for those, who uses npm package cookie_js
This commit is contained in:
35
types/cookie_js/cookie_js-tests.ts
Normal file
35
types/cookie_js/cookie_js-tests.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
|
||||
|
||||
// Based on https://github.com/js-coder/cookie.js/blob/gh-pages/tests/spec.js
|
||||
|
||||
import cookie = require("cookiejs");
|
||||
|
||||
cookie.set({a: '1', b: '2', c: '3'});
|
||||
|
||||
cookie;
|
||||
cookie.enabled();
|
||||
|
||||
cookie.set('n', '5');
|
||||
|
||||
cookie.get('a');
|
||||
cookie.get('__undef__');
|
||||
cookie.get('__undef__', 'fallback');
|
||||
cookie.get(['a', 'b']);
|
||||
cookie.get(['a', '__undef__'], 'fallback');
|
||||
|
||||
cookie('a');
|
||||
cookie('__undef__');
|
||||
cookie('__undef__', 'fallback');
|
||||
cookie(['a', 'b']);
|
||||
cookie(['a', '__undef__'], 'fallback');
|
||||
|
||||
cookie.remove('a');
|
||||
cookie.remove('a', 'b');
|
||||
cookie.remove(['a', 'b']);
|
||||
|
||||
cookie.removeSpecific('a', {path: '/search'});
|
||||
cookie.removeSpecific(['a', 'b'], {path: '/search'});
|
||||
|
||||
cookie.empty();
|
||||
|
||||
cookie.all();
|
||||
55
types/cookie_js/index.d.ts
vendored
Normal file
55
types/cookie_js/index.d.ts
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
// Type definitions for cookie_js v1.2.2
|
||||
// Project: https://github.com/florian/cookie.js
|
||||
// Definitions by: slawiko <https://github.com/slawiko>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
/**
|
||||
* Shortcut for cookie.get()
|
||||
*/
|
||||
|
||||
export = cookie;
|
||||
export as namespace cookie;
|
||||
|
||||
declare function cookie(key : string, fallback?: string) : string;
|
||||
declare function cookie(keys : string[], fallback?: string) : string;
|
||||
|
||||
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;
|
||||
}
|
||||
22
types/cookie_js/tsconfig.json
Normal file
22
types/cookie_js/tsconfig.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"cookie_js-tests.ts"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user