Skip to content

Commit

Permalink
Merge pull request #9 from szepeviktor/patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo authored Jan 5, 2025
2 parents a2a9e20 + a3705af commit 1941743
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 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}
*/
constructor(namespace = '')
{
Expand Down Expand Up @@ -42,17 +41,20 @@ export default class Cookie
...options,
};

/** @type {string[]} */
const initialValue = [];

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 {*}
*/
get(key, value = null)
{
Expand All @@ -67,7 +69,7 @@ export default class Cookie
* Determine if the given cookie exists.
*
* @param {string} key
* @return {bool}
* @return {boolean}
*/
isset(key)
{
Expand All @@ -84,7 +86,7 @@ export default class Cookie
*/
remove(key)
{
this.set(key, null, 'Thu, 01 Jan 1970 00:00:01 GMT');
this.set(key, '', 'Thu, 01 Jan 1970 00:00:01 GMT');
}

/**
Expand Down

0 comments on commit 1941743

Please sign in to comment.