Aktueller Stand
This commit is contained in:
33
backend/node_modules/fastify/lib/decorate.js
generated
vendored
33
backend/node_modules/fastify/lib/decorate.js
generated
vendored
@@ -1,7 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
/* eslint no-prototype-builtins: 0 */
|
||||
|
||||
const {
|
||||
kReply,
|
||||
kRequest,
|
||||
@@ -13,13 +11,13 @@ const {
|
||||
FST_ERR_DEC_ALREADY_PRESENT,
|
||||
FST_ERR_DEC_MISSING_DEPENDENCY,
|
||||
FST_ERR_DEC_AFTER_START,
|
||||
FST_ERR_DEC_DEPENDENCY_INVALID_TYPE
|
||||
FST_ERR_DEC_REFERENCE_TYPE,
|
||||
FST_ERR_DEC_DEPENDENCY_INVALID_TYPE,
|
||||
FST_ERR_DEC_UNDECLARED
|
||||
} = require('./errors')
|
||||
|
||||
const { FSTDEP006 } = require('./warnings')
|
||||
|
||||
function decorate (instance, name, fn, dependencies) {
|
||||
if (Object.prototype.hasOwnProperty.call(instance, name)) {
|
||||
if (Object.hasOwn(instance, name)) {
|
||||
throw new FST_ERR_DEC_ALREADY_PRESENT(name)
|
||||
}
|
||||
|
||||
@@ -35,9 +33,21 @@ function decorate (instance, name, fn, dependencies) {
|
||||
}
|
||||
}
|
||||
|
||||
function getInstanceDecorator (name) {
|
||||
if (!checkExistence(this, name)) {
|
||||
throw new FST_ERR_DEC_UNDECLARED(name, 'instance')
|
||||
}
|
||||
|
||||
if (typeof this[name] === 'function') {
|
||||
return this[name].bind(this)
|
||||
}
|
||||
|
||||
return this[name]
|
||||
}
|
||||
|
||||
function decorateConstructor (konstructor, name, fn, dependencies) {
|
||||
const instance = konstructor.prototype
|
||||
if (Object.prototype.hasOwnProperty.call(instance, name) || hasKey(konstructor, name)) {
|
||||
if (Object.hasOwn(instance, name) || hasKey(konstructor, name)) {
|
||||
throw new FST_ERR_DEC_ALREADY_PRESENT(name)
|
||||
}
|
||||
|
||||
@@ -58,7 +68,7 @@ function decorateConstructor (konstructor, name, fn, dependencies) {
|
||||
|
||||
function checkReferenceType (name, fn) {
|
||||
if (typeof fn === 'object' && fn && !(typeof fn.getter === 'function' || typeof fn.setter === 'function')) {
|
||||
FSTDEP006(name)
|
||||
throw new FST_ERR_DEC_REFERENCE_TYPE(name, typeof fn)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,8 +112,7 @@ function checkDependencies (instance, name, deps) {
|
||||
throw new FST_ERR_DEC_DEPENDENCY_INVALID_TYPE(name)
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-var
|
||||
for (var i = 0; i !== deps.length; ++i) {
|
||||
for (let i = 0; i !== deps.length; ++i) {
|
||||
if (!checkExistence(instance, deps[i])) {
|
||||
throw new FST_ERR_DEC_MISSING_DEPENDENCY(deps[i])
|
||||
}
|
||||
@@ -137,5 +146,7 @@ module.exports = {
|
||||
existReply: checkReplyExistence,
|
||||
dependencies: checkDependencies,
|
||||
decorateReply,
|
||||
decorateRequest
|
||||
decorateRequest,
|
||||
getInstanceDecorator,
|
||||
hasKey
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user