UNPKG

react-inline-for-rix-loader

Version:

for developing webpack rix-loader, folk from https://github.com/martinandert/react-inline

42 lines (28 loc) 948 B
"use strict"; var _classCallCheck = require("babel-runtime/helpers/class-call-check")["default"]; var _Object$keys = require("babel-runtime/core-js/object/keys")["default"]; exports.__esModule = true; var hasOwnProperty = Object.prototype.hasOwnProperty; var cache = {}; var MemoryCache = (function () { function MemoryCache(name) { _classCallCheck(this, MemoryCache); this.name = name; this.fetch.bind(this); this.clear.bind(this); cache[name] = cache[name] || {}; } MemoryCache.prototype.fetch = function fetch(key, miss) { if (hasOwnProperty.call(cache[this.name], key)) { return cache[this.name][key]; } cache[this.name][key] = miss(_Object$keys(cache[this.name])); return cache[this.name][key]; }; MemoryCache.prototype.clear = function clear() { cache[this.name] = {}; }; return MemoryCache; })(); exports["default"] = MemoryCache; module.exports = exports["default"];