From a2b3b27d91bc9405f801bc2e514424b6a8220b32 Mon Sep 17 00:00:00 2001 From: Vincent Voyer Date: Thu, 5 Nov 2020 13:50:42 +0100 Subject: [PATCH] fix(10): fix nodejs 10 --- lib/index.js | 5 +++-- package.json | 5 ++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/index.js b/lib/index.js index ec731881..8142f626 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,6 +1,7 @@ import ironStore from "iron-store"; import cookie from "cookie"; import createDebug from "debug"; +import flat from "array.prototype.flat"; const debug = createDebug("next-iron-session"); @@ -67,7 +68,7 @@ export async function applySession( `next-iron-session: Cookie length is too big ${cookieValue.length}, browsers will refuse it`, ); } - const existingSetCookie = [res.getHeader("set-cookie") || []].flat(); + const existingSetCookie = flat([res.getHeader("set-cookie") || []]); res.setHeader("set-cookie", [...existingSetCookie, cookieValue]); return cookieValue; }, @@ -77,7 +78,7 @@ export async function applySession( ...cookieOptions, maxAge: 0, }); - const existingSetCookie = [res.getHeader("set-cookie") || []].flat(); + const existingSetCookie = flat([res.getHeader("set-cookie") || []]); res.setHeader("set-cookie", [...existingSetCookie, cookieValue]); }, }; diff --git a/package.json b/package.json index 2ac220da..17b8bdd5 100644 --- a/package.json +++ b/package.json @@ -32,9 +32,7 @@ { "targets": { "node": "10" - }, - "useBuiltIns": "usage", - "corejs": 3 + } } ] ] @@ -81,6 +79,7 @@ ] }, "dependencies": { + "array.prototype.flat": "^1.2.3", "clone": "^2.1.2", "cookie": "^0.4.1", "debug": "^4.1.1",