Formatting fixes

This commit is contained in:
Ajay Ramachandran
2020-01-09 12:12:49 -05:00
parent 52f60d70e2
commit f42c23cd9a
2 changed files with 36 additions and 36 deletions

42
SB.js
View File

@@ -4,27 +4,6 @@ Map.prototype.toJSON = function() {
return Array.from(this.entries());
};
function storeEncode(data) {
if(!(data instanceof Map)) return data;
return JSON.stringify(data);
}
function mapDecode(data, key) {
if(typeof data !== "string") return data;
try {
let str = JSON.parse(data);
if(!Array.isArray(str)) return data;
return new Map(str);
} catch(e) {
return data
}
}
function mapProxy(data, key) {
if(!(data instanceof Map)) return data;
return new mapIO(key);
}
class mapIO extends Map {
constructor(id) {
super();
@@ -73,6 +52,27 @@ class mapIO extends Map {
}
}
function storeEncode(data) {
if(!(data instanceof Map)) return data;
return JSON.stringify(data);
}
function mapDecode(data, key) {
if(typeof data !== "string") return data;
try {
let str = JSON.parse(data);
if(!Array.isArray(str)) return data;
return new Map(str);
} catch(e) {
return data
}
}
function mapProxy(data, key) {
if(!(data instanceof Map)) return data;
return new mapIO(key);
}
function configProxy() {
chrome.storage.onChanged.addListener((changes, namespace) => {
for (key in changes) {