Skip to content

Commit

Permalink
fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
kaibocai committed Aug 19, 2024
1 parent 200136d commit c1b01f5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/worker/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,14 @@ export class Registry {
}

_getFunctionName(fn: Function): string {
const match = fn.toString().match(/function\s*([^(]*)\(/);
return fn.name || (match ? match[1] : '');
if (fn.name) {
return fn.name;
}

const fnStr = fn.toString();
const start = fnStr.indexOf('function') + 'function'.length;
const end = fnStr.indexOf('(', start);

return fnStr.slice(start, end).trim() || '';
}
}

0 comments on commit c1b01f5

Please sign in to comment.