17
17
* [ Install] ( #install )
18
18
* [ Use] ( #use )
19
19
* [ API] ( #api )
20
- * [ ` definitions(node ) ` ] ( #definitionsnode )
21
- * [ ` definition(identifier) ` ] ( #definitionidentifier )
20
+ * [ ` definitions(tree ) ` ] ( #definitionstree )
21
+ * [ ` GetDefinition ` ] ( #getdefinition )
22
22
* [ Types] ( #types )
23
23
* [ Compatibility] ( #compatibility )
24
24
* [ Security] ( #security )
@@ -39,7 +39,7 @@ It’s small and protects against prototype pollution.
39
39
## Install
40
40
41
41
This package is [ ESM only] [ esm ] .
42
- In Node.js (version 12.20+, 14.14+, or 16.0+), install with [ npm] [ ] :
42
+ In Node.js (version 14.14+ and 16.0+), install with [ npm] [ ] :
43
43
44
44
``` sh
45
45
npm install mdast-util-definitions
@@ -78,37 +78,49 @@ definition('foo')
78
78
79
79
## API
80
80
81
- This package exports the identifier ` definitions ` .
81
+ This package exports the identifier [ ` definitions ` ] [ api-definitions ] .
82
82
There is no default export.
83
83
84
- ### ` definitions(node ) `
84
+ ### ` definitions(tree ) `
85
85
86
- Find [ definition] [ ] s in ` node ` ([ ` Node ` ] [ node ] ).
87
- Uses CommonMark precedence, which means that earlier definitions are preferred
88
- over duplicate later definitions.
86
+ Find definitions in ` tree ` .
87
+
88
+ Uses CommonMark precedence, which means that earlier definitions are
89
+ preferred over duplicate later definitions.
90
+
91
+ ###### Parameters
92
+
93
+ * ` tree ` ([ ` Node ` ] [ node ] )
94
+ — tree to check
89
95
90
96
###### Returns
91
97
92
- ` definition ` ([ ` Function ` ] [ fn-definition ] ).
98
+ Getter ([ ` GetDefinition ` ] [ api-getdefinition ] ).
99
+
100
+ ### ` GetDefinition `
93
101
94
- ### ` definition( identifier) `
102
+ Get a definition by identifier (TypeScript type).
95
103
96
- Get a node from the bound definition cache by its ` identifier ` (` string ` ).
104
+ ###### Parameters
105
+
106
+ * ` identifier ` (` string ` , optional)
107
+ — identifier of definition
97
108
98
109
###### Returns
99
110
100
- [ Definition] [ ] , if found ([ ` Node? ` ] [ node ] )
111
+ Definition corresponding to ` identifier ` ([ ` Definition ` ] [ definition ] ) or
112
+ ` null ` .
101
113
102
114
## Types
103
115
104
116
This package is fully typed with [ TypeScript] [ ] .
105
- There are no additional exported types .
117
+ It exports the additional type [ ` GetDefinition ` ] [ api-getdefinition ] .
106
118
107
119
## Compatibility
108
120
109
121
Projects maintained by the unified collective are compatible with all maintained
110
122
versions of Node.js.
111
- As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
123
+ As of now, that is Node.js 14.14+ and 16.0+.
112
124
Our projects sometimes work with older versions, but this is not guaranteed.
113
125
114
126
## Security
@@ -188,10 +200,12 @@ abide by its terms.
188
200
189
201
[ node ] : https://github.com/syntax-tree/unist#node
190
202
191
- [ fn-definition ] : #definitionidentifier
192
-
193
203
[ definition ] : https://github.com/syntax-tree/mdast#definition
194
204
195
205
[ xss ] : https://en.wikipedia.org/wiki/Cross-site_scripting
196
206
197
207
[ hast ] : https://github.com/syntax-tree/hast
208
+
209
+ [ api-definitions ] : #definitionstree
210
+
211
+ [ api-getdefinition ] : #getdefinition
0 commit comments