Skip to content

Commit ed04dc3

Browse files
committed
Add improved docs
1 parent 30a4624 commit ed04dc3

File tree

3 files changed

+40
-14
lines changed

3 files changed

+40
-14
lines changed

index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
/**
2+
* @typedef {import('./lib/index.js').Options} Options
3+
*/
4+
15
export {removePosition} from './lib/index.js'

lib/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {visit} from 'unist-util-visit'
2121
* @param {Tree} tree
2222
* Tree to clean.
2323
* @param {Options | boolean | null | undefined} [options]
24-
* Configuration
24+
* Configuration.
2525
* @returns {Tree}
2626
* The given, modified, `tree`.
2727
*/

readme.md

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
* [Install](#install)
1818
* [Use](#use)
1919
* [API](#api)
20-
* [`removePosition(node[, force])`](#removepositionnode-force)
20+
* [`removePosition(node[, force|options])`](#removepositionnode-forceoptions)
21+
* [`Options`](#options)
2122
* [Types](#types)
2223
* [Compatibility](#compatibility)
2324
* [Contribute](#contribute)
@@ -49,7 +50,7 @@ to display positional info to users.
4950
## Install
5051

5152
This package is [ESM only][esm].
52-
In Node.js (version 12.20+, 14.14+, 16.0+, 18.0+), install with [npm][]:
53+
In Node.js (version 14.14+ and 16.0+), install with [npm][]:
5354

5455
```sh
5556
npm install unist-util-remove-position
@@ -58,14 +59,14 @@ npm install unist-util-remove-position
5859
In Deno with [`esm.sh`][esmsh]:
5960

6061
```js
61-
import {removePosition} from "https://esm.sh/unist-util-remove-position@4"
62+
import {removePosition} from 'https://esm.sh/unist-util-remove-position@4'
6263
```
6364

6465
In browsers with [`esm.sh`][esmsh]:
6566

6667
```html
6768
<script type="module">
68-
import {removePosition} from "https://esm.sh/unist-util-remove-position@4?bundle"
69+
import {removePosition} from 'https://esm.sh/unist-util-remove-position@4?bundle'
6970
</script>
7071
```
7172

@@ -77,7 +78,7 @@ import {removePosition} from 'unist-util-remove-position'
7778

7879
const tree = fromMarkdown('Some _emphasis_, **importance**, and `code`.')
7980

80-
removePosition(tree, true)
81+
removePosition(tree, {force: true})
8182

8283
console.dir(tree, {depth: null})
8384
```
@@ -106,29 +107,46 @@ Yields:
106107

107108
## API
108109

109-
This package exports the identifier `removePosition`.
110+
This package exports the identifier [`removePosition`][removeposition].
110111
There is no default export.
111112

112-
### `removePosition(node[, force])`
113+
### `removePosition(node[, force|options])`
113114

114-
Remove the `position` field from a tree ([`Node`][node]).
115-
If `force` is given (`boolean`, default: `false`), uses `delete` to remove the
116-
field entirely, otherwise it’s set to `undefined`.
115+
Remove the `position` field from a tree.
116+
117+
###### Parameters
118+
119+
* `node` ([`Node`][node])
120+
— tree to clean
121+
* `force` (`boolean`)
122+
— equivalent to `{force: boolean}`
123+
* `options` ([`Options`][options], optional)
124+
— configuration
117125

118126
###### Returns
119127

120-
The given, modified, `node` ([`Node`][node]).
128+
The given, modified, `tree` ([`Node`][node]).
129+
130+
### `Options`
131+
132+
Configuration (TypeScript type).
133+
134+
###### Fields
135+
136+
* `force` (`boolean`, default: `false`)
137+
— whether to use `delete` to remove `position` fields, the default is to
138+
set them to `undefined`
121139

122140
## Types
123141

124142
This package is fully typed with [TypeScript][].
125-
It exports no additional types.
143+
It exports the additional type [`Options`][options].
126144

127145
## Compatibility
128146

129147
Projects maintained by the unified collective are compatible with all maintained
130148
versions of Node.js.
131-
As of now, that is Node.js 12.20+, 14.14+, 16.0+, and 18.0+.
149+
As of now, that is Node.js 14.14+ and 16.0+.
132150
Our projects sometimes work with older versions, but this is not guaranteed.
133151

134152
## Contribute
@@ -202,3 +220,7 @@ abide by its terms.
202220
[unist-util-generated]: https://github.com/syntax-tree/unist-util-generated
203221

204222
[unist-util-stringify-position]: https://github.com/syntax-tree/unist-util-stringify-position
223+
224+
[removeposition]: #removepositionnode-forceoptions
225+
226+
[options]: #options

0 commit comments

Comments
 (0)