From 2351cf74f4471471e84f99912d30021462496597 Mon Sep 17 00:00:00 2001 From: jj Date: Fri, 1 Nov 2024 14:05:18 +0000 Subject: [PATCH] api/cookie: formatting --- api/src/processing/cookie/cookie.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/api/src/processing/cookie/cookie.js b/api/src/processing/cookie/cookie.js index 6dd95fc3..5a3f6dcd 100644 --- a/api/src/processing/cookie/cookie.js +++ b/api/src/processing/cookie/cookie.js @@ -6,14 +6,17 @@ export default class Cookie { this._values = {}; this.set(input) } + set(values) { Object.entries(values).forEach( ([ key, value ]) => this._values[key] = value ) } + unset(keys) { for (const key of keys) delete this._values[key] } + static fromString(str) { const obj = {}; @@ -25,12 +28,15 @@ export default class Cookie { return new Cookie(obj) } + toString() { return Object.entries(this._values).map(([ name, value ]) => `${name}=${value}`).join('; ') } + toJSON() { return this.toString() } + values() { return Object.freeze({ ...this._values }) }