UNPKG

@code-o-mat/globals

Version:

Abstract Package to support CodeOMat series of apps.

106 lines (81 loc) 4.94 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _values = require("../constants/values"); var _types = require("../constants/types"); var _jsTypes = require("../assertions/js-types"); var _meta = _interopRequireDefault(require("../abstracts/meta")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _instanceof(left, right) { if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) { return right[Symbol.hasInstance](left); } else { return left instanceof right; } } function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } function _classCallCheck(instance, Constructor) { if (!_instanceof(instance, Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 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, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } var Cache = /*#__PURE__*/ function (_Meta) { _inherits(Cache, _Meta); function Cache() { var _this; var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; _classCallCheck(this, Cache); _this = _possibleConstructorReturn(this, (Cache.__proto__ || Object.getPrototypeOf(Cache)).call(this)); Object.defineProperty(_assertThisInitialized(_this), "TYPE", { configurable: true, enumerable: true, writable: true, value: _types.CACHE }); (0, _jsTypes.assertIsObject)(data); _this[_values.PROPS] = _extends({}, data); return _this; } _createClass(Cache, [{ key: "clone", value: function clone() { return new this.constructor(_extends({}, this[_values.PROPS])); } }, { key: "data", value: function data() { var _data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _values.NONE; if (_data === _values.NONE) return this[_values.PROPS]; this[_values.PROPS] = _data; return this; } }, { key: "get", value: function get(key) { var dflt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _values.NONE; return key in this[_values.PROPS] ? this[_values.PROPS][key] : dflt; } }, { key: "merge", value: function merge(newData) { var data = this[_values.PROPS]; this[_values.PROPS] = _extends({}, data, newData); return this; } }, { key: "set", value: function set(key, value) { this[_values.PROPS] = _extends({}, this[_values.PROPS], _defineProperty({}, key, value)); } }]); return Cache; }(_meta.default); Object.defineProperty(Cache, "TYPE", { configurable: true, enumerable: true, writable: true, value: _types.CACHE }); var _default = Cache; exports.default = _default;