17
17
* [ Install] ( #install )
18
18
* [ Use] ( #use )
19
19
* [ API] ( #api )
20
- * [ ` toString(node [, separator]) ` ] ( #tostringnode -separator )
20
+ * [ ` toString(value [, separator]) ` ] ( #tostringvalue -separator )
21
21
* [ Types] ( #types )
22
22
* [ Compatibility] ( #compatibility )
23
23
* [ Contribute] ( #contribute )
@@ -35,7 +35,7 @@ This is a small utility that is useful when you’re dealing with ASTs.
35
35
## Install
36
36
37
37
This package is [ ESM only] [ esm ] .
38
- In Node.js (version 12.20+, 14.14+, 16.0+, 18 .0+), install with [ npm] [ ] :
38
+ In Node.js (version 14.14+ and 16 .0+), install with [ npm] [ ] :
39
39
40
40
``` sh
41
41
npm install nlcst-to-string
@@ -44,14 +44,14 @@ npm install nlcst-to-string
44
44
In Deno with [ ` esm.sh ` ] [ esmsh ] :
45
45
46
46
``` js
47
- import {toString } from " https://esm.sh/nlcst-to-string@3"
47
+ import {toString } from ' https://esm.sh/nlcst-to-string@3'
48
48
```
49
49
50
50
In browsers with [ ` esm.sh ` ] [ esmsh ] :
51
51
52
52
``` html
53
53
<script type =" module" >
54
- import {toString } from " https://esm.sh/nlcst-to-string@3?bundle"
54
+ import {toString } from ' https://esm.sh/nlcst-to-string@3?bundle'
55
55
</script >
56
56
```
57
57
@@ -74,21 +74,26 @@ console.log(
74
74
75
75
## API
76
76
77
- This package exports the identifier ` toString ` .
77
+ This package exports the identifier [ ` toString ` ] [ tostring ] .
78
78
There is no default export.
79
79
80
- ### ` toString(node [, separator]) `
80
+ ### ` toString(value [, separator]) `
81
81
82
- Stringify the given [ nlcst] [ ] node (or list of nodes).
82
+ Get the text content of a node or list of nodes.
83
+
84
+ Prefers the node’s plain-text fields, otherwise serializes its children, and
85
+ if the given value is an array, serialize the nodes in it.
83
86
84
87
###### Parameters
85
88
86
- * ` node ` ([ ` Node ` ] [ node ] or ` Array<Node> ` ) — node to serialize.
87
- * ` separator ` (` string ` , default: ` '' ` ) — value to delimit each item
89
+ * ` node ` ([ ` Node ` ] [ node ] or ` Array<Node> ` )
90
+ — node to serialize.
91
+ * ` separator ` (` string ` , default: ` '' ` )
92
+ — value to delimit each item
88
93
89
94
###### Returns
90
95
91
- ` string ` .
96
+ Result ( ` string ` ) .
92
97
93
98
## Types
94
99
@@ -99,7 +104,7 @@ It exports no additional types.
99
104
100
105
Projects maintained by the unified collective are compatible with all maintained
101
106
versions of Node.js.
102
- As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18 .0+.
107
+ As of now, that is Node.js 14.14+ and 16 .0+.
103
108
Our projects sometimes work with older versions, but this is not guaranteed.
104
109
105
110
## Contribute
@@ -167,3 +172,5 @@ abide by its terms.
167
172
[ nlcst ] : https://github.com/syntax-tree/nlcst
168
173
169
174
[ node ] : https://github.com/syntax-tree/nlcst#nodes
175
+
176
+ [ tostring ] : #tostringvalue-separator
0 commit comments