Export caches via CookieMonsterData.
This commit is contained in:
18
src/Cache/FillCMDCache.js
Normal file
18
src/Cache/FillCMDCache.js
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Insert the provided values into `window.CookieMonsterData.Cache`.
|
||||
*
|
||||
* The initial 'Cache' is dropped from the name, so e.g. `CacheWrinklersTotal`
|
||||
* becomes `window.CookieMonsterData.Cache.WrinklersTotal`.
|
||||
*/
|
||||
export default function FillCMDCache(caches) {
|
||||
if (!('Cache' in window.CookieMonsterData)) {
|
||||
window.CookieMonsterData.Cache = {};
|
||||
}
|
||||
|
||||
Object.keys(caches).forEach((name) => {
|
||||
const exportName = name.replace(/^Cache/, '');
|
||||
|
||||
// Passing through JSON ensures that no references are retained.
|
||||
window.CookieMonsterData.Cache[exportName] = JSON.parse(JSON.stringify(caches[name]));
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user