Skip to content

Commit

Permalink
Reduce
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Dec 14, 2022
1 parent 95384ce commit 26c0862
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions crates/swc_ecma_minifier/tests/fixture/issues/6636/input.js
@@ -1,23 +1,8 @@
export function memo(getDeps, fn, opts) {
let deps = [];
export function memo(fn, opts) {
let result;
return () => {
let depTime;
if (opts.key && opts.debug) depTime = Date.now();
const newDeps = getDeps();
const depsChanged = newDeps.length !== deps.length || newDeps.some((dep, index) => deps[index] !== dep);
if (!depsChanged) {
return result;
}
deps = newDeps;
let resultTime;
if (opts.key && opts.debug) resultTime = Date.now();
result = fn(...newDeps);
opts?.onChange?.(result);
if (opts.key && opts.debug) {
if (opts?.debug()) {
}
}
return result;
};
}

0 comments on commit 26c0862

Please sign in to comment.