# string-pos

> super fast string index-to-line/column and line/column-to-index translation

Latest version **1.0.0** (published 2017-08-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install string-pos
pnpm add string-pos
yarn add string-pos
bun add string-pos
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2017-08-23 |
| First published | 2017-08-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | danielkalen |
| Maintainers | danielkalen |

## Links

- npm: https://www.npmjs.com/package/string-pos
- Repository: https://github.com/danielkalen/string-pos
- Homepage: https://github.com/danielkalen/string-pos#readme
- Issues: https://github.com/danielkalen/string-pos/issues
- npm.io page: https://npm.io/package/string-pos

## Recent versions

- 1.0.0 (latest) — 2017-08-23

## README

# string-pos
[![Build Status](https://travis-ci.org/danielkalen/string-pos.svg?branch=master)](https://travis-ci.org/danielkalen/string-pos)
[![Coverage](.config/badges/coverage.png?raw=true)](https://github.com/danielkalen/string-pos)
[![Code Climate](https://codeclimate.com/github/danielkalen/string-pos/badges/gpa.svg)](https://codeclimate.com/github/danielkalen/string-pos)
[![NPM](https://img.shields.io/npm/v/string-pos.svg)](https://npmjs.com/package/string-pos)
[![NPM](https://img.shields.io/npm/dm/string-pos.svg)](https://npmjs.com/package/string-pos)

## Usage
```javascript
var stringPos = require('coffee-register');
var sample = "abc\n\n123\n \ndef";

stringPos(sample, 0) //-> {line:1, column:0}
stringPos(sample, 2) //-> {line:1, column:2}
stringPos(sample, 4) //-> {line:2, column:0}
stringPos(sample, 7) //-> {line:3, column:2}

stringPos.toIndex(sample, {line:1, column:0}) //-> 0
stringPos.toIndex(sample, {line:1, column:2}) //-> 2
stringPos.toIndex(sample, {line:2, column:0}) //-> 4
stringPos.toIndex(sample, {line:3, column:2}) //-> 7
```


## Benchmarks
[![Benchmarks](benchmarks/results.png?raw=true)](https://github.com/danielkalen/string-pos)


## Notes
- Compatible with [source-map](http://ghub.io/source-map) positions.
- Line numbers are 1 index based.
- Column numbers are zero index based.



## License
MIT © [Daniel Kalen](https://github.com/danielkalen)

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