diff options
author | (quasar) nebula <towerofnix@gmail.com> | 2021-04-26 13:15:09 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-05-16 22:29:25 -0300 |
commit | ebbdaa3473b4885468eb27922e24511c93b962ca (patch) | |
tree | b9e203691a5089edd48fb8b9eadc6a0add38e904 /general-util.js | |
parent | 4bee8ad4fc1c315055d0d3377f8140b02cd51621 (diff) |
synchronize shared sources on join + other stuff
Diffstat (limited to 'general-util.js')
-rw-r--r-- | general-util.js | 11 |
1 files changed, 11 insertions, 0 deletions
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 + }) +} |