Skip to content

Commit

Permalink
chore: add jsdoc type checking
Browse files Browse the repository at this point in the history
  • Loading branch information
paulrobertlloyd committed May 19, 2023
1 parent 62ca541 commit 3a0817d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
7 changes: 7 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"compilerOptions": {
"checkJs": true,
"module": "NodeNext",
"target": "es2021",
}
}
2 changes: 1 addition & 1 deletion lib/fetch-mf2.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { fetch } from "./fetch.js";
/**
* Fetch Microformats2 from a given URL
* @param {string} url URL
* @returns {object} Microformats2
* @returns {Promise<object>} Microformats2
*/
export const fetchMf2 = async (url) => {
const response = await fetch(url);
Expand Down
2 changes: 1 addition & 1 deletion lib/fetch-references.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const referenceableUrls = (jf2) => {
/**
* Fetch JF2 properties for each referenced URL
* @param {object} jf2 JF2
* @returns {object} JF2 with references
* @returns {Promise<object>} JF2 with references
*/
export const fetchReferences = async (jf2) => {
const urls = referenceableUrls(jf2);
Expand Down
2 changes: 2 additions & 0 deletions lib/fetch.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
/**
* Fetch ponyfill.
* @type {globalThis.fetch}
* @returns {Promise<Response>} Fetch response
*/
export async function fetch(...args) {
if ("fetch" in globalThis) {
return globalThis.fetch(...args);
}

const { fetch } = await import("undici");

return fetch(...args);
}
2 changes: 1 addition & 1 deletion lib/flatten-items.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const getHtml = (item) => ({
* Create object with `children` value
* @see {@link https://jf2.spec.indieweb.org/#collections}
* @param {Array} items MF2
* @returns {Array} JF2
* @returns {object} JF2
*/
const getChildren = (items) => ({
children: items.map((item) => flattenItems(item)),
Expand Down

0 comments on commit 3a0817d

Please sign in to comment.