Skip to content

Commit 7b3aac7

Browse files
committed
Update vfile-location
1 parent ee40d1a commit 7b3aac7

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* @typedef {import('unist').Point} Point
55
* @typedef {import('mdast').Content} Content
66
* @typedef {import('vfile').VFile} VFile
7-
* @typedef {import('vfile-location').Location} LocationInterface
7+
* @typedef {ReturnType<import('vfile-location').location>} Location
88
* @typedef {{
99
* parse(nodes: Node[]): Node
1010
* tokenizeSource(value: string): Node
@@ -19,7 +19,7 @@
1919
*
2020
* @typedef Context
2121
* @property {string} doc
22-
* @property {LocationInterface} location
22+
* @property {Location} place
2323
* @property {ParserInstance} parser
2424
* @property {Array.<string>} ignore
2525
* @property {Array.<string>} source
@@ -28,7 +28,7 @@
2828
import repeat from 'repeat-string'
2929
import {toString} from 'nlcst-to-string'
3030
import {pointStart, pointEnd} from 'unist-util-position'
31-
import vfileLocation from 'vfile-location'
31+
import {location} from 'vfile-location'
3232

3333
/**
3434
* Transform a `tree` in mdast to nlcst.
@@ -73,7 +73,7 @@ export function toNlcst(tree, file, Parser, options = {}) {
7373
one(
7474
{
7575
doc: String(file),
76-
location: vfileLocation(file),
76+
place: location(file),
7777
parser,
7878
ignore: [].concat(
7979
'table',
@@ -210,8 +210,8 @@ function patch(config, nodes, offset) {
210210
end = start + toString(node).length
211211

212212
node.position = {
213-
start: config.location.toPoint(start),
214-
end: config.location.toPoint(end)
213+
start: config.place.toPoint(start),
214+
end: config.place.toPoint(end)
215215
}
216216

217217
start = end

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"nlcst-to-string": "^3.0.0",
4141
"repeat-string": "^1.0.0",
4242
"unist-util-position": "^4.0.0",
43-
"vfile-location": "^3.1.0"
43+
"vfile-location": "^4.0.0"
4444
},
4545
"devDependencies": {
4646
"@types/tape": "^4.0.0",
@@ -57,7 +57,7 @@
5757
"remark-preset-wooorm": "^8.0.0",
5858
"rimraf": "^3.0.0",
5959
"tape": "^5.0.0",
60-
"to-vfile": "^6.0.0",
60+
"to-vfile": "^7.0.0",
6161
"type-coverage": "^2.0.0",
6262
"typescript": "^4.0.0",
6363
"xo": "^0.39.0"

readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ npm install mdast-util-to-nlcst
2626
## Use
2727

2828
```js
29-
import vfile from 'vfile'
29+
import {VFile} from 'vfile'
3030
import {ParseEnglish} from 'parse-english'
3131
import {inspect} from 'unist-util-inspect'
3232
import fromMarkdown from 'mdast-util-from-markdown'
3333
import {toNlcst} from 'mdast-util-to-nlcst'
3434

35-
var file = vfile('Some *foo*sball.')
35+
var file = new VFile('Some *foo*sball.')
3636
var mdast = fromMarkdown(file)
3737
var nlcst = toNlcst(mdast, file, ParseEnglish)
3838

test/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import test from 'tape'
99
import remark from 'remark'
1010
import gfm from 'remark-gfm'
1111
import frontmatter from 'remark-frontmatter'
12-
import vfile from 'to-vfile'
12+
import {toVFile as vfile} from 'to-vfile'
1313
import {ParseLatin} from 'parse-latin'
1414
import {ParseDutch} from 'parse-dutch'
1515
import {ParseEnglish} from 'parse-english'
@@ -144,11 +144,13 @@ test('Fixtures', function (t) {
144144
if (isHidden(name)) continue
145145

146146
input = vfile.readSync(path.join(base, name, 'input.md'))
147-
expected = JSON.parse(vfile.readSync(path.join(base, name, 'output.json')))
147+
expected = JSON.parse(
148+
String(vfile.readSync(path.join(base, name, 'output.json')))
149+
)
148150

149151
try {
150152
options = JSON.parse(
151-
vfile.readSync(path.join(base, name, 'options.json'))
153+
String(vfile.readSync(path.join(base, name, 'options.json')))
152154
)
153155
} catch {
154156
options = undefined

0 commit comments

Comments
 (0)