UNPKG

arweave-account

Version:

Account protocol library on Arweave by Metaweave.xyz

30 lines (29 loc) 1.23 kB
var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const Web_1 = __importDefault(require("./Web")); const Node_1 = __importDefault(require("./Node")); class Cache { constructor(env, size, expirationTime) { // Environments list this.select = { web: () => new Web_1.default(this.size, this.expirationTime), node: () => new Node_1.default(this.size, this.expirationTime), }; this.get = (addr) => this.cacheObj.get(addr); this.find = (uniqueHandle) => this.cacheObj.find(uniqueHandle); this.hydrate = (account) => this.cacheObj.hydrate(account); this.reset = () => this.cacheObj.reset(); this.dump = () => this.cacheObj.dump(); this.size = size; this.expirationTime = expirationTime; if (typeof env === 'object') this.cacheObj = env; else if (this.select[env]) this.cacheObj = this.select[env](); else throw new Error(`Cache for the '${env}' environment is not implemented.`); } } exports.default = Cache;