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

chore: noop per file #3544

Merged
merged 1 commit into from
Sep 4, 2024
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
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
Loading