Skip to content

Commit

Permalink
Use the node: URL scheme for Node.js builtin module imports.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaydenseric committed Sep 1, 2022
1 parent 13fde60 commit ac7415c
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion GraphQLUpload.test.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-check

import { doesNotThrow, throws } from "assert";
import { parseValue } from "graphql";
import { doesNotThrow, throws } from "node:assert";

import GraphQLUpload from "./GraphQLUpload.mjs";
import Upload from "./Upload.mjs";
Expand Down
2 changes: 1 addition & 1 deletion Upload.test.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-check

import { ok, rejects, strictEqual } from "assert";
import { ok, rejects, strictEqual } from "node:assert";

import Upload from "./Upload.mjs";

Expand Down
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Patch

- Updated dev dependencies.
- Use the `node:` URL scheme for Node.js builtin module imports.
- Improved JSDoc in the module `GraphQLUpload.mjs`.
- Revamped the readme:
- Removed the badges.
Expand Down
4 changes: 2 additions & 2 deletions graphqlUploadExpress.test.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// @ts-check

import { deepStrictEqual, ok, strictEqual } from "assert";
import express from "express";
import { createServer } from "http";
import createError from "http-errors";
import { deepStrictEqual, ok, strictEqual } from "node:assert";
import { createServer } from "node:http";
import fetch, { File, FormData } from "node-fetch";

import graphqlUploadExpress from "./graphqlUploadExpress.mjs";
Expand Down
4 changes: 2 additions & 2 deletions graphqlUploadKoa.test.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// @ts-check

import { deepStrictEqual, ok, strictEqual } from "assert";
import { createServer } from "http";
import Koa from "koa";
import { deepStrictEqual, ok, strictEqual } from "node:assert";
import { createServer } from "node:http";
import fetch, { File, FormData } from "node-fetch";

import graphqlUploadKoa from "./graphqlUploadKoa.mjs";
Expand Down
2 changes: 1 addition & 1 deletion ignoreStream.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/**
* Safely ignores a Node.js readable stream.
* @param {import("stream").Readable} stream Node.js readable stream.
* @param {import("node:stream").Readable} stream Node.js readable stream.
*/
export default function ignoreStream(stream) {
// Prevent an unhandled error from crashing the process.
Expand Down
2 changes: 1 addition & 1 deletion ignoreStream.test.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-check

import { doesNotThrow, strictEqual } from "assert";
import { doesNotThrow, strictEqual } from "node:assert";

import ignoreStream from "./ignoreStream.mjs";
import CountReadableStream from "./test/CountReadableStream.mjs";
Expand Down
6 changes: 3 additions & 3 deletions processRequest.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ export default function processRequest(
* all resolvers have resolved, or after an error has interrupted the request.
* @callback FileUploadCreateReadStream
* @param {FileUploadCreateReadStreamOptions} [options] Options.
* @returns {import("stream").Readable}
* @returns {import("node:stream").Readable}
* [Node.js readable stream](https://nodejs.org/api/stream.html#readable-streams)
* of the file’s contents.
* @see [Node.js `Readable` stream constructor docs](https://nodejs.org/api/stream.html#new-streamreadableoptions).
Expand Down Expand Up @@ -399,9 +399,9 @@ export default function processRequest(
* Processes an incoming
* [GraphQL multipart request](https://github.com/jaydenseric/graphql-multipart-request-spec).
* @callback ProcessRequestFunction
* @param {import("http").IncomingMessage} request
* @param {import("node:http").IncomingMessage} request
* [Node.js HTTP server request instance](https://nodejs.org/api/http.html#http_class_http_incomingmessage).
* @param {import("http").ServerResponse} response
* @param {import("node:http").ServerResponse} response
* [Node.js HTTP server response instance](https://nodejs.org/api/http.html#http_class_http_serverresponse).
* @param {ProcessRequestOptions} [options] Options.
* @returns {Promise<
Expand Down
6 changes: 3 additions & 3 deletions processRequest.test.mjs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// @ts-check

import { ReadStream } from "fs-capacitor";
import {
deepStrictEqual,
notStrictEqual,
ok,
rejects,
strictEqual,
throws,
} from "assert";
import { ReadStream } from "fs-capacitor";
import { createServer } from "http";
} from "node:assert";
import { createServer } from "node:http";
import fetch, { File, FormData } from "node-fetch";

import processRequest from "./processRequest.mjs";
Expand Down
4 changes: 2 additions & 2 deletions test/CountReadableStream.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// @ts-check

import { Readable } from "stream";
import { Readable } from "node:stream";

/**
* A count readable stream, for testing purposes.
* @see [Example counting stream in the Node.js docs](https://nodejs.org/api/stream.html#an-example-counting-stream).
*/
export default class CountReadableStream extends Readable {
/** @param {import("stream").ReadableOptions} [options] */
/** @param {import("node:stream").ReadableOptions} [options] */
constructor(options) {
super(options);
this._max = 1000000;
Expand Down
2 changes: 1 addition & 1 deletion test/abortingMultipartRequest.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// @ts-check

import { FormDataEncoder } from "form-data-encoder";
import { Readable } from "node:stream";
import nodeAbortController from "node-abort-controller";
import fetch, { AbortError } from "node-fetch";
import { Readable } from "stream";

const AbortController =
globalThis.AbortController || nodeAbortController.AbortController;
Expand Down
4 changes: 2 additions & 2 deletions test/listen.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/**
* Starts a Node.js HTTP server.
* @param {import("http").Server} server Node.js HTTP server.
* @param {import("node:http").Server} server Node.js HTTP server.
* @returns Resolves the port the server is listening on, and a server close
* function.
*/
Expand All @@ -12,7 +12,7 @@ export default async function listen(server) {
});

return {
port: /** @type {import("net").AddressInfo} */ (server.address()).port,
port: /** @type {import("node:net").AddressInfo} */ (server.address()).port,
close: () => server.close(),
};
}
2 changes: 1 addition & 1 deletion test/streamToString.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/**
* Converts a Node.js readable stream to a string.
* @param {import("stream").Readable} stream Node.js readable stream.
* @param {import("node:stream").Readable} stream Node.js readable stream.
* @returns {Promise<string>} Resolves the final string.
*/
export default function streamToString(stream) {
Expand Down

0 comments on commit ac7415c

Please sign in to comment.