Skip to content

Commit c3f0963

Browse files
committed
Add improved docs
1 parent 91721f3 commit c3f0963

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

readme.md

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* [Install](#install)
1818
* [Use](#use)
1919
* [API](#api)
20-
* [`toString(node[, separator])`](#tostringnode-separator)
20+
* [`toString(value[, separator])`](#tostringvalue-separator)
2121
* [Types](#types)
2222
* [Compatibility](#compatibility)
2323
* [Contribute](#contribute)
@@ -35,7 +35,7 @@ This is a small utility that is useful when you’re dealing with ASTs.
3535
## Install
3636

3737
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][]:
3939

4040
```sh
4141
npm install nlcst-to-string
@@ -44,14 +44,14 @@ npm install nlcst-to-string
4444
In Deno with [`esm.sh`][esmsh]:
4545

4646
```js
47-
import {toString} from "https://esm.sh/nlcst-to-string@3"
47+
import {toString} from 'https://esm.sh/nlcst-to-string@3'
4848
```
4949

5050
In browsers with [`esm.sh`][esmsh]:
5151

5252
```html
5353
<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'
5555
</script>
5656
```
5757

@@ -74,21 +74,26 @@ console.log(
7474

7575
## API
7676

77-
This package exports the identifier `toString`.
77+
This package exports the identifier [`toString`][tostring].
7878
There is no default export.
7979

80-
### `toString(node[, separator])`
80+
### `toString(value[, separator])`
8181

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.
8386

8487
###### Parameters
8588

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
8893

8994
###### Returns
9095

91-
`string`.
96+
Result (`string`).
9297

9398
## Types
9499

@@ -99,7 +104,7 @@ It exports no additional types.
99104

100105
Projects maintained by the unified collective are compatible with all maintained
101106
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+.
103108
Our projects sometimes work with older versions, but this is not guaranteed.
104109

105110
## Contribute
@@ -167,3 +172,5 @@ abide by its terms.
167172
[nlcst]: https://github.com/syntax-tree/nlcst
168173

169174
[node]: https://github.com/syntax-tree/nlcst#nodes
175+
176+
[tostring]: #tostringvalue-separator

0 commit comments

Comments
 (0)