Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions benchmarks/warn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict'

const { Suite } = require('benchmark')
const warning = require('..')()

warning.create('FastifyWarning', 'FST_ERROR_CODE_1', 'message')
warning.create('FastifyWarning', 'FST_ERROR_CODE_2', 'message')
warning.create('FastifyWarning', 'FST_ERROR_CODE_3', 'message')
new Suite()
.add('warn', function () {
warning.emit('FST_ERROR_CODE_1')
warning.emit('FST_ERROR_CODE_3')
})
.on('cycle', function (event) {
console.log(String(event.target))
})
.run()
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ function build () {
}

function emit (code, a, b, c) {
if (codes[code] === undefined) throw new Error(`The code '${code}' does not exist`)
if (emitted.get(code) === true) return
if (codes[code] === undefined) throw new Error(`The code '${code}' does not exist`)
emitted.set(code, true)

const warning = codes[code](a, b, c)
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
},
"homepage": "https://github.com/fastify/fastify-warning#readme",
"devDependencies": {
"benchmark": "^2.1.4",
"jest": "^29.0.1",
"standard": "^17.0.0",
"tap": "^16.3.0",
Expand Down