UNPKG

@alifd/meet-react

Version:

Fusion Mobile React UI System Component

36 lines (35 loc) 923 B
"use strict"; exports.__esModule = true; exports.default = void 0; var _utils = require("../utils"); var Cache = /*#__PURE__*/function () { function Cache() { this._root = null; this._store = new Map(); } var _proto = Cache.prototype; _proto.empty = function empty() { return this._store.size === 0; }; _proto.has = function has(key) { return this._store.has(key); }; _proto.get = function get(key, defaultValue) { var res = this.has(key) ? this._store.get(key) : this.root(); return (0, _utils.isNil)(res) ? defaultValue : res; }; _proto.add = function add(key, value) { if (this.empty()) { this._root = key; } this._store.set(key, value); }; _proto.remove = function remove(key) { this._store.delete(key); }; _proto.root = function root() { return this._store.get(this._root); }; return Cache; }(); var _default = exports.default = Cache;