UNPKG

devextreme

Version:

HTML5 JavaScript Component Suite for Responsive Web Development

91 lines (85 loc) 2.78 kB
/** * DevExtreme (cjs/ui/scheduler/workspaces/cache.js) * Version: 22.1.9 * Build date: Tue Apr 18 2023 * * Copyright (c) 2012 - 2023 Developer Express Inc. ALL RIGHTS RESERVED * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/ */ "use strict"; exports.Cache = void 0; var _type = require("../../../core/utils/type"); function _typeof(obj) { return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj) { return typeof obj } : function(obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj }, _typeof(obj) } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) { descriptor.writable = true } Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor) } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) { _defineProperties(Constructor.prototype, protoProps) } if (staticProps) { _defineProperties(Constructor, staticProps) } Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor } function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return "symbol" === _typeof(key) ? key : String(key) } function _toPrimitive(input, hint) { if ("object" !== _typeof(input) || null === input) { return input } var prim = input[Symbol.toPrimitive]; if (void 0 !== prim) { var res = prim.call(input, hint || "default"); if ("object" !== _typeof(res)) { return res } throw new TypeError("@@toPrimitive must return a primitive value.") } return ("string" === hint ? String : Number)(input) } var Cache = function() { function Cache() { this._cache = new Map } var _proto = Cache.prototype; _proto.clear = function() { this._cache.clear() }; _proto.get = function(name, callback) { if (!this._cache.has(name) && callback) { this.set(name, callback()) } return this._cache.get(name) }; _proto.set = function(name, value) { (0, _type.isDefined)(value) && this._cache.set(name, value) }; _createClass(Cache, [{ key: "size", get: function() { return this._cache.size } }]); return Cache }(); exports.Cache = Cache;