From 3f66e804e5b6a6b1bf709a9d2b9db0a715e28430 Mon Sep 17 00:00:00 2001 From: jkhsjdhjs Date: Sat, 17 Aug 2019 05:42:18 +0200 Subject: [PATCH] re-add static Cookie.fromObject() function --- src/cookie.mjs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/cookie.mjs b/src/cookie.mjs index 476b249..85675ac 100644 --- a/src/cookie.mjs +++ b/src/cookie.mjs @@ -108,6 +108,12 @@ export default class Cookie { if(!this.expiry) this.expiry = null; } + static fromObject(obj) { + let c = Object.assign(Object.create(this.prototype), obj); + if(typeof c.expiry === "string") + c.expiry = new Date(c.expiry); + return c; + } serialize() { return this.name + "=" + this.value; }