Skip to content

Commit 563e161

Browse files
Rebuild
1 parent 567da2e commit 563e161

21 files changed

+330
-293
lines changed

lib/internal/streams/end-of-stream.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1+
// Ported from https://github.com/mafintosh/end-of-stream with
2+
// permission from the author, Mathias Buus (@mafintosh).
3+
4+
'use strict'
5+
16
/* replacement start */
27

38
const process = require('process/')
49

510
/* replacement end */
6-
// Ported from https://github.com/mafintosh/end-of-stream with
7-
// permission from the author, Mathias Buus (@mafintosh).
811

9-
;('use strict')
1012
const { AbortError, codes } = require('../../ours/errors')
1113
const { ERR_INVALID_ARG_TYPE, ERR_STREAM_PREMATURE_CLOSE } = codes
1214
const { kEmptyObject, once } = require('../../ours/util')

lib/internal/streams/readable.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
/* replacement start */
2-
3-
const process = require('process/')
4-
5-
/* replacement end */
61
// Copyright Joyent, Inc. and other Node contributors.
72
//
83
// Permission is hereby granted, free of charge, to any person obtaining a
@@ -24,7 +19,14 @@ const process = require('process/')
2419
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
2520
// USE OR OTHER DEALINGS IN THE SOFTWARE.
2621

27-
;('use strict')
22+
'use strict'
23+
24+
/* replacement start */
25+
26+
const process = require('process/')
27+
28+
/* replacement end */
29+
2830
const {
2931
ArrayPrototypeIndexOf,
3032
NumberIsInteger,

lib/internal/streams/utils.js

-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ function isReadableNodeStream(obj, strict = false) {
3030
) // Writable has .pipe.
3131
)
3232
}
33-
3433
function isWritableNodeStream(obj) {
3534
var _obj$_writableState
3635
return !!(
@@ -45,7 +44,6 @@ function isWritableNodeStream(obj) {
4544
) // Duplex
4645
)
4746
}
48-
4947
function isDuplexNodeStream(obj) {
5048
return !!(
5149
obj &&

lib/internal/streams/writable.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
/* replacement start */
2-
3-
const process = require('process/')
4-
5-
/* replacement end */
61
// Copyright Joyent, Inc. and other Node contributors.
72
//
83
// Permission is hereby granted, free of charge, to any person obtaining a
@@ -28,7 +23,14 @@ const process = require('process/')
2823
// Implement an async ._write(chunk, encoding, cb), and it'll handle all
2924
// the drain event emission and buffering.
3025

31-
;('use strict')
26+
'use strict'
27+
28+
/* replacement start */
29+
30+
const process = require('process/')
31+
32+
/* replacement end */
33+
3234
const {
3335
ArrayPrototypeSlice,
3436
Error,

lib/ours/errors.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,8 @@ E(
311311
received = addNumericalSeparator(String(input))
312312
} else if (typeof input === 'bigint') {
313313
received = String(input)
314-
if (input > 2n ** 32n || input < -(2n ** 32n)) {
314+
const limit = BigInt(2) ** BigInt(32)
315+
if (input > limit || input < -limit) {
315316
received = addNumericalSeparator(received)
316317
}
317318
received += 'n'

lib/ours/primordials.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,6 @@ module.exports = {
102102
TypedArrayPrototypeSet(self, buf, len) {
103103
return self.set(buf, len)
104104
},
105-
Boolean: Boolean,
105+
Boolean,
106106
Uint8Array
107107
}

lib/ours/util.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
'use strict'
22

33
const bufferModule = require('buffer')
4+
const {
5+
codes: { ERR_INVALID_ARG_TYPE }
6+
} = require('./errors')
47
const { kResistStopPropagation, SymbolDispose } = require('./primordials')
58
const AbortSignal = globalThis.AbortSignal || require('abort-controller').AbortSignal
69
const AbortController = globalThis.AbortController || require('abort-controller').AbortController
@@ -24,7 +27,9 @@ const validateAbortSignal = (signal, name) => {
2427
}
2528
}
2629
const validateFunction = (value, name) => {
27-
if (typeof value !== 'function') throw new ERR_INVALID_ARG_TYPE(name, 'Function', value)
30+
if (typeof value !== 'function') {
31+
throw new ERR_INVALID_ARG_TYPE(name, 'Function', value)
32+
}
2833
}
2934

3035
// This is a simplified version of AggregateError

lib/stream.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
/* replacement start */
2-
3-
const { Buffer } = require('buffer')
4-
5-
/* replacement end */
61
// Copyright Joyent, Inc. and other Node contributors.
72
//
83
// Permission is hereby granted, free of charge, to any person obtaining a
@@ -24,7 +19,14 @@ const { Buffer } = require('buffer')
2419
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
2520
// USE OR OTHER DEALINGS IN THE SOFTWARE.
2621

27-
;('use strict')
22+
'use strict'
23+
24+
/* replacement start */
25+
26+
const { Buffer } = require('buffer')
27+
28+
/* replacement end */
29+
2830
const { ObjectDefineProperty, ObjectKeys, ReflectApply } = require('./ours/primordials')
2931
const {
3032
promisify: { custom: customPromisify }

test/browser/test-stream2-readable-wrap.js

-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ module.exports = function (test) {
4747
old.emit('data', item)
4848
// console.log('after emit', chunks, flowing);
4949
}
50-
5150
if (chunks <= 0) {
5251
oldEnded = true
5352
// console.log('old end', chunks, flowing);

test/common/fixtures.mjs

+3-15
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
1-
import fixtures from './fixtures.js';
1+
import fixtures from './fixtures.js'
22

3-
const {
4-
fixturesDir,
5-
path,
6-
fileURL,
7-
readSync,
8-
readKey,
9-
} = fixtures;
3+
const { fixturesDir, path, fileURL, readSync, readKey } = fixtures
104

11-
export {
12-
fixturesDir,
13-
path,
14-
fileURL,
15-
readSync,
16-
readKey,
17-
};
5+
export { fixturesDir, path, fileURL, readSync, readKey }

test/common/index.js

-1
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,6 @@ const common = {
866866
get enoughTestMem() {
867867
return require('os').totalmem() > 0x70000000 /* 1.75 Gb */
868868
},
869-
870869
get hasFipsCrypto() {
871870
return hasCrypto && require('crypto').getFips()
872871
},

test/common/index.mjs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { createRequire } from 'module';
1+
import { createRequire } from 'module'
22

3-
const require = createRequire(import.meta.url);
4-
const common = require('./index.js');
3+
const require = createRequire(import.meta.url)
4+
const common = require('./index.js')
55

66
const {
77
allowGlobals,
@@ -50,10 +50,10 @@ const {
5050
skipIfDumbTerminal,
5151
skipIfEslintMissing,
5252
skipIfInspectorDisabled,
53-
spawnPromisified,
54-
} = common;
53+
spawnPromisified
54+
} = common
5555

56-
const getPort = () => common.PORT;
56+
const getPort = () => common.PORT
5757

5858
export {
5959
allowGlobals,
@@ -104,5 +104,5 @@ export {
104104
skipIfDumbTerminal,
105105
skipIfEslintMissing,
106106
skipIfInspectorDisabled,
107-
spawnPromisified,
108-
};
107+
spawnPromisified
108+
}
+59-41
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,82 @@
1-
import '../common/index.mjs';
2-
import { Readable }from '../../lib/ours/index.js';
3-
import { deepStrictEqual, rejects, throws } from 'assert';
4-
import tap from 'tap';
1+
import '../common/index.mjs'
2+
import { Readable } from '../../lib/ours/index.js'
3+
import { deepStrictEqual, rejects, throws } from 'assert'
4+
import tap from 'tap'
55

66
{
77
// asIndexedPairs with a synchronous stream
8-
const pairs = await Readable.from([1, 2, 3]).asIndexedPairs().toArray();
9-
deepStrictEqual(pairs, [[0, 1], [1, 2], [2, 3]]);
10-
const empty = await Readable.from([]).asIndexedPairs().toArray();
11-
deepStrictEqual(empty, []);
8+
const pairs = await Readable.from([1, 2, 3]).asIndexedPairs().toArray()
9+
deepStrictEqual(pairs, [
10+
[0, 1],
11+
[1, 2],
12+
[2, 3]
13+
])
14+
const empty = await Readable.from([]).asIndexedPairs().toArray()
15+
deepStrictEqual(empty, [])
1216
}
1317

1418
{
1519
// asIndexedPairs works an asynchronous streams
16-
const asyncFrom = (...args) => Readable.from(...args).map(async (x) => x);
17-
const pairs = await asyncFrom([1, 2, 3]).asIndexedPairs().toArray();
18-
deepStrictEqual(pairs, [[0, 1], [1, 2], [2, 3]]);
19-
const empty = await asyncFrom([]).asIndexedPairs().toArray();
20-
deepStrictEqual(empty, []);
20+
const asyncFrom = (...args) => Readable.from(...args).map(async (x) => x)
21+
const pairs = await asyncFrom([1, 2, 3]).asIndexedPairs().toArray()
22+
deepStrictEqual(pairs, [
23+
[0, 1],
24+
[1, 2],
25+
[2, 3]
26+
])
27+
const empty = await asyncFrom([]).asIndexedPairs().toArray()
28+
deepStrictEqual(empty, [])
2129
}
2230

2331
{
2432
// Does not enumerate an infinite stream
25-
const infinite = () => Readable.from(async function* () {
26-
while (true) yield 1;
27-
}());
28-
const pairs = await infinite().asIndexedPairs().take(3).toArray();
29-
deepStrictEqual(pairs, [[0, 1], [1, 1], [2, 1]]);
30-
const empty = await infinite().asIndexedPairs().take(0).toArray();
31-
deepStrictEqual(empty, []);
33+
const infinite = () =>
34+
Readable.from(
35+
(async function* () {
36+
while (true) yield 1
37+
})()
38+
)
39+
const pairs = await infinite().asIndexedPairs().take(3).toArray()
40+
deepStrictEqual(pairs, [
41+
[0, 1],
42+
[1, 1],
43+
[2, 1]
44+
])
45+
const empty = await infinite().asIndexedPairs().take(0).toArray()
46+
deepStrictEqual(empty, [])
3247
}
3348

3449
{
3550
// AbortSignal
36-
await rejects(async () => {
37-
const ac = new AbortController();
38-
const { signal } = ac;
39-
const p = Readable.from([1, 2, 3]).asIndexedPairs({ signal }).toArray();
40-
ac.abort();
41-
await p;
42-
}, { name: 'AbortError' });
51+
await rejects(
52+
async () => {
53+
const ac = new AbortController()
54+
const { signal } = ac
55+
const p = Readable.from([1, 2, 3]).asIndexedPairs({ signal }).toArray()
56+
ac.abort()
57+
await p
58+
},
59+
{ name: 'AbortError' }
60+
)
4361

4462
await rejects(async () => {
45-
const signal = AbortSignal.abort();
46-
await Readable.from([1, 2, 3]).asIndexedPairs({ signal }).toArray();
47-
}, /AbortError/);
63+
const signal = AbortSignal.abort()
64+
await Readable.from([1, 2, 3]).asIndexedPairs({ signal }).toArray()
65+
}, /AbortError/)
4866
}
4967

5068
{
5169
// Error cases
52-
throws(() => Readable.from([1]).asIndexedPairs(1), /ERR_INVALID_ARG_TYPE/);
53-
throws(() => Readable.from([1]).asIndexedPairs({ signal: true }), /ERR_INVALID_ARG_TYPE/);
70+
throws(() => Readable.from([1]).asIndexedPairs(1), /ERR_INVALID_ARG_TYPE/)
71+
throws(() => Readable.from([1]).asIndexedPairs({ signal: true }), /ERR_INVALID_ARG_TYPE/)
5472
}
5573

56-
/* replacement start */
57-
process.on('beforeExit', (code) => {
58-
if(code === 0) {
59-
tap.pass('test succeeded');
60-
} else {
61-
tap.fail(`test failed - exited code ${code}`);
62-
}
63-
});
64-
/* replacement end */
74+
/* replacement start */
75+
process.on('beforeExit', (code) => {
76+
if (code === 0) {
77+
tap.pass('test succeeded')
78+
} else {
79+
tap.fail(`test failed - exited code ${code}`)
80+
}
81+
})
82+
/* replacement end */

0 commit comments

Comments
 (0)