Skip to content

Commit

Permalink
Move type annotation to the cachedScripts definition
Browse files Browse the repository at this point in the history
  • Loading branch information
wafuwafu13 committed Sep 8, 2021
1 parent 786250c commit 10a57fe
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ const checkDuplicatedNodes = _checkDuplicatedNodes.default;

const EXTERNAL_HELPERS_VERSION = "7.100.0";

const cachedScripts = new QuickLRU({ maxSize: 10 });
const cachedScripts = new QuickLRU<
string,
{ code: string; cachedData?: Buffer }
>({ maxSize: 10 });
const contextModuleCache = new WeakMap();
const sharedTestContext = createContext();

Expand Down Expand Up @@ -82,8 +85,7 @@ function runCacheableScriptInTestContext(
context: vm.Context,
moduleCache: any,
) {
let cached: { code?: string; cachedData?: Buffer } =
cachedScripts.get(filename);
let cached = cachedScripts.get(filename);
if (!cached) {
const code = `(function (exports, require, module, __filename, __dirname) {\n${srcFn()}\n});`;
cached = {
Expand Down

0 comments on commit 10a57fe

Please sign in to comment.