mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 10:15:07 +08:00
stream: fix fromSync() async input error messages
The ERR_INVALID_ARG_TYPE messages for async iterable and promise inputs read "must be an a synchronous input (not AsyncIterable)", because the error formatter adds "an" to expected-type strings that contain uppercase letters. Rephrase them in lowercase. Assisted-by: OpenCode Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: https://github.com/nodejs/node/pull/66483 Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
1 parent
1caad8efb4
commit
b5a14634e5
2 files changed
+10
-5
No files matched your search
@@ -738,7 +738,7 @@ function fromSync(input) {
|
||||
if (!isIterable && isAsyncIterable(input)) {
|
||||
throw new ERR_INVALID_ARG_TYPE(
|
||||
'input',
|
||||
'a synchronous input (not AsyncIterable)',
|
||||
'a synchronous input, not an async iterable',
|
||||
input,
|
||||
);
|
||||
}
|
||||
@@ -748,7 +748,7 @@ function fromSync(input) {
|
||||
typeof input.then === 'function') {
|
||||
throw new ERR_INVALID_ARG_TYPE(
|
||||
'input',
|
||||
'a synchronous input (not Promise)',
|
||||
'a synchronous input, not a promise',
|
||||
input,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -183,7 +183,10 @@ function testFromSyncIgnoresAsyncStreamable() {
|
||||
// Explicit async iterable rejected
|
||||
function testFromSyncRejectsAsyncIterable() {
|
||||
async function* gen() { yield [new TextEncoder().encode('a')]; }
|
||||
assert.throws(() => fromSync(gen()), { code: 'ERR_INVALID_ARG_TYPE' });
|
||||
assert.throws(() => fromSync(gen()), {
|
||||
code: 'ERR_INVALID_ARG_TYPE',
|
||||
message: /must be a synchronous input, not an async iterable\./,
|
||||
});
|
||||
}
|
||||
|
||||
function testFromSyncPrefersIteratorForDualIterable() {
|
||||
@@ -212,8 +215,10 @@ function testFromSyncPrefersIteratorForThenableIterable() {
|
||||
|
||||
// Promise rejected
|
||||
function testFromSyncRejectsPromise() {
|
||||
assert.throws(() => fromSync(Promise.resolve('hello')),
|
||||
{ code: 'ERR_INVALID_ARG_TYPE' });
|
||||
assert.throws(() => fromSync(Promise.resolve('hello')), {
|
||||
code: 'ERR_INVALID_ARG_TYPE',
|
||||
message: /must be a synchronous input, not a promise\./,
|
||||
});
|
||||
}
|
||||
|
||||
// DataView input should be converted to Uint8Array (zero-copy)
|
||||
|
||||
Reference in new issue
Block a user