MCPcopy
hub / github.com/jestjs/jest / fnNameFor

Function fnNameFor

packages/pretty-format/src/__tests__/AsymmetricMatcher.test.ts:14–21  ·  view source on GitHub ↗
(func: (...any: Array<any>) => unknown)

Source from the content-addressed store, hash-verified

12let options: OptionsReceived;
13
14function fnNameFor(func: (...any: Array<any>) => unknown) {
15 if (func.name) {
16 return func.name;
17 }
18
19 const matches = func.toString().match(/^\s*function\s*(\w*)\s*\(/);
20 return matches ? matches[1] : '<anonymous>';
21}
22
23beforeEach(() => {
24 options = {plugins: [AsymmetricMatcher]};

Callers 1

Calls 2

matchMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected