From a396f1ac69c70b3cabcafc0618202e6bec5865da Mon Sep 17 00:00:00 2001 From: borislavjivkov Date: Sat, 27 Feb 2016 02:20:43 +0200 Subject: [PATCH] Added angular-cookie (https://github.com/ivpusic/angular-cookie) definitions --- angular-cookie/angular-cookie-tests.ts | 21 +++++++++ angular-cookie/angular-cookie.d.ts | 65 ++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 angular-cookie/angular-cookie-tests.ts create mode 100644 angular-cookie/angular-cookie.d.ts diff --git a/angular-cookie/angular-cookie-tests.ts b/angular-cookie/angular-cookie-tests.ts new file mode 100644 index 000000000..e6280fbeb --- /dev/null +++ b/angular-cookie/angular-cookie-tests.ts @@ -0,0 +1,21 @@ +/// +/// + +angular.module('myApp', ['ipCookie']) + .controller('cookieController', ['ipCookie', function(ipCookie: angular.cookie.CookieService) { + ipCookie('key', 'value'); + ipCookie('key', { value: 'value'}); + ipCookie('key', [1, 2, 3]); + + ipCookie('key', 'value', { expires: 21 }); + ipCookie('key', 'value', { encode: function (value) { return value; } }); + + ipCookie(); + ipCookie('key'); + ipCookie('key', undefined, {decode: function (value) { return value; }}); + + ipCookie.remove('key'); + ipCookie.remove('key', { path: '/some/path/' }); + + var obj: Object = '255'; + }]); \ No newline at end of file diff --git a/angular-cookie/angular-cookie.d.ts b/angular-cookie/angular-cookie.d.ts new file mode 100644 index 000000000..99041f934 --- /dev/null +++ b/angular-cookie/angular-cookie.d.ts @@ -0,0 +1,65 @@ +// Type definitions for angular-cookie v4.1.0 +// Project: https://github.com/ivpusic/angular-cookie +// Definitions by: Borislav Zhivkov +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module angular.cookie { + interface CookieService { + /** + * Get all cookies + */ + (): any; + + /** + * Get a cookie with a specific key + */ + (key: string): any; + + /** + * Create a cookie + */ + (key: string, value: any, options?: CookieOptions): any; + + /** + * Remove a cookie + */ + remove(key: string, options?: CookieOptions): void; + } + + interface CookieOptions { + /** + * The domain tells the browser to which domain the cookie should be sent. If you don't specify it, it becomes the domain of the page that sets the cookie. + */ + domain?: string; + + /** + * The path gives you the chance to specify a directory where the cookie is active. + */ + path?: string; + + /** + * Each cookie has an expiry date after which it is trashed. If you don't specify the expiry date the cookie is trashed when you close the browser. + */ + expires?: number; + + /** + * Allows you to set the expiration time in hours, minutes, seconds, or `milliseconds. If this is not specified, any expiration time specified will default to days. + */ + expirationUnit?: string; + + /** + * The Secure attribute is meant to keep cookie communication limited to encrypted transmission, directing browsers to use cookies only via secure/encrypted connections. + */ + secure?: boolean; + + /** + * The method that will be used to encode the cookie value (should be passed when using Set). + */ + encode?: (value: any) => any; + + /** + * The method that will be used to decode extracted cookie values (should be passed when using Get). + */ + decode?: (value: any) => any; + } +} \ No newline at end of file