Skip to content

Commit 9a6ff58

Browse files
committed
build(deps): bump vfile-location from 4.1.0 to 5.0.1
Signed-off-by: Lexus Drumgold <[email protected]>
1 parent e563bf6 commit 9a6ff58

File tree

6 files changed

+49
-63
lines changed

6 files changed

+49
-63
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
"unist-builder": "4.0.0",
9191
"unist-util-source": "4.0.2",
9292
"vfile": "6.0.1",
93-
"vfile-location": "4.1.0"
93+
"vfile-location": "5.0.1"
9494
},
9595
"devDependencies": {
9696
"@arethetypeswrong/cli": "0.7.0",

src/reader.ts

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,16 @@
44
*/
55

66
import type { Point } from '@flex-development/docast'
7-
import { at, cast, ifelse } from '@flex-development/tutils'
7+
import {
8+
at,
9+
cast,
10+
ifelse,
11+
isNumber,
12+
type Nilable,
13+
type Optional
14+
} from '@flex-development/tutils'
815
import type unist from 'unist'
9-
import { location } from 'vfile-location'
10-
import type { LocationUtility } from './types'
16+
import { location, type Location } from 'vfile-location'
1117

1218
/**
1319
* Character reader.
@@ -32,9 +38,9 @@ class Reader {
3238
*
3339
* @protected
3440
* @readonly
35-
* @member {LocationUtility} location
41+
* @member {Location} location
3642
*/
37-
protected readonly location: LocationUtility
43+
protected readonly location: Location
3844

3945
/**
4046
* @protected
@@ -49,7 +55,7 @@ class Reader {
4955
*/
5056
constructor(document: string) {
5157
this.document = document
52-
this.location = cast(location(this.document))
58+
this.location = location(this.document)
5359
this.position = ifelse(document.length, -1, 0)
5460
}
5561

@@ -136,11 +142,18 @@ class Reader {
136142
*
137143
* @public
138144
*
139-
* @param {unist.Point} point - Line and column based point
145+
* @param {Nilable<unist.Point>} [point] - Line and column based point
140146
* @return {number} Document index
141147
*/
142-
public toOffset(point: unist.Point): number {
143-
return this.location.toOffset(point)
148+
public toOffset(point?: Nilable<unist.Point>): number {
149+
/**
150+
* Offset for {@linkcode point}.
151+
*
152+
* @const {Optional<number>} offset
153+
*/
154+
const offset: Optional<number> = this.location.toOffset(point)
155+
156+
return ifelse(isNumber(offset), cast(offset), -1)
144157
}
145158

146159
/**
@@ -150,11 +163,22 @@ class Reader {
150163
*
151164
* @public
152165
*
153-
* @param {number} offset - Document index
166+
* @param {Nilable<number>} [offset] - Document index
154167
* @return {Point} Line and column based point
155168
*/
156-
public toPoint(offset: number): Point {
157-
return this.location.toPoint(offset)
169+
public toPoint(offset?: Nilable<number>): Point {
170+
/**
171+
* Line and column based {@linkcode unist.Point} for {@linkcode offset}.
172+
*
173+
* @const {Optional<unist.Point>} point
174+
*/
175+
const point: Optional<unist.Point> = this.location.toPoint(offset)
176+
177+
return ifelse(point, cast(point), {
178+
column: Number.NaN,
179+
line: Number.NaN,
180+
offset: -1
181+
})
158182
}
159183
}
160184

src/types/__tests__/location-utility.spec-d.ts

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/types/index.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/types/location-utility.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

yarn.lock

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,7 +1179,7 @@ __metadata:
11791179
unist-util-source: "npm:4.0.2"
11801180
version-bump-prompt: "npm:6.1.0"
11811181
vfile: "npm:6.0.1"
1182-
vfile-location: "npm:4.1.0"
1182+
vfile-location: "npm:5.0.1"
11831183
vite: "npm:4.4.7"
11841184
vite-tsconfig-paths: "npm:4.2.0"
11851185
vitest: "npm:0.33.0"
@@ -9774,7 +9774,17 @@ __metadata:
97749774
languageName: node
97759775
linkType: hard
97769776

9777-
"vfile-location@npm:4.1.0, vfile-location@npm:^4.0.0":
9777+
"vfile-location@npm:5.0.1":
9778+
version: 5.0.1
9779+
resolution: "vfile-location@npm:5.0.1"
9780+
dependencies:
9781+
"@types/unist": "npm:^2.0.0"
9782+
vfile: "npm:^6.0.0"
9783+
checksum: 4672b96ae66c7e605b1f1a3b73f7671beab6caff378eb64ca904358e37344bdf30c1a26a69a34be0fe3cd752ffceb35883d640b6b1aa146f2db832364604bf3b
9784+
languageName: node
9785+
linkType: hard
9786+
9787+
"vfile-location@npm:^4.0.0":
97789788
version: 4.1.0
97799789
resolution: "vfile-location@npm:4.1.0"
97809790
dependencies:

0 commit comments

Comments
 (0)