Skip to content

Commit

Permalink
improve matchMethodCall
Browse files Browse the repository at this point in the history
  • Loading branch information
stanislav-atr committed Mar 22, 2024
1 parent c60eb64 commit 12b7134
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/scriptlets/trusted-suppress-native-method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ import {
* @added unknown.
*/
/* eslint-enable max-len */
export function TrustedSuppressNativeMethod(
export function trustedSuppressNativeMethod(
source: Source,
methodPath: string,
signatureStr: string,
Expand Down Expand Up @@ -155,25 +155,25 @@ export function TrustedSuppressNativeMethod(
return;
}

/**
* Matches the incoming arguments with the signature matcher.
*
* @param nativeArguments original arguments of the native method call
* @param matchArguments matcher to match against the native argument
* @returns true, if each of the signature matchers match their corresponding argument.
*/
function matchMethodCall(
nativeArguments: unknown[],
matchArguments: unknown[],
): boolean {
for (let i = 0; i < matchArguments.length; i += 1) {
const matcher = matchArguments[i];
return matchArguments.every((matcher, i) => {
if (matcher === IGNORE_ARG_SYMBOL) {
continue;
return true;
}

const argument = nativeArguments[i];
if (!isValueMatched(argument, matcher)) {
return false;
}

continue;
}

return true;
return isValueMatched(argument, matcher);
});
}

// This flag allows to prevent infinite loops when trapping props that are used by scriptlet's own code.
Expand Down Expand Up @@ -204,11 +204,11 @@ export function TrustedSuppressNativeMethod(
base[prop] = new Proxy(nativeMethod, { apply });
}

TrustedSuppressNativeMethod.names = [
trustedSuppressNativeMethod.names = [
'trusted-suppress-native-method',
];

TrustedSuppressNativeMethod.injections = [
trustedSuppressNativeMethod.injections = [
hit,
logMessage,
getPropertyInChain,
Expand Down

0 comments on commit 12b7134

Please sign in to comment.