move logic below

This commit is contained in:
Simon Knott 2024-09-02 08:42:12 +02:00
parent 2d7ae24de9
commit 1af4bc0b5d
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC

View file

@ -265,21 +265,19 @@ class ExpectMetaInfoProxyHandler implements ProxyHandler<any> {
get(target: Object, matcherName: string | symbol, receiver: any): any { get(target: Object, matcherName: string | symbol, receiver: any): any {
let matcher = Reflect.get(target, matcherName, receiver); let matcher = Reflect.get(target, matcherName, receiver);
if (typeof matcherName !== 'string')
return matcher;
if (typeof matcherName === 'string') { for (const prefix of this._prefixes) {
for (const prefix of this._prefixes) { for (let i = prefix.length; i > 0; i--) {
for (let i = prefix.length; i > 0; i--) { const qualifiedName = qualifiedMatcherName(prefix.slice(0, i), matcherName);
const qualifiedName = qualifiedMatcherName(prefix.slice(0, i), matcherName); if (Reflect.has(target, qualifiedName)) {
if (Reflect.has(target, qualifiedName)) { matcher = Reflect.get(target, qualifiedName, receiver);
matcher = Reflect.get(target, qualifiedName, receiver); break;
break;
}
} }
} }
} }
if (typeof matcherName !== 'string')
return matcher;
if (matcher === undefined) if (matcher === undefined)
throw new Error(`expect: Property '${matcherName}' not found.`); throw new Error(`expect: Property '${matcherName}' not found.`);
if (typeof matcher !== 'function') { if (typeof matcher !== 'function') {