Skip to content

Commit fa86ae2

Browse files
committed
Change to yield undefined
1 parent 910f1bb commit fa86ae2

File tree

4 files changed

+22
-20
lines changed

4 files changed

+22
-20
lines changed

index.test-d.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import {removePosition} from './index.js'
44

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

7-
expectType<Root>(removePosition(tree))
8-
expectType<Root>(removePosition(tree, {force: false}))
9-
expectType<Root>(removePosition(tree, {force: true}))
7+
expectType<undefined>(removePosition(tree))
8+
9+
removePosition(tree, {force: false})
10+
11+
removePosition(tree, {force: true})

lib/index.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,19 @@ import {visit} from 'unist-util-visit'
1616
/**
1717
* Remove the `position` field from a tree.
1818
*
19-
* @template {Node} Tree
20-
* Node type.
21-
* @param {Tree} tree
19+
* @param {Node} tree
2220
* Tree to clean.
2321
* @param {Options | null | undefined} [options={force: false}]
2422
* Configuration (default: `{force: false}`).
25-
* @returns {Tree}
26-
* The given, modified, `tree`.
23+
* @returns {undefined}
24+
* Nothing.
2725
*/
28-
// To do: next major: return `undefined`.
2926
export function removePosition(tree, options) {
3027
const config = options || {}
3128
const force = config.force || false
3229

3330
visit(tree, remove)
3431

35-
return tree
36-
3732
/**
3833
* @param {Node} node
3934
*/

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ Remove the `position` field from a tree.
123123

124124
###### Returns
125125

126-
The given, modified, `tree` ([`Node`][node]).
126+
Nothing (`undefined`).
127127

128128
### `Options`
129129

test.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ test('removePosition', async function (t) {
1414
await t.test('should work softly', async function () {
1515
const empty = {position: undefined}
1616

17+
const root = fromMarkdown('Some **strong**, _emphasis_, and `code`.')
18+
removePosition(root)
19+
1720
assert.deepEqual(
18-
removePosition(fromMarkdown('Some **strong**, _emphasis_, and `code`.')),
21+
root,
1922
u('root', empty, [
2023
u('paragraph', empty, [
2124
u('text', empty, 'Some '),
@@ -31,10 +34,12 @@ test('removePosition', async function (t) {
3134
})
3235

3336
await t.test('should work by force', async function () {
37+
const root = fromMarkdown('Some **strong**, _emphasis_, and `code`.')
38+
39+
removePosition(root, {force: true})
40+
3441
assert.deepEqual(
35-
removePosition(fromMarkdown('Some **strong**, _emphasis_, and `code`.'), {
36-
force: true
37-
}),
42+
root,
3843
u('root', [
3944
u('paragraph', [
4045
u('text', 'Some '),
@@ -50,9 +55,9 @@ test('removePosition', async function (t) {
5055
})
5156

5257
await t.test('should support options', async function () {
53-
assert.deepEqual(
54-
removePosition(fromMarkdown('x'), {force: true}),
55-
u('root', [u('paragraph', [u('text', 'x')])])
56-
)
58+
const root = fromMarkdown('x')
59+
removePosition(root, {force: true})
60+
61+
assert.deepEqual(root, u('root', [u('paragraph', [u('text', 'x')])]))
5762
})
5863
})

0 commit comments

Comments
 (0)