Skip to content

Commit 4b8958a

Browse files
authored
chore: noop per file (#3544)
1 parent 408aa70 commit 4b8958a

4 files changed

Lines changed: 11 additions & 8 deletions

File tree

lib/api/api-pipeline.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ const {
1515
const util = require('../core/util')
1616
const { addSignal, removeSignal } = require('./abort-signal')
1717

18+
function noop () {}
19+
1820
const kResume = Symbol('resume')
1921

2022
class PipelineRequest extends Readable {
@@ -92,7 +94,7 @@ class PipelineHandler extends AsyncResource {
9294
this.context = null
9395
this.onInfo = onInfo || null
9496

95-
this.req = new PipelineRequest().on('error', util.nop)
97+
this.req = new PipelineRequest().on('error', noop)
9698

9799
this.ret = new Duplex({
98100
readableObjectMode: opts.objectMode,
@@ -183,7 +185,7 @@ class PipelineHandler extends AsyncResource {
183185
context
184186
})
185187
} catch (err) {
186-
this.res.on('error', util.nop)
188+
this.res.on('error', noop)
187189
throw err
188190
}
189191

lib/api/api-request.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ const { Readable } = require('./readable')
66
const { InvalidArgumentError, RequestAbortedError } = require('../core/errors')
77
const util = require('../core/util')
88

9+
function noop () {}
10+
911
class RequestHandler extends AsyncResource {
1012
constructor (opts, callback) {
1113
if (!opts || typeof opts !== 'object') {
@@ -38,7 +40,7 @@ class RequestHandler extends AsyncResource {
3840
super('UNDICI_REQUEST')
3941
} catch (err) {
4042
if (util.isStream(body)) {
41-
util.destroy(body.on('error', util.nop), err)
43+
util.destroy(body.on('error', noop), err)
4244
}
4345
throw err
4446
}
@@ -159,7 +161,7 @@ class RequestHandler extends AsyncResource {
159161
this.body = null
160162

161163
if (util.isStream(body)) {
162-
body.on('error', util.nop)
164+
body.on('error', noop)
163165
util.destroy(body, err)
164166
}
165167
}

lib/api/api-stream.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ const { InvalidArgumentError, InvalidReturnValueError } = require('../core/error
77
const util = require('../core/util')
88
const { addSignal, removeSignal } = require('./abort-signal')
99

10+
function noop () {}
11+
1012
class StreamHandler extends AsyncResource {
1113
constructor (opts, factory, callback) {
1214
if (!opts || typeof opts !== 'object') {
@@ -39,7 +41,7 @@ class StreamHandler extends AsyncResource {
3941
super('UNDICI_STREAM')
4042
} catch (err) {
4143
if (util.isStream(body)) {
42-
util.destroy(body.on('error', util.nop), err)
44+
util.destroy(body.on('error', noop), err)
4345
}
4446
throw err
4547
}

lib/core/util.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ function wrapRequestBody (body) {
6767
}
6868
}
6969

70-
function nop () {}
71-
7270
function isStream (obj) {
7371
return obj && typeof obj === 'object' && typeof obj.pipe === 'function' && typeof obj.on === 'function'
7472
}
@@ -664,7 +662,6 @@ Object.setPrototypeOf(normalizedMethodRecords, null)
664662

665663
module.exports = {
666664
kEnumerableProperty,
667-
nop,
668665
isDisturbed,
669666
toUSVString,
670667
isUSVString,

0 commit comments

Comments
 (0)