Last active
June 2, 2019 20:23
-
-
Save nhalstead/6f0031121faec99e58e55b503207a9c3 to your computer and use it in GitHub Desktop.
Config Manager in JS, This is used on things like YouTube music to keep a simple interface for config data.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const pagecfg = { | |
d: function() { | |
return pagecfg.data_ || (pagecfg.data_ = {}); | |
}, | |
get: function(k, o) { | |
return (k in pagecfg.d()) ? pagecfg.d()[k] : o; | |
}, | |
set: function() { | |
var a = arguments; | |
if (a.length > 1) { | |
pagecfg.d()[a[0]] = a[1]; | |
} else { | |
for (var k in a[0]) { | |
pagecfg.d()[k] = a[0][k]; | |
} | |
} | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const pagecfg={d:function(){return pagecfg.data_||(pagecfg.data_={})},get:function(g,e){return g in pagecfg.d()?pagecfg.d()[g]:e},set:function(){var g=arguments;if(g.length>1)pagecfg.d()[g[0]]=g[1];else for(var e in g[0])pagecfg.d()[e]=g[0][e]}}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment