Skip to content

Conversation

@ehmicky
Copy link
Collaborator

@ehmicky ehmicky commented Jul 21, 2024

This PR upgrades xo.

CI currently failing due to actions/node-versions#182

}

// eslint-disable-next-line n/no-unsupported-features/es-syntax
const arrayBuffer = new ArrayBuffer(length, {maxByteLength: getNewContentsLength(length)});
Copy link
Collaborator Author

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.

// 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>;
Copy link
Collaborator Author

@ehmicky ehmicky Jul 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReadableStream is supported in Node 18 but is marked as experimental.
However, it is a web standard, and the Node.js implementation has been pretty stable for a few years now.
This is only used in types, not runtime.


export const createStream = streamDefinition => typeof streamDefinition === 'function'
// eslint-disable-next-line n/no-unsupported-features/node-builtins
? Duplex.from(streamDefinition)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplex.from() is supported in Node 18 but is marked as experimental.
However, its implementation has barely changed in many years now. Also, this is only used in tests.


test('works with fetch()', async t => {
// eslint-disable-next-line n/no-unsupported-features/node-builtins
const {body} = await fetch(TEST_URL);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fetch() support is experimental in Node, but we're only using this in tests.


test('can use TextDecoderStream', async t => {
// eslint-disable-next-line n/no-unsupported-features/node-builtins
const textDecoderStream = new TextDecoderStream('utf-16le');
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as for fetch(), but with TextDecoderStream().

};

// eslint-disable-next-line n/no-unsupported-features/node-builtins
test('Handles multiple successive fast reads', testMultipleReads, () => scheduler.yield());
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as fetch(), but for scheduler.yield().

@sindresorhus sindresorhus merged commit cd27167 into main Jul 21, 2024
@sindresorhus sindresorhus deleted the upgrade-deps branch July 21, 2024 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants