@@ -47,7 +47,7 @@ To create trees, use [`unist-builder`][unist-builder].
4747## Install
4848
4949This package is [ ESM only] [ esm ] .
50- In Node.js (version 12.20+, 14.14+, 16.0+, 18 .0+), install with [ npm] [ ] :
50+ In Node.js (version 14.14+ and 16 .0+), install with [ npm] [ ] :
5151
5252``` sh
5353npm install unist-util-map
@@ -56,14 +56,14 @@ npm install unist-util-map
5656In Deno with [ ` esm.sh ` ] [ esmsh ] :
5757
5858``` js
59- import {map } from " https://esm.sh/unist-util-map@3"
59+ import {map } from ' https://esm.sh/unist-util-map@3'
6060```
6161
6262In browsers with [ ` esm.sh ` ] [ esmsh ] :
6363
6464``` html
6565<script type =" module" >
66- import {map } from " https://esm.sh/unist-util-map@3?bundle"
66+ import {map } from ' https://esm.sh/unist-util-map@3?bundle'
6767 </script >
6868```
6969
@@ -107,39 +107,56 @@ Yields:
107107
108108## API
109109
110- This package exports the identifier ` map ` .
110+ This package exports the identifier [ ` map ` ] [ api-map ] .
111111There is no default export.
112112
113113### ` map(tree, mapFunction) `
114114
115- Create a new tree ([ ` Node ` ] [ node ] ) by mapping all nodes with the given function
116- ([ ` MapFunction ` ] [ map-function ] ).
115+ Create a new tree by mapping all nodes with the given function.
116+
117+ ###### Parameters
118+
119+ * ` tree ` ([ ` Node ` ] [ node ] )
120+ — tree to map
121+ * ` mapFunction ` ([ ` MapFunction ` ] [ api-mapfunction ] )
122+ — function called with a node, its index, and its parent to produce a new
123+ node
117124
118125###### Returns
119126
120127New mapped tree ([ ` Node ` ] [ node ] ).
121128
122- #### ` function mapFunction(node, index, parent) `
129+ #### ` MapFunction `
130+
131+ Function called with a node, its index, and its parent to produce a new
132+ node (TypeScript type).
133+
134+ ###### Parameters
123135
124- Function called with a node ([ ` Node ` ] [ node ] ), its [ index] [ ] (` number? ` ), and its
125- [ parent] [ ] (` Node? ` ) to produce a new node.
136+ * ` node ` ([ ` Node ` ] [ node ] )
137+ — node to map
138+ * ` index ` (` number ` or ` undefined ` )
139+ — index of ` node ` in ` parent ` (if any)
140+ * ` parent ` ([ ` Node ` ] [ node ] or ` undefined ` )
141+ — parent of ` node `
126142
127143###### Returns
128144
129- Node to be used in the new tree ([ ` Node ` ] [ node ] ).
145+ New mapped node ([ ` Node ` ] [ node ] ).
146+
130147The children on the returned node are not used.
131- if the original node has children, those are mapped instead.
148+ If the original node has children, those are mapped instead.
132149
133150## Types
134151
135152This package is fully typed with [ TypeScript] [ ] .
136- It exports a type ` MapFunction<Tree extends Node = Node> ` to properly type ` MapFunction ` s .
153+ It exports the additional type [ ` MapFunction ` ] [ api-mapfunction ] .
137154
138155## Compatibility
139156
140157Projects maintained by the unified collective are compatible with all maintained
141158versions of Node.js.
142- As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18 .0+.
159+ As of now, that is Node.js 14.14+ and 16 .0+.
143160Our projects sometimes work with older versions, but this is not guaranteed.
144161
145162## Related
@@ -223,10 +240,6 @@ abide by its terms.
223240
224241[ node ] : https://github.com/syntax-tree/unist#node
225242
226- [ parent ] : https://github.com/syntax-tree/unist#parent-1
227-
228- [ index ] : https://github.com/syntax-tree/unist#index
229-
230243[ unist-util-visit ] : https://github.com/syntax-tree/unist-util-visit
231244
232245[ unist-util-visit-parents ] : https://github.com/syntax-tree/unist-util-visit-parents
@@ -237,4 +250,6 @@ abide by its terms.
237250
238251[ unist-builder ] : https://github.com/syntax-tree/unist-builder
239252
240- [ map-function ] : #function-mapfunctionnode-index-parent
253+ [ api-map ] : #maptree-mapfunction
254+
255+ [ api-mapfunction ] : #mapfunction
0 commit comments