add jsdoc comments
This commit is contained in:
1 parent
6de354ad47
commit
8c1205bc13
24 files changed
+1228
-425
No files matched your search
+15
-1
@@ -1,3 +1,10 @@
|
||||
/**
|
||||
* @param {string} name
|
||||
* @param {string} value
|
||||
* @param {number} [expireDays]
|
||||
* @param {string} [host]
|
||||
* @param {boolean} [encode]
|
||||
*/
|
||||
export function setCookie(name, value, expireDays, host, encode) {
|
||||
if (name == null) {
|
||||
return;
|
||||
@@ -6,7 +13,7 @@ export function setCookie(name, value, expireDays, host, encode) {
|
||||
if (expireDays != null) {
|
||||
const d = new Date();
|
||||
d.setTime(d.getTime() + (expireDays * 24 * 60 * 60 * 1000));
|
||||
extra += `; expires=${d.toGMTString()}`;
|
||||
extra += `; expires=${d.toUTCString()}`;
|
||||
}
|
||||
if (/^(https|wss):$/.test(location.protocol)) {
|
||||
extra += '; secure';
|
||||
@@ -17,6 +24,10 @@ export function setCookie(name, value, expireDays, host, encode) {
|
||||
document.cookie = `${name}=${value}${extra}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} [name]
|
||||
* @returns {string | null}
|
||||
*/
|
||||
export function getCookie(name) {
|
||||
if (name == null) {
|
||||
return null;
|
||||
@@ -32,6 +43,9 @@ export function getCookie(name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
*/
|
||||
export function deleteCookie(name) {
|
||||
setCookie(name, '', -1);
|
||||
}
|
||||
Reference in new issue
Block a user