Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix types in JSDoc #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export default class Cookie
* Make a new Cookie instance.
*
* @param {string} namespace
* @return {void}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No return tag for constructor.

*/
constructor(namespace = '')
{
Expand All @@ -15,7 +14,7 @@ export default class Cookie
* Set a cookie value for the given key.
*
* @param {string} key
* @param {string} value
* @param {string} value
* @param {Date|string|null} expires
* @param {string} path
* @param {object} options
Expand All @@ -34,17 +33,20 @@ export default class Cookie
...options,
};

/** @type {string[]} */
const initialValue = [];
Comment on lines +36 to +37
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sets the type for the empty array.


document.cookie = Object.entries(cookie)
.reduce((stack, entry) => stack.concat(entry.join('=')), [])
.reduce((stack, entry) => stack.concat(entry.join('=')), initialValue)
.join('; ');
}

/**
* Get the cookie with the given key.
*
* @param {string} key
* @param {mixed} value
* @return {mixed}
* @param {*} value
* @return {*}
Comment on lines -46 to +49
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHP: mixed
JS: *

*/
get(key, value = null)
{
Expand All @@ -59,7 +61,7 @@ export default class Cookie
* Determine if the given cookie exists.
*
* @param {string} key
* @return {bool}
* @return {boolean}
*/
isset(key)
{
Expand All @@ -78,7 +80,7 @@ export default class Cookie
{
key = this._qualify(key);

this.set(key, null, 'Thu, 01 Jan 1970 00:00:01 GMT');
this.set(key, '', 'Thu, 01 Jan 1970 00:00:01 GMT');
Comment on lines -81 to +83
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

null is not compatible with string

}

/**
Expand Down