Projektstart
This commit is contained in:
25
backend/node_modules/fastify-plugin/lib/getPluginName.js
generated
vendored
Normal file
25
backend/node_modules/fastify-plugin/lib/getPluginName.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
'use strict'
|
||||
|
||||
const fpStackTracePattern = /at\s{1}(?:.*\.)?plugin\s{1}.*\n\s*(.*)/
|
||||
const fileNamePattern = /(\w*(\.\w*)*)\..*/
|
||||
|
||||
module.exports = function getPluginName (fn) {
|
||||
if (fn.name.length > 0) return fn.name
|
||||
|
||||
const stackTraceLimit = Error.stackTraceLimit
|
||||
Error.stackTraceLimit = 10
|
||||
try {
|
||||
throw new Error('anonymous function')
|
||||
} catch (e) {
|
||||
Error.stackTraceLimit = stackTraceLimit
|
||||
return extractPluginName(e.stack)
|
||||
}
|
||||
}
|
||||
|
||||
function extractPluginName (stack) {
|
||||
const m = stack.match(fpStackTracePattern)
|
||||
|
||||
// get last section of path and match for filename
|
||||
return m ? m[1].split(/[/\\]/).slice(-1)[0].match(fileNamePattern)[1] : 'anonymous'
|
||||
}
|
||||
module.exports.extractPluginName = extractPluginName
|
||||
11
backend/node_modules/fastify-plugin/lib/toCamelCase.js
generated
vendored
Normal file
11
backend/node_modules/fastify-plugin/lib/toCamelCase.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = function toCamelCase (name) {
|
||||
if (name[0] === '@') {
|
||||
name = name.slice(1).replace('/', '-')
|
||||
}
|
||||
const newName = name.replace(/-(.)/g, function (match, g1) {
|
||||
return g1.toUpperCase()
|
||||
})
|
||||
return newName
|
||||
}
|
||||
Reference in New Issue
Block a user