Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(source-map): updated API section based on #207 #248

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions packages/source-map/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,22 @@ Provides functionality related to source maps.

## API

This package exports a `SourceMap` class with the following methods:
### This package exports a `SourceMap` class with the following methods:

- `getSourceOffset(generatedOffset: number)`: Returns the source offset for a given generated offset.
Params:

- `getGeneratedOffset(sourceOffset: number)`: Returns the generated offset for a given source offset.
- `fallbackToAnyMatch`(default: false): allow the start and end offsets to come from different mappings.
- `filter?: (data: Data) => boolean)`(default: undefined): according to mapping: Mapping<MyDataType>.data, filter out offsets that do not meet the custom conditions.

- `getSourceOffsets(generatedOffset: number)`: Returns all source offsets for a given generated offset.
Methods:

- `getGeneratedOffsets(sourceOffset: number)`: Returns all generated offsets for a given source offset.
- `toSourceRange(generatedStart: number, generatedEnd: number, fallbackToAnyMatch: boolean, filter?: (data: Data) => boolean)`: Returns all source start and end offsets for the given generated start and end offsets.

- `toGeneratedRange(sourceStart: number, sourceEnd: number, fallbackToAnyMatch: boolean, filter?: (data: Data) => boolean) `: Returns all generated start and end offsets for the given source start and end offsets.

- `toSourceLocation(generatedOffset: number, filter?: (data: Data) => boolean)`: Returns all source offsets for a given generated offset.

- `toGeneratedLocation(sourceOffset: number, filter?: (data: Data) => boolean)`: Returns all generated offsets for a given source offset.

## Data Structures

Expand Down
Loading