From f7a3f98ad3c5e978ef11ba3a5ad469a38ccf873c Mon Sep 17 00:00:00 2001 From: Official Noob <31563761+OfficialNoob@users.noreply.github.com> Date: Thu, 16 Jan 2020 18:43:49 +0000 Subject: [PATCH] Comments --- SB.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/SB.js b/SB.js index c11575d7..86582311 100644 --- a/SB.js +++ b/SB.js @@ -9,16 +9,21 @@ SB = { // Function setup +// Allows a map to be conveted into json form +// Currently used for local storage Map.prototype.toJSON = function() { return Array.from(this.entries()); }; +// Proxy Map changes to Map in SB.localConfig +// Saves the changes to chrome.storage in json form class MapIO { constructor(id) { + // The name of the item in the array this.id = id; + // A local copy of the map (SB.config.mapname.map) this.map = SB.localConfig[this.id]; } - set(key, value) { // Proxy to map this.map.set(key, value); @@ -65,6 +70,7 @@ class MapIO { * @param {*} data */ function encodeStoredItem(data) { + // if data is Map convert to json for storing if(!(data instanceof Map)) return data; return JSON.stringify(data); } @@ -120,7 +126,7 @@ function configProxy() { deleteProperty(obj, prop) { chrome.storage.sync.remove(prop); } - + }; return new Proxy({handler}, handler);