plus-8.x-4.x-dev/js/Drupal.Storage.js
js/Drupal.Storage.js
/** * DO NOT EDIT THIS FILE. * THIS FILE IS COMPILED AUTOMATICALLY FROM ITS ES6 SOURCE. * @preserve **/'use strict'; var _createClass = 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); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } 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 (Drupal, JSON) { 'use strict'; var MemoryStorage = function (_Map) { _inherits(MemoryStorage, _Map); function MemoryStorage() { _classCallCheck(this, MemoryStorage); return _possibleConstructorReturn(this, (MemoryStorage.__proto__ || Object.getPrototypeOf(MemoryStorage)).apply(this, arguments)); } _createClass(MemoryStorage, [{ key: 'getItem', value: function getItem(key) { return this.get(key); } }, { key: 'removeItem', value: function removeItem(key) { this.delete(key); } }, { key: 'setItem', value: function setItem(key, value) { if (value !== undefined) { this.set(key, String(value)); } } }, { key: 'length', get: function get() { return this.size; } }]); return MemoryStorage; }(Map); if (window.memoryStorage === undefined) { window.memoryStorage = new MemoryStorage(); } var Storage = function () { function Storage() { var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Drupal'; var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'local'; _classCallCheck(this, Storage); this.prefix = prefix; this.storage = window[type.toLowerCase().replace(/storage$/, '') + 'Storage']; if (!this.storage) { Drupal.throwError(Drupal.t('Unsupported storage: "@type". Defaulting to global "memory" storage. Warning: storage will not be persistent.', { '@type': type })); this.storage = window.memoryStorage; } } _createClass(Storage, [{ key: 'get', value: function get(key) { var item = this.storage.getItem(this.getPrefixedKey(key)); return item === undefined ? undefined : JSON.parse(item); } }, { key: 'getPrefixedKey', value: function getPrefixedKey(key) { if (!this.prefix) { return key; } var prefix = ('' + this.prefix).replace(/[.?*+^$[\]\\(){}|-]/g, '\\$&'); var keys = key.replace(new RegExp('^' + prefix + '\\.?'), '').split('.'); keys.unshift(this.prefix); return keys.join('.'); } }, { key: 'set', value: function set(key, value) { if (value !== undefined) { try { this.storage.setItem(this.getPrefixedKey(key), JSON.stringify(value)); } catch (e) { Drupal.throwError(e); } } return this; } }, { key: 'remove', value: function remove(key) { key = this.getPrefixedKey(key); this.storage.removeItem(key); return this; } }], [{ key: 'create', value: function create(prefix, type) { return new this(prefix, type); } }]); return Storage; }(); Drupal.Storage = Storage; })(window.Drupal, window.JSON);