From 960b838fbbcd1087f88c11f7a113a3230d98ef79 Mon Sep 17 00:00:00 2001 From: badabygirl Date: Sat, 14 Dec 2024 05:07:15 +0800 Subject: [PATCH] docs(source-map): updated API section based on #207 (#248) --- packages/source-map/README.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/source-map/README.md b/packages/source-map/README.md index 2d3cc53d..e045f507 100644 --- a/packages/source-map/README.md +++ b/packages/source-map/README.md @@ -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.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