Skip to content

Commit

Permalink
various type improvements
Browse files Browse the repository at this point in the history
Co-authored-by: Jayden Seric <[email protected]>
  • Loading branch information
dburles and jaydenseric committed Oct 18, 2023
1 parent e5c7049 commit 07e23d9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions formatLinkHeaderRelation.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// @ts-check

/**
* Formats a resource as a Link header relation.
* Formats a resource as a `Link` header relation.
* @param {string} resource The resource.
* @returns {string} The formatted Link header relation.
* @returns {string} The formatted `Link` header relation.
*/
export default function formatLinkHeaderRelation(resource) {
return `<${resource}>; rel="modulepreload"`;
Expand Down
6 changes: 3 additions & 3 deletions formatLinkHeaderRelations.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import formatLinkHeaderRelation from "./formatLinkHeaderRelation.mjs";

/**
* Formats an array of resources as a Link header value.
* @param {Array<string>} resources The resources to format.
* @returns {string} The formatted Link header value.
* Formats resources as a `Link` header value.
* @param {Array<string>} resources Resources to format.
* @returns {string} The formatted `Link` header value.
*/
export default function formatLinkHeaderRelations(resources) {
return resources.map(formatLinkHeaderRelation).join(", ");
Expand Down
9 changes: 5 additions & 4 deletions resolveImports.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import { readFile, access } from "node:fs/promises";

/**
* Resolved imports.
* @typedef {string[] | undefined} ResolvedImports
* @typedef {Array<string> | undefined} ResolvedImports
*/

/**
* Checks if a file exists.
* @param {string} module The path to the file.
* @returns {Promise<boolean>} Whether the file exists.
* @returns {Promise<boolean>} Does the file exist.
*/
async function exists(module) {
try {
Expand All @@ -26,11 +26,12 @@ async function exists(module) {
/**
* Recursively parses and resolves a module's imports.
* @param {string} module The path to the module.
* @param {boolean} [root=true] Whether the module is the root module.
* @param {boolean} [root] Whether the module is the root module.
* @returns {Promise<ResolvedImports>} The resolved modules.
*/
export default async function resolveImports(module, root = true) {
let source = "";
/** @type {string | undefined} */
let source;

try {
source = await readFile(module, "utf-8");
Expand Down
2 changes: 1 addition & 1 deletion resolveLinkRelations.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import resolveImportsCached from "./resolveImportsCached.mjs";

/**
* Resolves link relations for a given URL within an `appPath`.
* @param {Object} options Options.
* @param {object} options Options.
* @param {string} options.appPath The path to the app.
* @param {string} options.url The module URL to resolve.
* @returns {Promise<ResolvedImports>} The resolved modules.
Expand Down

0 comments on commit 07e23d9

Please sign in to comment.