11'use strict' ;
22
3+ import { CookieOptions } from './types' ;
4+
35/**
46 * Module dependencies.
57 */
@@ -17,21 +19,15 @@ var topDomain = require('@segment/top-domain');
1719 * @param {Object } options
1820 */
1921
20- function Cookie ( options ) {
22+ function Cookie ( options ?: CookieOptions ) {
2123 this . options ( options ) ;
2224}
2325
2426/**
2527 * Get or set the cookie options.
26- *
27- * @param {Object } options
28- * @field {Number} maxage (1 year)
29- * @field {String} domain
30- * @field {String} path
31- * @field {Boolean} secure
3228 */
3329
34- Cookie . prototype . options = function ( options ) {
30+ Cookie . prototype . options = function ( options : CookieOptions ) {
3531 if ( arguments . length === 0 ) return this . _options ;
3632
3733 options = options || { } ;
@@ -64,13 +60,9 @@ Cookie.prototype.options = function(options) {
6460
6561/**
6662 * Set a `key` and `value` in our cookie.
67- *
68- * @param {String } key
69- * @param {Object } value
70- * @return {Boolean } saved
7163 */
7264
73- Cookie . prototype . set = function ( key , value ) {
65+ Cookie . prototype . set = function ( key : string , value ?: object | string ) : boolean {
7466 try {
7567 value = window . JSON . stringify ( value ) ;
7668 cookie ( key , value === 'null' ? null : value , clone ( this . _options ) ) ;
@@ -82,12 +74,9 @@ Cookie.prototype.set = function(key, value) {
8274
8375/**
8476 * Get a value from our cookie by `key`.
85- *
86- * @param {String } key
87- * @return {Object } value
8877 */
8978
90- Cookie . prototype . get = function ( key ) {
79+ Cookie . prototype . get = function ( key : string ) : object {
9180 try {
9281 var value = cookie ( key ) ;
9382 value = value ? window . JSON . parse ( value ) : null ;
@@ -99,12 +88,9 @@ Cookie.prototype.get = function(key) {
9988
10089/**
10190 * Remove a value from our cookie by `key`.
102- *
103- * @param {String } key
104- * @return {Boolean } removed
10591 */
10692
107- Cookie . prototype . remove = function ( key ) {
93+ Cookie . prototype . remove = function ( key : string ) : boolean {
10894 try {
10995 cookie ( key , null , clone ( this . _options ) ) ;
11096 return true ;
0 commit comments