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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: correct typo #2

Merged
merged 1 commit into from Apr 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 13 additions & 8 deletions README.md
Expand Up @@ -2,11 +2,9 @@

> Trace the original position through a source map

`trace-mapping` allows you to take the line and column of an output file and trace it to the
original location in the source file through a source map.
`trace-mapping` allows you to take the line and column of an output file and trace it to the original location in the source file through a source map.

You may already be familiar with the [`source-map`][source-map] package's `SourceMapConsumer`. This
provides the same `originalPositionFor` and `generatedPositionFor` API, without requires WASM.
You may already be familiar with the [`source-map`][source-map] package's `SourceMapConsumer`. This provides the same `originalPositionFor` and `generatedPositionFor` API, without requiring WASM.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

requires -> requiring is the typo fix, rest is whitespace


## Installation

Expand All @@ -17,7 +15,11 @@ npm install @jridgewell/trace-mapping
## Usage

```typescript
import { TraceMap, originalPositionFor, generatedPositionFor } from '@jridgewell/trace-mapping';
import {
TraceMap,
originalPositionFor,
generatedPositionFor,
} from '@jridgewell/trace-mapping';

const tracer = new TraceMap({
version: 3,
Expand All @@ -35,15 +37,18 @@ assert.deepEqual(traced, {
name: 'foo',
});

const generated = generatedPositionFor(tracer, { source: 'input.js', line: 42, column: 4 });
const generated = generatedPositionFor(tracer, {
source: 'input.js',
line: 42,
column: 4,
});
assert.deepEqual(generated, {
line: 1,
column: 5,
});
```

We also provide a lower level API to get the actual segment that matches our line and column. Unlike
`originalPositionFor`, `traceSegment` uses a 0-base for `line`:
We also provide a lower level API to get the actual segment that matches our line and column. Unlike `originalPositionFor`, `traceSegment` uses a 0-base for `line`:

```typescript
import { traceSegment } from '@jridgewell/trace-mapping';
Expand Down