Files
portfolio-balancer/src/stores/pricing.js
Lewis Diamond 37ebd9f824 First commit
2020-07-13 00:03:38 -04:00

21 lines
505 B
JavaScript

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,
};