copy-webpack-plugin
Advanced tools
Comparing version 12.0.1 to 12.0.2
@@ -17,4 +17,3 @@ "use strict"; | ||
throttleAll, | ||
memoize, | ||
asyncMemoize | ||
memoize | ||
} = require("./utils"); | ||
@@ -34,3 +33,3 @@ const template = /\[\\*([\w:]+)\\*\]/i; | ||
require("fast-glob")); | ||
const getGlobby = asyncMemoize(async () => { | ||
const getGlobby = memoize(async () => { | ||
// @ts-ignore | ||
@@ -37,0 +36,0 @@ const { |
@@ -123,26 +123,2 @@ "use strict"; | ||
} | ||
/** | ||
* @template T | ||
* @param fn {(function(): any) | undefined} | ||
* @returns {function(): Promise<T>} | ||
*/ | ||
function asyncMemoize(fn) { | ||
let cache = false; | ||
/** @type {T} */ | ||
let result; | ||
return async () => { | ||
if (cache) { | ||
return result; | ||
} | ||
result = await /** @type {function(): any} */fn(); | ||
cache = true; | ||
// Allow to clean up memory for fn | ||
// and all dependent resources | ||
// eslint-disable-next-line no-undefined, no-param-reassign | ||
fn = undefined; | ||
return result; | ||
}; | ||
} | ||
module.exports = { | ||
@@ -152,4 +128,3 @@ stat, | ||
throttleAll, | ||
memoize, | ||
asyncMemoize | ||
memoize | ||
}; |
{ | ||
"name": "copy-webpack-plugin", | ||
"version": "12.0.1", | ||
"version": "12.0.2", | ||
"description": "Copy files && directories with webpack", | ||
@@ -28,5 +28,5 @@ "license": "MIT", | ||
"security": "npm audit --production", | ||
"lint:prettier": "prettier --list-different .", | ||
"lint:prettier": "prettier --cache --list-different .", | ||
"lint:js": "eslint --cache .", | ||
"lint:spelling": "cspell --cache --quiet \"**/*.*\"", | ||
"lint:spelling": "cspell --cache --no-must-find-files --quiet \"**/*.*\"", | ||
"lint:types": "tsc --pretty --noEmit", | ||
@@ -33,0 +33,0 @@ "lint": "npm-run-all -l -p \"lint:**\"", |
@@ -42,7 +42,1 @@ export type InputFileSystem = import("webpack").Compilation["inputFileSystem"]; | ||
export function memoize<T>(fn: (() => any) | undefined): () => T; | ||
/** | ||
* @template T | ||
* @param fn {(function(): any) | undefined} | ||
* @returns {function(): Promise<T>} | ||
*/ | ||
export function asyncMemoize<T>(fn: (() => any) | undefined): () => Promise<T>; |
78101
1386