nav tabs on admin dashboard
This commit is contained in:
54
node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js
generated
vendored
54
node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js
generated
vendored
@@ -2,16 +2,7 @@
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
var createInnerCallback = require("./createInnerCallback");
|
||||
|
||||
function UnsafeCachePlugin(source, filterPredicate, cache, withContext, target) {
|
||||
this.source = source;
|
||||
this.filterPredicate = filterPredicate;
|
||||
this.withContext = withContext;
|
||||
this.cache = cache || {};
|
||||
this.target = target;
|
||||
}
|
||||
module.exports = UnsafeCachePlugin;
|
||||
"use strict";
|
||||
|
||||
function getCacheId(request, withContext) {
|
||||
return JSON.stringify({
|
||||
@@ -22,22 +13,29 @@ function getCacheId(request, withContext) {
|
||||
});
|
||||
}
|
||||
|
||||
UnsafeCachePlugin.prototype.apply = function(resolver) {
|
||||
var filterPredicate = this.filterPredicate;
|
||||
var cache = this.cache;
|
||||
var target = this.target;
|
||||
var withContext = this.withContext;
|
||||
resolver.plugin(this.source, function(request, callback) {
|
||||
if(!filterPredicate(request)) return callback();
|
||||
var cacheId = getCacheId(request, withContext);
|
||||
var cacheEntry = cache[cacheId];
|
||||
if(cacheEntry) {
|
||||
return callback(null, cacheEntry);
|
||||
}
|
||||
resolver.doResolve(target, request, null, createInnerCallback(function(err, result) {
|
||||
if(err) return callback(err);
|
||||
if(result) return callback(null, cache[cacheId] = result);
|
||||
callback();
|
||||
}, callback));
|
||||
});
|
||||
module.exports = class UnsafeCachePlugin {
|
||||
constructor(source, filterPredicate, cache, withContext, target) {
|
||||
this.source = source;
|
||||
this.filterPredicate = filterPredicate;
|
||||
this.withContext = withContext;
|
||||
this.cache = cache || {};
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
apply(resolver) {
|
||||
const target = resolver.ensureHook(this.target);
|
||||
resolver.getHook(this.source).tapAsync("UnsafeCachePlugin", (request, resolveContext, callback) => {
|
||||
if(!this.filterPredicate(request)) return callback();
|
||||
const cacheId = getCacheId(request, this.withContext);
|
||||
const cacheEntry = this.cache[cacheId];
|
||||
if(cacheEntry) {
|
||||
return callback(null, cacheEntry);
|
||||
}
|
||||
resolver.doResolve(target, request, null, resolveContext, (err, result) => {
|
||||
if(err) return callback(err);
|
||||
if(result) return callback(null, this.cache[cacheId] = result);
|
||||
callback();
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user