# strind

> Partition strings based on character indices

Latest version **0.3.1** (published 2019-10-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install strind
pnpm add strind
yarn add strind
bun add strind
```

## Health

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

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

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.1 |
| Published | 2019-10-13 |
| First published | 2019-07-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Eric Liu |
| Maintainers | metonym |
| Keywords | string, string manipulation, partition, char, index, indices, utility |

## Links

- npm: https://www.npmjs.com/package/strind
- Repository: https://github.com/metonym/strind
- Issues: https://github.com/metonym/strind/issues
- npm.io page: https://npm.io/package/strind

## Alternatives

- [d3-force-3d](https://npm.io/package/d3-force-3d.md) — 1.0M weekly downloads
- [ng2-charts](https://npm.io/package/ng2-charts.md) — 486.8K weekly downloads
- [@arcgis/core](https://npm.io/package/@arcgis/core.md) — 257.8K weekly downloads
- [react-sparklines](https://npm.io/package/react-sparklines.md) — 249.3K weekly downloads
- [react-native-gifted-charts](https://npm.io/package/react-native-gifted-charts.md) — 182.3K weekly downloads

## Recent versions

- 0.3.1 (latest) — 2019-10-13
- 0.3.0 — 2019-09-05
- 0.2.1 — 2019-07-13
- 0.2.0 — 2019-07-13
- 0.1.1 — 2019-07-11
- 0.1.0 — 2019-07-10

## README

# strind

[![NPM][npm]][npm-url]
[![Build][build]][build-badge]
[![Coverage][codecov-shield]][codecov]

> Partition strings based on character indices.

## Install

```bash
yarn add strind
```

## Usage

```js
import strind from 'strind';

const result = strind('abcd', [[1, 1], [2, 6]]);

console.log(result);
/**
 * {
      matched: ['b', 'cd'],
      unmatched: [
        {
          chars: 'a',
          index: 0
        }
      ]
    }
 *
 */
```

### Callback

An optional callback function can be passed as the third argument.

The function is called with the substring `chars` and boolean `matches` if the substring matches the array indices.

```js
import strind from 'strind';

const result = strind('abcd', [[1, 1], [2, 6]], ({ chars, matches }) => {
  return {
    text: chars,
    isHighlighted: matches
  };
});

console.log(result);
/**
 * [
      { isHighlighted: false, text: 'a' },
      { isHighlighted: true, text: 'b' },
      { isHighlighted: true, text: 'cd' }
    ]
 *
 */
```

## [Changelog](CHANGELOG.md)

## License

[MIT](LICENSE)

[npm]: https://img.shields.io/npm/v/strind.svg?color=blue
[npm-url]: https://npmjs.com/package/strind
[build]: https://travis-ci.com/metonym/strind.svg?branch=master
[build-badge]: https://travis-ci.com/metonym/strind
[codecov]: https://codecov.io/gh/metonym/strind
[codecov-shield]: https://img.shields.io/codecov/c/github/metonym/strind.svg

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