# text-finder

> Searching word in string, faster and flexible.

Latest version **1.0.0** (published 2018-03-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install text-finder
pnpm add text-finder
yarn add text-finder
bun add text-finder
```

## Health

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

Positive: no vulnerabilities; high maintenance score.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2018-03-24 |
| First published | 2018-03-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 20.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | noritama |
| Maintainers | noritama |
| Keywords | text, finder, search, string |

## Links

- npm: https://www.npmjs.com/package/text-finder
- Repository: https://github.com/noritama/text-finder
- Homepage: https://github.com/noritama/text-finder#readme
- Issues: https://github.com/noritama/text-finder/issues
- npm.io page: https://npm.io/package/text-finder

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 1.0.0 (latest) — 2018-03-24
- 0.0.1 — 2018-03-21

## README

# text-finder

text-finder Search "registered words" in string.
Word registering is easy, and search is fast.

## Install

```
npm install text-finder
```

## Usage

### simple

```
const textfinder = require('text-finder');

(async () => {
  // setup is async. (return Promise<void>)
  await textfinder.setup(['apple', 'orange', 'remon']);
  
  const result = textfinder.findOne('I like orange');
  // result: {string: 'orange', start: 7, end: 13}
})();
```

### customize character mapping

"character mapping" means Translate as a other character. 

ex) lower/upper case(A => a)

```
const {TextFinder} = require('./');
const textfinder = new TextFinder({A: 'a', O: 'o', R: 'r'});

(async () => {
  await textfinder.setup(['apple', 'orange', 'remon']);
  
  const result = textfinder.findOne('I like Remon');
  // result: {string: 'Remon', start: 7, end: 12}
})();
```

## APIs

### TextFinder#findOne

Returns the first word found.

```
const result = textfinder.findOne('I like orange and remon.');
// result: {string: 'orange', start: 7, end: 13}
```

### TextFinder#find

Return the all word found as an array.

```
const result = textfinder.find('I like orange and remon.');
// result: [{string: 'orange', start: 7, end: 13}, {string: 'remon', start, 18, end: 23}]
```

## Benchmark

| function | 100words | 1000words | 10000words |
|----------|----------|-----------|------------|
| Array#indexOf | 54,045 ops/s | 9,600 ops/s | 1,015 ops/s |
| TextFinder#findOne | 28,787 ops/s | 24,683 ops/s | 12,858 ops/s |
| TextFinder#find | 28,891 ops/s | 24,301 ops/s | 12,506 ops/s |

## LICENSE

MIT LICENSE [LICENSE](LICENSE)

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