From 932cf8ecf180506fafec28e717ba03e89cb3bcb3 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Sat, 1 Feb 2020 16:53:33 -0500 Subject: [PATCH] Fixed SBMap not importing entries. --- src/SB.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/SB.ts b/src/SB.ts index 751137f1..48edab13 100644 --- a/src/SB.ts +++ b/src/SB.ts @@ -9,6 +9,17 @@ interface SBObject { // Allows a SBMap to be conveted into json form // Currently used for local storage class SBMap extends Map { + constructor(entries?: [T, U][]) { + super(); + + // Import all entries if they were given + if (entries !== undefined) { + for (const item of entries) { + this.set(entries[0], entries[1]) + } + } + } + toJSON() { return Array.from(this.entries()); } @@ -205,7 +216,7 @@ function resetConfig() { function convertJSON() { Object.keys(SB.defaults).forEach(key => { - SB.localConfig[key] = decodeStoredItem(SB.localConfig[key], key); + SB.localConfig[key] = decodeStoredItem(SB.localConfig[key]); }); }