First commit
This commit is contained in:
20
src/stores/pricing.js
Normal file
20
src/stores/pricing.js
Normal file
@@ -0,0 +1,20 @@
|
||||
const memoryBackend = require("./backend/pricing/memory.js");
|
||||
|
||||
const globalCache = {};
|
||||
let globalInstance;
|
||||
|
||||
function global({ seed = {}, backend = memoryBackend } = {}) {
|
||||
if (!globalInstance) {
|
||||
Object.assign(globalCache, seed, { USD: 1 });
|
||||
globalInstance = backend(globalCache);
|
||||
}
|
||||
return globalInstance;
|
||||
}
|
||||
|
||||
function instance({ cache = {}, backend = memoryBackend } = {}) {
|
||||
return backend(Object.assign(cache, { USD: 1 }));
|
||||
}
|
||||
module.exports = {
|
||||
global,
|
||||
instance,
|
||||
};
|
||||
Reference in New Issue
Block a user