Skip to content

Commit

Permalink
functional
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzlopak committed Dec 10, 2023
1 parent 39b155e commit dbcfe02
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions benchmarks/warn.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const err2 = createWarning('FastifyWarning', 'FST_ERROR_CODE_2', 'message')

new Suite()
.add('warn', function () {
err1.emit()
err2.emit()
err1()
err2()
})
.on('cycle', function (event) {
console.log(String(event.target))
Expand Down
2 changes: 1 addition & 1 deletion examples/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ const { createWarning } = require('..')

const CUSTDEP001 = createWarning('DeprecationWarning', 'CUSTDEP001', 'This is a deprecation warning')

CUSTDEP001.emit()
CUSTDEP001()
4 changes: 2 additions & 2 deletions test/emit-interpolated-string.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ test('emit with interpolated string', t => {
}

const codeWarning = createWarning('FastifyDeprecation', 'CODE', 'Hello %s')
codeWarning.emit('world')
codeWarning.emit('world')
codeWarning('world')
codeWarning('world')

setImmediate(() => {
process.removeListener('warning', onWarning)
Expand Down
4 changes: 2 additions & 2 deletions test/emit-once-only.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ test('emit should emit a given code only once', t => {
}

const warn = createWarning('FastifyDeprecation', 'CODE', 'Hello world')
warn.emit()
warn.emit()
warn()
warn()
setImmediate(() => {
process.removeListener('warning', onWarning)
t.end()
Expand Down
2 changes: 1 addition & 1 deletion test/emit-set.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ test('emit should set the emitted state', t => {
warn.emitted = true
t.ok(warn.emitted)

warn.emit()
warn()
t.ok(warn.emitted)

setImmediate(() => {
Expand Down
2 changes: 1 addition & 1 deletion test/emit-unlimited.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ test('emit should emit a given code unlimited times', t => {

for (let i = 0; i < times; i++) {
expectedRun.push(i)
warn.emit()
warn()
}
setImmediate(() => {
process.removeListener('warning', onWarning)
Expand Down
4 changes: 2 additions & 2 deletions test/issue-88.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ test('Must not overwrite config', t => {
createWarning('FastifyWarning', 'CODE_2', 'Msg', { unlimited: true })

process.on('warning', onWarning)
a.emit('CODE_1')
a.emit('CODE_1')
a('CODE_1')
a('CODE_1')

setImmediate(() => {
process.removeListener('warning', onWarning)
Expand Down
2 changes: 1 addition & 1 deletion test/jest.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { createWarning } = require('..')

test('works with jest', done => {
const code = createWarning('FastifyDeprecation', 'CODE', 'Hello %s')
code.emit('world')
code('world')

// we cannot actually listen to process warning event
// because jest messes with it (that's the point of this test)
Expand Down

0 comments on commit dbcfe02

Please sign in to comment.