Skip to content

Commit 6efcd35

Browse files
authored
chore: just build to fix whitespace issues (#498)
1 parent 7fdb3b4 commit 6efcd35

File tree

269 files changed

+1944
-4634
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

269 files changed

+1944
-4634
lines changed

lib/_stream_duplex.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
'use strict' // Keep this file as an alias for the full stream module.
1+
'use strict'
22

3+
// Keep this file as an alias for the full stream module.
34
module.exports = require('./stream').Duplex

lib/_stream_passthrough.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
'use strict' // Keep this file as an alias for the full stream module.
1+
'use strict'
22

3+
// Keep this file as an alias for the full stream module.
34
module.exports = require('./stream').PassThrough

lib/_stream_readable.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
'use strict' // Keep this file as an alias for the full stream module.
1+
'use strict'
22

3+
// Keep this file as an alias for the full stream module.
34
module.exports = require('./stream').Readable

lib/_stream_transform.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
'use strict' // Keep this file as an alias for the full stream module.
1+
'use strict'
22

3+
// Keep this file as an alias for the full stream module.
34
module.exports = require('./stream').Transform

lib/_stream_writable.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
'use strict' // Keep this file as an alias for the full stream module.
1+
'use strict'
22

3+
// Keep this file as an alias for the full stream module.
34
module.exports = require('./stream').Writable
Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,43 @@
11
'use strict'
22

33
const { AbortError, codes } = require('../../ours/errors')
4-
54
const eos = require('./end-of-stream')
5+
const { ERR_INVALID_ARG_TYPE } = codes
66

7-
const { ERR_INVALID_ARG_TYPE } = codes // This method is inlined here for readable-stream
7+
// This method is inlined here for readable-stream
88
// It also does not allow for signal to not exist on the stream
99
// https://github.com/nodejs/node/pull/36061#discussion_r533718029
10-
1110
const validateAbortSignal = (signal, name) => {
1211
if (typeof signal !== 'object' || !('aborted' in signal)) {
1312
throw new ERR_INVALID_ARG_TYPE(name, 'AbortSignal', signal)
1413
}
1514
}
16-
1715
function isNodeStream(obj) {
1816
return !!(obj && typeof obj.pipe === 'function')
1917
}
20-
2118
module.exports.addAbortSignal = function addAbortSignal(signal, stream) {
2219
validateAbortSignal(signal, 'signal')
23-
2420
if (!isNodeStream(stream)) {
2521
throw new ERR_INVALID_ARG_TYPE('stream', 'stream.Stream', stream)
2622
}
27-
2823
return module.exports.addAbortSignalNoValidate(signal, stream)
2924
}
30-
3125
module.exports.addAbortSignalNoValidate = function (signal, stream) {
3226
if (typeof signal !== 'object' || !('aborted' in signal)) {
3327
return stream
3428
}
35-
3629
const onAbort = () => {
3730
stream.destroy(
3831
new AbortError(undefined, {
3932
cause: signal.reason
4033
})
4134
)
4235
}
43-
4436
if (signal.aborted) {
4537
onAbort()
4638
} else {
4739
signal.addEventListener('abort', onAbort)
4840
eos(stream, () => signal.removeEventListener('abort', onAbort))
4941
}
50-
5142
return stream
5243
}

lib/internal/streams/buffer_list.js

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
'use strict'
22

33
const { StringPrototypeSlice, SymbolIterator, TypedArrayPrototypeSet, Uint8Array } = require('../../ours/primordials')
4-
54
const { Buffer } = require('buffer')
6-
75
const { inspect } = require('../../ours/util')
8-
96
module.exports = class BufferList {
107
constructor() {
118
this.head = null
129
this.tail = null
1310
this.length = 0
1411
}
15-
1612
push(v) {
1713
const entry = {
1814
data: v,
@@ -23,7 +19,6 @@ module.exports = class BufferList {
2319
this.tail = entry
2420
++this.length
2521
}
26-
2722
unshift(v) {
2823
const entry = {
2924
data: v,
@@ -33,7 +28,6 @@ module.exports = class BufferList {
3328
this.head = entry
3429
++this.length
3530
}
36-
3731
shift() {
3832
if (this.length === 0) return
3933
const ret = this.head.data
@@ -42,73 +36,62 @@ module.exports = class BufferList {
4236
--this.length
4337
return ret
4438
}
45-
4639
clear() {
4740
this.head = this.tail = null
4841
this.length = 0
4942
}
50-
5143
join(s) {
5244
if (this.length === 0) return ''
5345
let p = this.head
5446
let ret = '' + p.data
55-
5647
while ((p = p.next) !== null) ret += s + p.data
57-
5848
return ret
5949
}
60-
6150
concat(n) {
6251
if (this.length === 0) return Buffer.alloc(0)
6352
const ret = Buffer.allocUnsafe(n >>> 0)
6453
let p = this.head
6554
let i = 0
66-
6755
while (p) {
6856
TypedArrayPrototypeSet(ret, p.data, i)
6957
i += p.data.length
7058
p = p.next
7159
}
72-
7360
return ret
74-
} // Consumes a specified amount of bytes or characters from the buffered data.
61+
}
7562

63+
// Consumes a specified amount of bytes or characters from the buffered data.
7664
consume(n, hasStrings) {
7765
const data = this.head.data
78-
7966
if (n < data.length) {
8067
// `slice` is the same for buffers and strings.
8168
const slice = data.slice(0, n)
8269
this.head.data = data.slice(n)
8370
return slice
8471
}
85-
8672
if (n === data.length) {
8773
// First chunk is a perfect match.
8874
return this.shift()
89-
} // Result spans more than one buffer.
90-
75+
}
76+
// Result spans more than one buffer.
9177
return hasStrings ? this._getString(n) : this._getBuffer(n)
9278
}
93-
9479
first() {
9580
return this.head.data
9681
}
97-
9882
*[SymbolIterator]() {
9983
for (let p = this.head; p; p = p.next) {
10084
yield p.data
10185
}
102-
} // Consumes a specified amount of characters from the buffered data.
86+
}
10387

88+
// Consumes a specified amount of characters from the buffered data.
10489
_getString(n) {
10590
let ret = ''
10691
let p = this.head
10792
let c = 0
108-
10993
do {
11094
const str = p.data
111-
11295
if (n > str.length) {
11396
ret += str
11497
n -= str.length
@@ -123,26 +106,22 @@ module.exports = class BufferList {
123106
this.head = p
124107
p.data = StringPrototypeSlice(str, n)
125108
}
126-
127109
break
128110
}
129-
130111
++c
131112
} while ((p = p.next) !== null)
132-
133113
this.length -= c
134114
return ret
135-
} // Consumes a specified amount of bytes from the buffered data.
115+
}
136116

117+
// Consumes a specified amount of bytes from the buffered data.
137118
_getBuffer(n) {
138119
const ret = Buffer.allocUnsafe(n)
139120
const retLen = n
140121
let p = this.head
141122
let c = 0
142-
143123
do {
144124
const buf = p.data
145-
146125
if (n > buf.length) {
147126
TypedArrayPrototypeSet(ret, buf, retLen - n)
148127
n -= buf.length
@@ -157,17 +136,15 @@ module.exports = class BufferList {
157136
this.head = p
158137
p.data = buf.slice(n)
159138
}
160-
161139
break
162140
}
163-
164141
++c
165142
} while ((p = p.next) !== null)
166-
167143
this.length -= c
168144
return ret
169-
} // Make sure the linked list only shows the minimal necessary information.
145+
}
170146

147+
// Make sure the linked list only shows the minimal necessary information.
171148
[Symbol.for('nodejs.util.inspect.custom')](_, options) {
172149
return inspect(this, {
173150
...options,

lib/internal/streams/compose.js

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,48 @@
11
'use strict'
22

33
const { pipeline } = require('./pipeline')
4-
54
const Duplex = require('./duplex')
6-
75
const { destroyer } = require('./destroy')
8-
96
const { isNodeStream, isReadable, isWritable } = require('./utils')
10-
117
const {
128
AbortError,
139
codes: { ERR_INVALID_ARG_VALUE, ERR_MISSING_ARGS }
1410
} = require('../../ours/errors')
15-
1611
module.exports = function compose(...streams) {
1712
if (streams.length === 0) {
1813
throw new ERR_MISSING_ARGS('streams')
1914
}
20-
2115
if (streams.length === 1) {
2216
return Duplex.from(streams[0])
2317
}
24-
2518
const orgStreams = [...streams]
26-
2719
if (typeof streams[0] === 'function') {
2820
streams[0] = Duplex.from(streams[0])
2921
}
30-
3122
if (typeof streams[streams.length - 1] === 'function') {
3223
const idx = streams.length - 1
3324
streams[idx] = Duplex.from(streams[idx])
3425
}
35-
3626
for (let n = 0; n < streams.length; ++n) {
3727
if (!isNodeStream(streams[n])) {
3828
// TODO(ronag): Add checks for non streams.
3929
continue
4030
}
41-
4231
if (n < streams.length - 1 && !isReadable(streams[n])) {
4332
throw new ERR_INVALID_ARG_VALUE(`streams[${n}]`, orgStreams[n], 'must be readable')
4433
}
45-
4634
if (n > 0 && !isWritable(streams[n])) {
4735
throw new ERR_INVALID_ARG_VALUE(`streams[${n}]`, orgStreams[n], 'must be writable')
4836
}
4937
}
50-
5138
let ondrain
5239
let onfinish
5340
let onreadable
5441
let onclose
5542
let d
56-
5743
function onfinished(err) {
5844
const cb = onclose
5945
onclose = null
60-
6146
if (cb) {
6247
cb(err)
6348
} else if (err) {
@@ -66,22 +51,21 @@ module.exports = function compose(...streams) {
6651
d.destroy()
6752
}
6853
}
69-
7054
const head = streams[0]
7155
const tail = pipeline(streams, onfinished)
7256
const writable = !!isWritable(head)
73-
const readable = !!isReadable(tail) // TODO(ronag): Avoid double buffering.
57+
const readable = !!isReadable(tail)
58+
59+
// TODO(ronag): Avoid double buffering.
7460
// Implement Writable/Readable/Duplex traits.
7561
// See, https://github.com/nodejs/node/pull/33515.
76-
7762
d = new Duplex({
7863
// TODO (ronag): highWaterMark?
7964
writableObjectMode: !!(head !== null && head !== undefined && head.writableObjectMode),
8065
readableObjectMode: !!(tail !== null && tail !== undefined && tail.writableObjectMode),
8166
writable,
8267
readable
8368
})
84-
8569
if (writable) {
8670
d._write = function (chunk, encoding, callback) {
8771
if (head.write(chunk, encoding)) {
@@ -90,12 +74,10 @@ module.exports = function compose(...streams) {
9074
ondrain = callback
9175
}
9276
}
93-
9477
d._final = function (callback) {
9578
head.end()
9679
onfinish = callback
9780
}
98-
9981
head.on('drain', function () {
10082
if (ondrain) {
10183
const cb = ondrain
@@ -111,7 +93,6 @@ module.exports = function compose(...streams) {
11193
}
11294
})
11395
}
114-
11596
if (readable) {
11697
tail.on('readable', function () {
11798
if (onreadable) {
@@ -123,39 +104,32 @@ module.exports = function compose(...streams) {
123104
tail.on('end', function () {
124105
d.push(null)
125106
})
126-
127107
d._read = function () {
128108
while (true) {
129109
const buf = tail.read()
130-
131110
if (buf === null) {
132111
onreadable = d._read
133112
return
134113
}
135-
136114
if (!d.push(buf)) {
137115
return
138116
}
139117
}
140118
}
141119
}
142-
143120
d._destroy = function (err, callback) {
144121
if (!err && onclose !== null) {
145122
err = new AbortError()
146123
}
147-
148124
onreadable = null
149125
ondrain = null
150126
onfinish = null
151-
152127
if (onclose === null) {
153128
callback(err)
154129
} else {
155130
onclose = callback
156131
destroyer(tail, err)
157132
}
158133
}
159-
160134
return d
161135
}

0 commit comments

Comments
 (0)