Skip to content

Commit

Permalink
chore: noop per file (#3544)
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzlopak authored Sep 4, 2024
1 parent 408aa70 commit 4b8958a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
6 changes: 4 additions & 2 deletions lib/api/api-pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ const {
const util = require('../core/util')
const { addSignal, removeSignal } = require('./abort-signal')

function noop () {}

const kResume = Symbol('resume')

class PipelineRequest extends Readable {
Expand Down Expand Up @@ -92,7 +94,7 @@ class PipelineHandler extends AsyncResource {
this.context = null
this.onInfo = onInfo || null

this.req = new PipelineRequest().on('error', util.nop)
this.req = new PipelineRequest().on('error', noop)

this.ret = new Duplex({
readableObjectMode: opts.objectMode,
Expand Down Expand Up @@ -183,7 +185,7 @@ class PipelineHandler extends AsyncResource {
context
})
} catch (err) {
this.res.on('error', util.nop)
this.res.on('error', noop)
throw err
}

Expand Down
6 changes: 4 additions & 2 deletions lib/api/api-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const { Readable } = require('./readable')
const { InvalidArgumentError, RequestAbortedError } = require('../core/errors')
const util = require('../core/util')

function noop () {}

class RequestHandler extends AsyncResource {
constructor (opts, callback) {
if (!opts || typeof opts !== 'object') {
Expand Down Expand Up @@ -38,7 +40,7 @@ class RequestHandler extends AsyncResource {
super('UNDICI_REQUEST')
} catch (err) {
if (util.isStream(body)) {
util.destroy(body.on('error', util.nop), err)
util.destroy(body.on('error', noop), err)
}
throw err
}
Expand Down Expand Up @@ -159,7 +161,7 @@ class RequestHandler extends AsyncResource {
this.body = null

if (util.isStream(body)) {
body.on('error', util.nop)
body.on('error', noop)
util.destroy(body, err)
}
}
Expand Down
4 changes: 3 additions & 1 deletion lib/api/api-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const { InvalidArgumentError, InvalidReturnValueError } = require('../core/error
const util = require('../core/util')
const { addSignal, removeSignal } = require('./abort-signal')

function noop () {}

class StreamHandler extends AsyncResource {
constructor (opts, factory, callback) {
if (!opts || typeof opts !== 'object') {
Expand Down Expand Up @@ -39,7 +41,7 @@ class StreamHandler extends AsyncResource {
super('UNDICI_STREAM')
} catch (err) {
if (util.isStream(body)) {
util.destroy(body.on('error', util.nop), err)
util.destroy(body.on('error', noop), err)
}
throw err
}
Expand Down
3 changes: 0 additions & 3 deletions lib/core/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ function wrapRequestBody (body) {
}
}

function nop () {}

function isStream (obj) {
return obj && typeof obj === 'object' && typeof obj.pipe === 'function' && typeof obj.on === 'function'
}
Expand Down Expand Up @@ -664,7 +662,6 @@ Object.setPrototypeOf(normalizedMethodRecords, null)

module.exports = {
kEnumerableProperty,
nop,
isDisturbed,
toUSVString,
isUSVString,
Expand Down

0 comments on commit 4b8958a

Please sign in to comment.