From 4e0f83c02ff424e386272685bf567c0dfd9ab09c Mon Sep 17 00:00:00 2001 From: MIZUNE Pine Date: Thu, 30 Oct 2014 01:33:59 +0900 Subject: [PATCH 1/2] Add cookie --- cookie/cookie-test.ts | 33 +++++++++++++++++++++++++++++++++ cookie/cookie.d.ts | 28 ++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 cookie/cookie-test.ts create mode 100644 cookie/cookie.d.ts diff --git a/cookie/cookie-test.ts b/cookie/cookie-test.ts new file mode 100644 index 000000000..fccb4b0d3 --- /dev/null +++ b/cookie/cookie-test.ts @@ -0,0 +1,33 @@ +/// + +import cookie = require('cookie'); + +function test_serialize(): void { + var retVal: string; + + retVal = cookie.serialize('foo', 'bar'); + retVal = cookie.serialize('foo', 'bar', { httpOnly: true }); +} + +function test_parse(): void { + var retVal: { [key: string]: string }; + + retVal = cookie.parse('foo=bar; bar=baz;'); + retVal = cookie.parse('foo=bar; bar=baz', { decode: x => x }); +} + +function test_options(): void { + var serializeOptions: CookieSerializeOptions = { + encode: (x: string) => x, + path: '/', + expires: new Date(), + maxAge: 200, + domain: 'example.com', + secure: false, + httpOnly: false + }; + + var parseOptios: CookieParseOptions = { + decode: (x: string) => x + }; +} diff --git a/cookie/cookie.d.ts b/cookie/cookie.d.ts new file mode 100644 index 000000000..a7151fc9f --- /dev/null +++ b/cookie/cookie.d.ts @@ -0,0 +1,28 @@ +// Type definitions for cookie v0.1.2 +// Project: https://github.com/jshttp/cookie +// Definitions by: Pine Mizune +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface CookieSerializeOptions { + encode?: (val: string) => string; + path?: string; + expires?: Date; + maxAge?: number; + domain?: string; + secure?: boolean; + httpOnly?: boolean; +} + +interface CookieParseOptions { + decode?: (val: string) => string; +} + +interface CookieStatic { + serialize(name: string, val: string, options?: CookieSerializeOptions): string; + parse(str: string, options?: CookieParseOptions): { [key: string]: string }; +} + +declare module "cookie" { + var cookie: CookieStatic; + export = cookie; +} From dcdb42d2556b01992e2bc41f81ee9c01ab38f827 Mon Sep 17 00:00:00 2001 From: MIZUNE Pine Date: Thu, 30 Oct 2014 01:38:12 +0900 Subject: [PATCH 2/2] Add contributor --- CONTRIBUTORS.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 083204e8f..d6c24bc1c 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -63,7 +63,8 @@ All definitions files include a header with the author and editors, so at some p * [Clone](https://github.com/pvorb/node-clone) (by [Kieran Simpson](https://github.com/kierans)) * [CodeMirror](http://codemirror.net) (by [François de Campredon](https://github.com/fdecampredon)) * [Commander](http://github.com/visionmedia/commander.js) (by [Marcelo Dezem](https://github.com/mdezem) and [vvakame](https://github.com/vvakame)) -* [configstore](http://github.com/yeoman/configstore) (by [Bart van der Schoor](https://github.com/Bartvds)) +* [configstore](http://github.com/yeoman/configstore) (by [Bart van der Schoor](https://github.com/Bartvds)) +* [cookie](https://github.com/jshttp/cookie) (by [Pine Mizune](https://github.com/jshttp/cookie)) * [Cordova](http://cordova.apache.org) (by [Microsoft Open Technologies, Inc.](http://msopentech.com/)) * [Cordovarduino](https://github.com/stereolux/cordovarduino) (by [Hendrik Maus](https://github.com/hendrikmaus)) * [Couchbase / Couchnode](https://github.com/couchbase/couchnode) (by [Basarat Ali Syed](https://github.com/basarat))