Skip to content

Commit ec9098b

Browse files
committed
Refactor code-style
1 parent 04b5474 commit ec9098b

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

index.js

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,20 @@
44
*
55
* @typedef {string | Omit<Entry, 'lang'|'alternate'>} Alternate
66
*
7-
* @typedef Entry Entries represent a single URL and describe them with metadata.
8-
* @property {string} url Full URL (example: `'https://example.org/'`). See <https://www.sitemaps.org/protocol.html#locdef>
9-
* @property {number|string|Date} [modified] Value indicating when the page last changed.
10-
* @property {string} [lang] BCP 47 tag indicating the language of the page (example: `'en-GB'`). See <https://github.com/wooorm/bcp-47>
11-
* @property {Object.<string, Alternate>} [alternate] Translations of the page, where each key is a BCP 47 tag and each value an entry. Alternate resources inherit fields from the entry they are described in.
7+
* @typedef Entry
8+
* Entries represent a single URL and describe them with metadata.
9+
* @property {string} url
10+
* Full URL (example: `'https://example.org/'`).
11+
* See <https://www.sitemaps.org/protocol.html#locdef>
12+
* @property {number|string|Date} [modified]
13+
* Value indicating when the page last changed.
14+
* @property {string} [lang]
15+
* BCP 47 tag indicating the language of the page (example: `'en-GB'`).
16+
* See <https://github.com/wooorm/bcp-47>
17+
* @property {Record<string, Alternate>} [alternate]
18+
* Translations of the page, where each key is a BCP 47 tag and each value an
19+
* entry.
20+
* Alternate resources inherit fields from the entry they are described in.
1221
*/
1322

1423
import {URL} from 'node:url'
@@ -21,15 +30,16 @@ const own = {}.hasOwnProperty
2130
/**
2231
* Build a sitemap.
2332
*
24-
* @param {Array<string|Entry>} [data] URLs to build a sitemap for.
33+
* @param {Array<string|Entry>} [data]
34+
* URLs to build a sitemap for.
2535
* @returns {Root}
2636
*/
2737
export function sitemap(data) {
28-
/** @type {Array.<Element>} */
38+
/** @type {Array<Element>} */
2939
const nodes = []
30-
/** @type {Object.<string, Entry>} */
40+
/** @type {Record<string, Entry>} */
3141
const urls = {}
32-
/** @type {Object.<string, Array.<string>>} */
42+
/** @type {Record<string, Array<string>>} */
3343
const groupings = {}
3444
/** @type {boolean|undefined} */
3545
let i18n
@@ -59,7 +69,7 @@ export function sitemap(data) {
5969
)
6070
}
6171

62-
/** @type {Array.<string>} */
72+
/** @type {Array<string>} */
6373
let grouping
6474

6575
// Find an already defined grouping.

0 commit comments

Comments
 (0)