From ebbdaa3473b4885468eb27922e24511c93b962ca Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 26 Apr 2021 13:15:09 -0300 Subject: synchronize shared sources on join + other stuff --- general-util.js | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'general-util.js') diff --git a/general-util.js b/general-util.js index 4bfd491..364da88 100644 --- a/general-util.js +++ b/general-util.js @@ -349,3 +349,14 @@ export async function silenceEvents(emitter, eventsToSilence, callback) { emitter.emit = oldEmit } + +// Kindly stolen from ESDiscuss: +// https://esdiscuss.org/topic/proposal-add-an-option-to-omit-prototype-of-objects-created-by-json-parse#content-1 +export function parseWithoutPrototype(string) { + return JSON.parse(string, function(k, v) { + if (v && typeof v === 'object' && !Array.isArray(v)) { + return Object.assign(Object.create(null), v) + } + return v + }) +} -- cgit 1.3.0-6-gf8a5