MCPcopy Create free account
hub / github.com/fastify/fastify / getPluginName

Function getPluginName

lib/plugin-utils.js:23–50  ·  view source on GitHub ↗
(func)

Source from the content-addressed store, hash-verified

21}
22
23function getPluginName (func) {
24 const display = getDisplayName(func)
25 if (display) {
26 return display
27 }
28
29 // let's see if this is a file, and in that case use that
30 // this is common for plugins
31 const cache = require.cache
32 // cache is undefined inside SEA
33 if (cache) {
34 const keys = Object.keys(cache)
35
36 for (let i = 0; i < keys.length; i++) {
37 const key = keys[i]
38 if (cache[key].exports === func) {
39 return key
40 }
41 }
42 }
43
44 // if not maybe it's a named function, so use that
45 if (func.name) {
46 return func.name
47 }
48
49 return null
50}
51
52function getFuncPreview (func) {
53 // takes the first two lines of the function if nothing else works

Callers 1

registerPluginFunction · 0.85

Calls 1

getDisplayNameFunction · 0.85

Tested by

no test coverage detected