Skip to content

Commit 30a4624

Browse files
committed
Fix typos
1 parent eadb7a8 commit 30a4624

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

index.test-d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import {expectType} from 'tsd'
2-
import {Node} from 'unist'
32
import type {Root} from 'mdast'
4-
import {fromMarkdown} from 'mdast-util-from-markdown'
53
import {removePosition} from './index.js'
64

75
const tree: Root = {type: 'root', children: []}

lib/index.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22
* @typedef {import('unist').Node} Node
33
*/
44

5+
/**
6+
* @typedef Options
7+
* Configuration.
8+
* @property {boolean | null | undefined} [force=false]
9+
* Whether to use `delete` to remove `position` fields.
10+
*
11+
* The default is to set them to `undefined`.
12+
*/
13+
514
import {visit} from 'unist-util-visit'
615

716
/**
@@ -11,16 +20,17 @@ import {visit} from 'unist-util-visit'
1120
* Node type.
1221
* @param {Tree} tree
1322
* Tree to clean.
14-
* @param {boolean | null | undefined} [force=false]
15-
* Whether to use `delete` to remove `position` fields.
16-
*
17-
* The default is to set them to `undefined`.
23+
* @param {Options | boolean | null | undefined} [options]
24+
* Configuration
1825
* @returns {Tree}
1926
* The given, modified, `tree`.
2027
*/
2128
// To do: next major: return `void`.
2229
// To do: remove `force` shortcut, replace with options.
23-
export function removePosition(tree, force) {
30+
export function removePosition(tree, options) {
31+
const force =
32+
typeof options === 'boolean' ? options : options ? options.force : false
33+
2434
visit(tree, remove)
2535

2636
return tree

test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,10 @@ test('removePosition', () => {
4848
]),
4949
'should work by force'
5050
)
51+
52+
assert.deepEqual(
53+
removePosition(fromMarkdown('x'), {force: true}),
54+
u('root', [u('paragraph', [u('text', 'x')])]),
55+
'should support options'
56+
)
5157
})

0 commit comments

Comments
 (0)