-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
Upgrade xo #130
Upgrade xo #130
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,6 @@ | |
"precise-now": "^3.0.0", | ||
"stream-json": "^1.8.0", | ||
"tsd": "^0.31.0", | ||
"xo": "^0.58.0" | ||
"xo": "^0.59.0" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ export class MaxBufferError extends Error { | |
|
||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
type TextStreamItem = string | Buffer | ArrayBuffer | ArrayBufferView; | ||
// eslint-disable-next-line n/no-unsupported-features/node-builtins | ||
export type AnyStream<SteamItem = TextStreamItem> = Readable | ReadableStream<SteamItem> | AsyncIterable<SteamItem>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
export type Options = { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ import {finished} from 'node:stream/promises'; | |
export {fromAnyIterable as readableStreamFrom} from '@sec-ant/readable-stream/ponyfill'; | ||
|
||
export const createStream = streamDefinition => typeof streamDefinition === 'function' | ||
// eslint-disable-next-line n/no-unsupported-features/node-builtins | ||
? Duplex.from(streamDefinition) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
: Readable.from(streamDefinition); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ import {fixtureString, fixtureBuffer, fixtureUtf16} from './fixtures/index.js'; | |
|
||
const TEST_URL = 'https://nodejs.org/dist/index.json'; | ||
|
||
// eslint-disable-next-line n/no-unsupported-features/node-builtins | ||
const createReadableStream = streamDefinition => Duplex.toWeb(Duplex.from(streamDefinition)).readable; | ||
|
||
test('works with opendir()', async t => { | ||
|
@@ -63,13 +64,15 @@ if (!nodeVersion.startsWith('v16.')) { | |
test('works with readableWebStream({ type: "bytes" })', readableWebStream, 'bytes'); | ||
|
||
test('works with fetch()', async t => { | ||
// eslint-disable-next-line n/no-unsupported-features/node-builtins | ||
const {body} = await fetch(TEST_URL); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
const result = await getStream(body); | ||
const parsedResult = JSON.parse(result); | ||
t.true(Array.isArray(parsedResult)); | ||
}); | ||
|
||
test('can use TextDecoderStream', async t => { | ||
// eslint-disable-next-line n/no-unsupported-features/node-builtins | ||
const textDecoderStream = new TextDecoderStream('utf-16le'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as for |
||
const result = await getStream( | ||
createReadableStream(fixtureUtf16).pipeThrough(textDecoderStream), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -274,6 +274,7 @@ const testMultipleReads = async (t, wait) => { | |
assertSuccess(t, stream, Readable); | ||
}; | ||
|
||
// eslint-disable-next-line n/no-unsupported-features/node-builtins | ||
test('Handles multiple successive fast reads', testMultipleReads, () => scheduler.yield()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as |
||
test('Handles multiple successive slow reads', testMultipleReads, () => pSetTimeout(100)); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
import test from 'ava'; | ||
|
||
// Emulate browsers that do not support those methods | ||
// eslint-disable-next-line n/no-unsupported-features/node-builtins | ||
delete ReadableStream.prototype.values; | ||
// eslint-disable-next-line n/no-unsupported-features/node-builtins | ||
delete ReadableStream.prototype[Symbol.asyncIterator]; | ||
|
||
// Run those tests, but emulating browsers | ||
await import('./web-stream.js'); | ||
|
||
test('Should not polyfill ReadableStream', t => { | ||
// eslint-disable-next-line n/no-unsupported-features/node-builtins | ||
t.is(ReadableStream.prototype.values, undefined); | ||
// eslint-disable-next-line n/no-unsupported-features/node-builtins | ||
t.is(ReadableStream.prototype[Symbol.asyncIterator], undefined); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ArrayBuffer
resizing is not supported in Node 18.However, we check for support before calling this function.