MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / humanizeFunction

Function humanizeFunction

lib/utils.js:542–562  ·  view source on GitHub ↗
(fn)

Source from the content-addressed store, hash-verified

540}
541
542export const humanizeFunction = function (fn) {
543 const fnStr = fn.toString().trim()
544 // Remove arrow function syntax, async, and parentheses
545 let simplified = fnStr
546 .replace(/^async\s*/, '')
547 .replace(/^\([^)]*\)\s*=>/, '')
548 .replace(/^function\s*\([^)]*\)/, '')
549 // Remove curly braces and any whitespace around them
550 .replace(/{\s*(.*)\s*}/, '$1')
551 // Remove return statement
552 .replace(/return\s+/, '')
553 // Remove trailing semicolon
554 .replace(/;$/, '')
555 .trim()
556
557 if (simplified.length > 100) {
558 simplified = simplified.slice(0, 97) + '...'
559 }
560
561 return simplified
562}
563
564/**
565 * Searches through a given data source using the Fuse.js library for fuzzy searching.

Callers 2

expectAllElementsFunction · 0.90
prepareStepFunction · 0.90

Calls 1

toStringMethod · 0.45

Tested by

no test coverage detected