Skip to content

Commit c9b3870

Browse files
committed
undo function->variable change
1 parent 524ab52 commit c9b3870

File tree

3 files changed

+50
-49
lines changed

3 files changed

+50
-49
lines changed

lib/index.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -807,14 +807,6 @@ export class Processor extends CallableInstance {
807807
let complete = false
808808
/** @type {VFileWithOutput<CompileResult> | undefined} */
809809
let result
810-
/**
811-
* @type {ProcessCallback<VFileWithOutput<CompileResult>>}
812-
*/
813-
const realDone = (error, file) => {
814-
complete = true
815-
bail(error)
816-
result = file
817-
}
818810

819811
this.freeze()
820812
assertParser('processSync', this.parser || this.Parser)
@@ -825,6 +817,16 @@ export class Processor extends CallableInstance {
825817
assert(result, 'we either bailed on an error or have a tree')
826818

827819
return result
820+
821+
/**
822+
* @type {ProcessCallback<VFileWithOutput<CompileResult>>}
823+
*/
824+
function realDone(error, file) {
825+
complete = true
826+
bail(error)
827+
result = file
828+
}
829+
828830
}
829831

830832
/**
@@ -941,21 +943,21 @@ export class Processor extends CallableInstance {
941943
let complete = false
942944
/** @type {(TailTree extends undefined ? Node : TailTree) | undefined} */
943945
let result
944-
/**
945-
* @type {RunCallback<TailTree extends undefined ? Node : TailTree>}
946-
*/
947-
const realDone = (error, tree) => {
948-
bail(error)
949-
result = tree
950-
complete = true
951-
}
952946

953947
this.run(tree, file, realDone)
954948

955949
assertDone('runSync', 'run', complete)
956950
assert(result, 'we either bailed on an error or have a tree')
957951
return result
958952

953+
/**
954+
* @type {RunCallback<TailTree extends undefined ? Node : TailTree>}
955+
*/
956+
function realDone(error, tree) {
957+
bail(error)
958+
result = tree
959+
complete = true
960+
}
959961
}
960962

961963
/**

test/freeze.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,6 @@ import test from 'node:test'
88
import {unified} from 'unified'
99
import {simpleCompiler, simpleParser} from './util/simple.js'
1010

11-
// `this` in JS is buggy in TS.
12-
/**
13-
* @type {Plugin<[], string, Node>}
14-
*/
15-
const parse = function () {
16-
this.parser = simpleParser
17-
}
18-
19-
// `this` in JS is buggy in TS.
20-
/**
21-
* @type {Plugin<[], Node, string>}
22-
*/
23-
const compile = function () {
24-
this.compiler = simpleCompiler
25-
}
26-
2711
test('`freeze`', async function (t) {
2812
const frozen = unified().use(parse).use(compile).freeze()
2913

@@ -235,3 +219,19 @@ test('`freeze`', async function (t) {
235219
})
236220
})
237221
})
222+
223+
// `this` in JS is buggy in TS.
224+
/**
225+
* @type {Plugin<[], string, Node>}
226+
*/
227+
function parse() {
228+
this.parser = simpleParser
229+
}
230+
231+
// `this` in JS is buggy in TS.
232+
/**
233+
* @type {Plugin<[], Node, string>}
234+
*/
235+
function compile() {
236+
this.compiler = simpleCompiler
237+
}

test/process-sync.js

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,6 @@ import test from 'node:test'
88
import {unified} from 'unified'
99
import {simpleCompiler, simpleParser} from './util/simple.js'
1010

11-
12-
// `this` in JS is buggy in TS.
13-
/**
14-
* @type {Plugin<[], string, Node>}
15-
*/
16-
const parse = function () {
17-
this.parser = simpleParser
18-
}
19-
20-
// `this` in JS is buggy in TS.
21-
/**
22-
* @type {Plugin<[], Node, string>}
23-
*/
24-
const compile = function () {
25-
this.compiler = simpleCompiler
26-
}
27-
2811
test('`processSync`', async function (t) {
2912
await t.test('should throw w/o `parser`', async function () {
3013
assert.throws(function () {
@@ -80,3 +63,19 @@ test('`processSync`', async function (t) {
8063
}
8164
)
8265
})
66+
67+
// `this` in JS is buggy in TS.
68+
/**
69+
* @type {Plugin<[], string, Node>}
70+
*/
71+
function parse() {
72+
this.parser = simpleParser
73+
}
74+
75+
// `this` in JS is buggy in TS.
76+
/**
77+
* @type {Plugin<[], Node, string>}
78+
*/
79+
function compile() {
80+
this.compiler = simpleCompiler
81+
}

0 commit comments

Comments
 (0)