index.d.ts 990 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import type {Point as UnistPoint} from 'unist'
  2. export {location} from './lib/index.js'
  3. /**
  4. * Accessors for index.
  5. */
  6. export interface Location {
  7. /**
  8. * Get the `offset` from a line/column based `Point` in the bound indices;
  9. * returns `undefined` when given out of bounds input.
  10. *
  11. * @param point
  12. * Line/column based `Point`.
  13. * @returns
  14. * Offset.
  15. */
  16. toOffset(point?: PointLike | null | undefined): number | undefined
  17. /**
  18. * Get the line/column based `Point` for `offset` in the bound indices;
  19. * returns `undefined` when given out of bounds input.
  20. *
  21. * @param offset
  22. * Offset.
  23. * @returns
  24. * `Point`.
  25. */
  26. toPoint(offset?: number | null | undefined): UnistPoint | undefined
  27. }
  28. /**
  29. * Point from `unist`, allowed as input.
  30. */
  31. interface PointLike {
  32. /**
  33. * Column.
  34. */
  35. column?: number | null | undefined
  36. /**
  37. * Line.
  38. */
  39. line?: number | null | undefined
  40. /**
  41. * Offset.
  42. */
  43. offset?: number | null | undefined
  44. }