# lines-and-columns

> Maps lines and columns to character offsets and back.

Latest version **2.0.4** (published 2023-11-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install lines-and-columns
pnpm add lines-and-columns
yarn add lines-and-columns
bun add lines-and-columns
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.4 |
| Published | 2023-11-07 |
| First published | 2015-12-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | ^12.20.0 \|\| ^14.13.1 \|\| >=16.0.0 |
| Dependencies | 0 |
| Unpacked size | 7.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 27 |
| Author | Brian Donovan |
| Maintainers | eventualbuddha |
| Keywords | lines, columns, parser |

## Links

- npm: https://www.npmjs.com/package/lines-and-columns
- Repository: https://github.com/eventualbuddha/lines-and-columns
- Homepage: https://github.com/eventualbuddha/lines-and-columns#readme
- Issues: https://github.com/eventualbuddha/lines-and-columns/issues
- npm.io page: https://npm.io/package/lines-and-columns

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 2.0.4 (latest) — 2023-11-07
- 1.2.4 (v12x) — 2021-11-21
- 1.1.11 (v11x) — 2021-11-21
- 2.0.3 — 2021-11-23
- 1.1.10 — 2021-11-21
- 1.2.3 — 2021-11-21
- 1.2.2 — 2021-11-21
- 2.0.2 — 2021-11-20
- 1.2.1 — 2021-11-20
- 1.1.9 — 2021-11-20
- 1.1.8 — 2021-11-20
- 2.0.1 — 2021-11-20
- 2.0.0 — 2021-11-20
- 1.2.0 — 2021-11-20
- 1.1.7 — 2021-11-20
- … 10 more at https://npm.io/package/lines-and-columns/versions

## README

# lines-and-columns

Maps lines and columns to character offsets and back. This is useful for parsers
and other text processors that deal in character ranges but process text with
meaningful lines and columns.

## Install

```
$ npm install [--save] lines-and-columns
```

## Usage

```js
import { LinesAndColumns } from 'lines-and-columns'

const lines = new LinesAndColumns(
  `table {
  border: 0
}`
)

lines.locationForIndex(9)
// { line: 1, column: 1 }

lines.indexForLocation({ line: 1, column: 2 })
// 10
```

## License

MIT

---
_Source: https://npm.io/package/lines-and-columns · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
