Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extract noop #215

Closed
wants to merge 2 commits into from
Closed
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
3 changes: 1 addition & 2 deletions boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const {
const TimeTree = require('./time-tree')
const Plugin = require('./plugin')
const { debug } = require('./lib/debug')
const { noop } = require('./lib/noop')
const kAvvio = Symbol('kAvvio')
const kThenifyDoNotWrap = Symbol('kThenifyDoNotWrap')

Expand Down Expand Up @@ -370,8 +371,6 @@ Boot.prototype.toJSON = function () {
return this.pluginTree.toJSON()
}

function noop () { }

function thenify () {
// If the instance is ready, then there is
// nothing to await. This is true during
Expand Down
11 changes: 11 additions & 0 deletions lib/noop.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict'

/**
* @function noop
* @returns {void}
*/
function noop () {}

module.exports = {
noop
}
3 changes: 1 addition & 2 deletions plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const fastq = require('fastq')
const EE = require('events').EventEmitter
const inherits = require('util').inherits
const { debug } = require('./lib/debug')
const { noop } = require('./lib/noop')
const { AVV_ERR_READY_TIMEOUT } = require('./lib/errors')

// this symbol is assigned by fastify-plugin
Expand Down Expand Up @@ -277,7 +278,5 @@ function loadPlugin (toLoad, cb) {
})
}

function noop () {}

module.exports = Plugin
module.exports.loadPlugin = loadPlugin
2 changes: 1 addition & 1 deletion test/events-listeners.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const { test } = require('tap')
const boot = require('..')
const noop = () => {}
const { noop } = require('../lib/noop')

test('boot a plugin and then execute a call after that', (t) => {
t.plan(1)
Expand Down
5 changes: 2 additions & 3 deletions test/override.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/* eslint no-prototype-builtins: off */

const { test } = require('tap')
const { noop } = require('../lib/noop')
const boot = require('..')

test('custom inheritance', (t) => {
Expand Down Expand Up @@ -151,8 +152,6 @@ test('custom inheritance multiple levels with multiple heads', (t) => {
test('fastify test case', (t) => {
t.plan(7)

const noop = () => {}

function build () {
const app = boot(server, {})
app.override = function (s) {
Expand All @@ -167,7 +166,7 @@ test('fastify test case', (t) => {

return server

function server (req, res) {}
function server (req, res) { }
}

const instance = build()
Expand Down