Skip to content

Commit 3d83958

Browse files
committed
Refactor
1 parent f265716 commit 3d83958

File tree

8 files changed

+25
-25
lines changed

8 files changed

+25
-25
lines changed

lib/footer.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {wrap} from './wrap.js'
1616
*/
1717
export function footer(h) {
1818
let index = -1
19-
/** @type {ElementContent[]} */
19+
/** @type {Array<ElementContent>} */
2020
const listItems = []
2121

2222
while (++index < h.footnoteOrder.length) {
@@ -30,7 +30,7 @@ export function footer(h) {
3030
const id = String(def.identifier)
3131
const safeId = sanitizeUri(id.toLowerCase())
3232
let referenceIndex = 0
33-
/** @type {ElementContent[]} */
33+
/** @type {Array<ElementContent>} */
3434
const backReferences = []
3535

3636
while (++referenceIndex <= h.footnoteCounts[id]) {

lib/handlers/list-item.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function listItem(h, node, parent) {
2020
const loose = parent ? listLoose(parent) : listItemLoose(node)
2121
/** @type {Properties} */
2222
const props = {}
23-
/** @type {Array.<Content>} */
23+
/** @type {Array<Content>} */
2424
const wrapped = []
2525

2626
if (typeof node.checked === 'boolean') {

lib/handlers/table.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ export function table(h, node) {
1818
const rows = node.children
1919
let index = -1
2020
const align = node.align || []
21-
/** @type {Array.<Element>} */
21+
/** @type {Array<Element>} */
2222
const result = []
2323

2424
while (++index < rows.length) {
2525
const row = rows[index].children
2626
const name = index === 0 ? 'th' : 'td'
27-
/** @type {Array.<Content>} */
27+
/** @type {Array<Content>} */
2828
const out = []
2929
let cellIndex = -1
3030
const length = node.align ? align.length : row.length

lib/index.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,29 @@
1515
* @typedef EmbeddedHastFields
1616
* @property {string} [hName] Defines the tag name of an element
1717
* @property {Properties} [hProperties] Defines the properties of an element
18-
* @property {Array.<Content>} [hChildren] Defines the (hast) children of an element
18+
* @property {Array<Content>} [hChildren] Defines the (hast) children of an element
1919
*
20-
* @typedef {Object.<string, unknown> & EmbeddedHastFields} Data unist data with embedded hast fields
20+
* @typedef {Record<string, unknown> & EmbeddedHastFields} Data unist data with embedded hast fields
2121
*
2222
* @typedef {MdastNode & {data?: Data}} NodeWithData unist node with embedded hast data
2323
*
2424
* @callback Handler
2525
* @param {H} h Handle context
2626
* @param {any} node mdast node to handle
2727
* @param {Parent|null} parent Parent of `node`
28-
* @returns {Content|Array.<Content>|null|undefined} hast node
28+
* @returns {Content|Array<Content>|null|undefined} hast node
2929
*
3030
* @callback HFunctionProps
3131
* @param {MdastNode|PositionLike|null|undefined} node mdast node or unist position
3232
* @param {string} tagName HTML tag name
3333
* @param {Properties} props Properties
34-
* @param {Array.<Content>?} [children] hast content
34+
* @param {Array<Content>?} [children] hast content
3535
* @returns {Element}
3636
*
3737
* @callback HFunctionNoProps
3838
* @param {MdastNode|PositionLike|null|undefined} node mdast node or unist position
3939
* @param {string} tagName HTML tag name
40-
* @param {Array.<Content>?} [children] hast content
40+
* @param {Array<Content>?} [children] hast content
4141
* @returns {Element}
4242
*
4343
* @typedef HFields
@@ -46,13 +46,13 @@
4646
* @property {string} footnoteLabel Label to use to introduce the footnote section
4747
* @property {string} footnoteBackLabel Label to use to go back to a footnote call from the footnote section
4848
* @property {(identifier: string) => Definition|null} definition Definition cache
49-
* @property {Object.<string, FootnoteDefinition>} footnoteById Footnote cache
50-
* @property {Array.<string>} footnoteOrder Order in which footnotes occur
51-
* @property {Record.<string, number>} footnoteCounts Counts the same footnote was used
49+
* @property {Record<string, FootnoteDefinition>} footnoteById Footnote cache
50+
* @property {Array<string>} footnoteOrder Order in which footnotes occur
51+
* @property {Record<string, number>} footnoteCounts Counts the same footnote was used
5252
* @property {Handlers} handlers Applied handlers
5353
* @property {Handler} unknownHandler Handler for any none not in `passThrough` or otherwise handled
5454
* @property {(left: NodeWithData|PositionLike|null|undefined, right: Content) => Content} augment Like `h` but lower-level and usable on non-elements.
55-
* @property {Array.<string>} passThrough List of node types to pass through untouched (except for their children).
55+
* @property {Array<string>} passThrough List of node types to pass through untouched (except for their children).
5656
*
5757
* @typedef Options
5858
* @property {boolean} [allowDangerousHtml=false]
@@ -79,12 +79,12 @@
7979
* Change it if you’re authoring in a different language.
8080
* @property {Handlers} [handlers]
8181
* Object mapping mdast nodes to functions handling them
82-
* @property {Array.<string>} [passThrough]
82+
* @property {Array<string>} [passThrough]
8383
* List of custom mdast node types to pass through (keep) in hast
8484
* @property {Handler} [unknownHandler]
8585
* Handler for all unknown nodes.
8686
*
87-
* @typedef {Record.<string, Handler>} Handlers
87+
* @typedef {Record<string, Handler>} Handlers
8888
* Map of node types to handlers
8989
* @typedef {HFunctionProps & HFunctionNoProps & HFields} H
9090
* Handle context
@@ -110,7 +110,7 @@ const own = {}.hasOwnProperty
110110
function factory(tree, options) {
111111
const settings = options || {}
112112
const dangerous = settings.allowDangerousHtml || false
113-
/** @type {Object.<string, FootnoteDefinition>} */
113+
/** @type {Record<string, FootnoteDefinition>} */
114114
const footnoteById = {}
115115

116116
h.dangerous = dangerous
@@ -122,9 +122,9 @@ function factory(tree, options) {
122122
h.footnoteBackLabel = settings.footnoteBackLabel || 'Back to content'
123123
h.definition = definitions(tree)
124124
h.footnoteById = footnoteById
125-
/** @type {Array.<string>} */
125+
/** @type {Array<string>} */
126126
h.footnoteOrder = []
127-
/** @type {Record.<string, number>} */
127+
/** @type {Record<string, number>} */
128128
h.footnoteCounts = {}
129129
h.augment = augment
130130
h.handlers = {...handlers, ...settings.handlers}

lib/revert.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {all} from './traverse.js'
1313
*
1414
* @type {Handler}
1515
* @param {ImageReference|LinkReference} node
16-
* @returns {Content|Array.<Content>}
16+
* @returns {Content|Array<Content>}
1717
*/
1818
export function revert(h, node) {
1919
const subtype = node.referenceType

lib/traverse.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function returnNode(h, node) {
7070
* @param {MdastNode} parent
7171
*/
7272
export function all(h, parent) {
73-
/** @type {Array.<Content>} */
73+
/** @type {Array<Content>} */
7474
const values = []
7575

7676
if ('children' in parent) {

lib/wrap.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import {u} from 'unist-builder'
88
* Wrap `nodes` with line feeds between each entry.
99
* Optionally adds line feeds at the start and end.
1010
*
11-
* @param {Array.<Content>} nodes
11+
* @param {Array<Content>} nodes
1212
* @param {boolean} [loose=false]
13-
* @returns {Array.<Content>}
13+
* @returns {Array<Content>}
1414
*/
1515
export function wrap(nodes, loose) {
16-
/** @type {Array.<Content>} */
16+
/** @type {Array<Content>} */
1717
const result = []
1818
let index = -1
1919

readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ Take a look at [`lib/handlers/`][handlers] for examples.
108108
###### `options.passThrough`
109109

110110
List of custom mdast node types to pass through (keep) in hast
111-
(`Array.<string>`, default: `[]`).
111+
(`Array<string>`, default: `[]`).
112112
If the passed through nodes have children, those children are expected to be
113113
mdast and will be handled.
114114

0 commit comments

Comments
 (0)