# char-props

> Utility for looking up line and column of a character at a given index and vice versa

Latest version **0.1.5** (published 2013-06-18) · 0 weekly downloads

## Install

```sh
npm install char-props
pnpm add char-props
yarn add char-props
bun add char-props
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.5 |
| Published | 2013-06-18 |
| First published | 2012-10-07 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.6.0 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Todd Wolfson |
| Maintainers | twolfson |
| Keywords | character, lookup, line, row, column, index |

## Links

- npm: https://www.npmjs.com/package/char-props
- Repository: https://github.com/twolfson/char-props
- Issues: https://github.com/twolfson/char-props/issues
- npm.io page: https://npm.io/package/char-props

## Alternatives

- [@snazzah/davey](https://npm.io/package/@snazzah/davey.md) — 1.5M weekly downloads
- [@vendure/testing](https://npm.io/package/@vendure/testing.md) — 8.3K weekly downloads
- [vue-simple-context-menu](https://npm.io/package/vue-simple-context-menu.md) — 6.6K weekly downloads
- [cypress-webpack-preprocessor-v5](https://npm.io/package/cypress-webpack-preprocessor-v5.md) — 2.1K weekly downloads
- [@backstage/plugin-catalog-backend-module-puppetdb](https://npm.io/package/@backstage/plugin-catalog-backend-module-puppetdb.md) — 1.3K weekly downloads

## Recent versions

- 0.1.5 (latest) — 2013-06-18
- 0.1.4 — 2013-06-18
- 0.1.3 — 2012-10-09
- 0.1.2 — 2012-10-08
- 0.1.1 — 2012-10-08
- 0.1.0 — 2012-10-07

## README

# char-props [![Donate on Gittip](http://badgr.co/gittip/twolfson.png)](https://www.gittip.com/twolfson/)

Utility for looking up line and column of a character at a given index and vice versa.

## Getting Started
Install the module with: `npm install charProps`

## Documentation
```js
// charProps is a function which invokes the Indexer constructor

// Indexer JSDoc
/**
 * Indexer constructor (takes index and performs pre-emptive caching)
 * @constructor
 * @param {String} input Content to index
 */

// Indexer.lineAt JSDoc
/**
 * Get the line of the character at a certain index
 * @param {Number} index Index of character to retrieve line of
 * @param {Object} [options] Options to use for search
 * @param {Number} [options.minLine=0] Minimum line for us to search on
 * TODO: The following still have to be built/implemented
 * @param {Number} [options.maxLine=lines.length] Maximum line for us to search on
 * @param {String} [options.guess="average"] Affects searching pattern -- can be "high", "low", or "average" (linear top-down, linear bottom-up, or binary)
 * @returns {Number} Line number of character
 */

// Indexer.columnAt JSDoc
/**
 * Get the column of the character at a certain index
 * @param {Number} index Index of character to retrieve column of
 * @returns {Number} Column number of character
 */

// Indexer.indexAt JSDoc
/**
 * Get the index of the character at a line and column
 * @param {Object} params Object containing line and column
 * @param {Number} params.line Line of character
 * @param {Number} params.column Column of character
 * @returns {Number} Index of character
 */

// Indexer.charAt JSDoc
/**
 * Get the character at a line and column
 * @param {Object} params Object containing line and column
 * @param {Number} params.line Line of character
 * @param {Number} params.column Column of character
 * @returns {String} Character at specified location
 */
```

## Examples
### Initial load
```js
var charProps = require('char-props'),
    jquerySrc = fs.readFileSync('jquery.js', 'utf8');

// Load jQuery into charProps
var jqueryProps = charProps(jquerySrc);
```

### lineAt usage
```js
// Look up line of character at index 42
jqueryProps.lineAt(42);
```

### columnAt usage
```js
// Look up column of character at index 88
jqueryProps.columnAt(88);
```

### indexAt usage
```js
// Look up the index of a character at line 9000, column 1
jqueryProps.indexAt({'line': 9000, 'column': 1});
```

### charAt usage
```js
// Get the character at line 20, column 20
jqueryProps.charAt({'line': 20, 'column': 20});
```

## lineAt advanced usage
```js
// Look up line of character at index 9001 with a minimum line of 99
jqueryProps.lineAt(9001, {'minLine': 99});
```

## Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint your code via [grunt](http://gruntjs.com/) and test via [vows](http://vowsjs.org/).

## License
Copyright (c) 2012 Todd Wolfson
Licensed under the MIT license.

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