vfile / vfile-location

utility to convert between positional (line and column-based) and offset (range-based) locations
https://unifiedjs.com
MIT License
13 stars 2 forks source link

Position vs Point #5

Closed muescha closed 4 years ago

muescha commented 4 years ago

the readme is confusing.

the function expect an unist.Point instead of unist.Position

there should be this notation change for readme:

PS: i think the refactor the function name toPosition to toPoint would be harder

wooorm commented 4 years ago

Ah yeah, thanks. Reason is that we didn’t have a term to differentiate between the two when this project was created..

PR welcome to a) fix the docs, b) add a toPoint function and alias toPosition to it? Next major we could remove toPosition.

muescha commented 4 years ago
declare namespace vfileLocation {
  type Position = Pick<Point, 'line' | 'column'>

//...
toOffset: (position: Position) => Offset

any hint how this would be changed?

ChristianMurphy commented 4 years ago

For a) do nothing. For b)

declare namespace vfileLocation {
  type Point = Pick<unist.Point, 'line' | 'column'>
  /** @deprecated */
  type Position = Point
  //...
    toOffset: (position: Point) => Offset
wooorm commented 4 years ago

@muescha What do you think, are you interesting and able to work on a PR?

muescha commented 4 years ago

it was out of my scope - i will give it a try