persona-community-5/.pnpm-store/v3/files/93/d777ca7c2b31d7ece4eeee57d8bd5240d7d4f92e2af619b3a6da647a8a65f78aff1f8abf3b6691a23f1356843dec14201982bf1eca20b6d5b7ffd7d37ad602
rdev-worker a1d0d1bf1c
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
build: /implement-feature community-ui --requirements 'Build the React commu...
2026-02-24 08:22:30 +00:00

60 lines
891 B
Plaintext

# index-to-position
> Convert a string index to its line and column position
## Install
```sh
npm install index-to-position
```
## Usage
```js
import indexToPosition from 'index-to-position';
indexToPosition('hello\nworld\n!', 7);
//=> {line: 1, column: 1}
```
## API
### `indexToPosition(text, index, options?)`
#### text
Type: `string`
The text in which to find the line and column position.
#### index
Type: `number`
The index in the string for which to find the line and column position.
#### options
Type: `object`
##### oneBased
Type: `boolean`\
Default: `false`
Whether to use 1-based or 0-based indexing for the result.
##### oneBasedLine
Type: `boolean`\
Default: `false`
Whether to use 1-based or 0-based line indexing for the result.
##### oneBasedColumn
Type: `boolean`\
Default: `false`
Whether to use 1-based or 0-based column indexing for the result.