From f1881bc61d424df4576864d610d4840101b45631 Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Thu, 2 Feb 2023 12:23:24 +0100 Subject: [PATCH] refactor: remove use of Node.js v8 builtin Refs: #442 Refs: #475 Refs: #555 --- lib/helpers/deep_clone.js | 4 +--- lib/helpers/keystore.js | 5 +---- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/helpers/deep_clone.js b/lib/helpers/deep_clone.js index 4ad037bb..b1a3d9c9 100644 --- a/lib/helpers/deep_clone.js +++ b/lib/helpers/deep_clone.js @@ -1,3 +1 @@ -const { serialize, deserialize } = require('v8'); - -module.exports = globalThis.structuredClone || ((obj) => deserialize(serialize(obj))); +module.exports = globalThis.structuredClone || JSON.parse(JSON.stringify(obj)); diff --git a/lib/helpers/keystore.js b/lib/helpers/keystore.js index e9dad799..e8bba155 100644 --- a/lib/helpers/keystore.js +++ b/lib/helpers/keystore.js @@ -1,9 +1,6 @@ -const v8 = require('v8'); - const jose = require('jose'); -const clone = globalThis.structuredClone || ((value) => v8.deserialize(v8.serialize(value))); - +const clone = require('./deep_clone'); const isPlainObject = require('./is_plain_object'); const isKeyObject = require('./is_key_object');