Skip to content

Commit 8aa2014

Browse files
committed
renaming variable
1 parent a1c7686 commit 8aa2014

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

community/memoize-one/src/5.0.0/transform.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,20 @@ export default function transformer(
2626
call.value.callee.type === 'Identifier' &&
2727
call.value.callee.name === importName,
2828
)
29-
// looking for calls with a custom equality function
3029
// .filter(call => call.value.arguments.length === 2)
3130
.forEach(call => {
32-
const [first, second] = call.value.arguments;
33-
if (second == null) {
31+
const equalityFn = call.value.arguments[1];
32+
// we don't need to do anything for calls without an equality fn
33+
if (equalityFn == null) {
3434
return;
3535
}
3636
// We are going to wrap the existing customEqualityFn in our new one
3737
// 4.0.0 EqualityFn → (a, b) => boolean [called for each argument]
3838
// 5.0.0 EqualityFn → ([newArgs], [lastArgs]) => boolean [called once with all arguments]
3939
if (
40-
second.type === 'FunctionExpression' ||
41-
second.type === 'ArrowFunctionExpression' ||
42-
second.type === 'Identifier'
40+
equalityFn.type === 'FunctionExpression' ||
41+
equalityFn.type === 'ArrowFunctionExpression' ||
42+
equalityFn.type === 'Identifier'
4343
) {
4444
const customEqualityFn = j.arrowFunctionExpression(
4545
[j.identifier('newArgs'), j.identifier('lastArgs')],
@@ -59,7 +59,7 @@ export default function transformer(
5959
j.blockStatement([j.returnStatement(j.booleanLiteral(false))]),
6060
),
6161
j.variableDeclaration('const', [
62-
j.variableDeclarator(j.identifier('__equalityFn'), second),
62+
j.variableDeclarator(j.identifier('__equalityFn'), equalityFn),
6363
]),
6464
j.returnStatement(
6565
j.callExpression(
@@ -86,7 +86,7 @@ export default function transformer(
8686
]),
8787
);
8888

89-
call.value.arguments = [first, customEqualityFn];
89+
call.value.arguments[1] = customEqualityFn;
9090
return;
9191
}
9292
});

0 commit comments

Comments
 (0)