(fn)
| 540 | } |
| 541 | |
| 542 | export 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. |
no test coverage detected