16023: creates second types folder for those, who uses npm package cookie_js

This commit is contained in:
Shchaurouski Sviataslau
2017-04-20 17:02:38 +03:00
parent 01ad8d4e35
commit 869f7f406e
3 changed files with 112 additions and 0 deletions

View 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
View 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;
}

View 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"
]
}