fragment_cache.js 228 B

123456789101112
  1. 'use strict';
  2. module.exports = ctx => {
  3. const cache = {};
  4. return function fragmentCache(id, fn) {
  5. if (this.cache && cache[id] != null) return cache[id];
  6. const result = cache[id] = fn();
  7. return result;
  8. };
  9. };