# matcho

> utility functions to identify and highlight texts, numbers and expressions in text

Latest version **2.0.2** (published 2021-09-10) · MIT license · 0 weekly downloads

## Install

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

## Health

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

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

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2021-09-10 |
| First published | 2019-10-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | maxwellium |
| Maintainers | maxwellium |

## Links

- npm: https://www.npmjs.com/package/matcho
- Repository: https://github.com/maxwellium/matcho
- Homepage: https://github.com/maxwellium/matcho#readme
- Issues: https://github.com/maxwellium/matcho/issues
- npm.io page: https://npm.io/package/matcho

## Recent versions

- 2.0.2 (latest) — 2021-09-10
- 2.0.1 — 2021-09-10
- 2.0.0 — 2020-06-25
- 1.0.0 — 2019-10-27

## README

Tree-shakeable zero-dependencies utility functions to identify and highlight texts, numbers and expressions in text.

example:
```typescript
import { fullNumberHighlighter } from 'matcho/full-number-highlighter';

const highlighter = fullNumberHighlighter( '0123' );

const domHighlight = ( input: string ) => highlighter( input )
  .map( ( { match, part } ) => match ? `<span class="highlight">${ part }</span>` : part )
  .join( '' );


domHighlight( '#0 12-34 5678' ) === '#<span class="highlight">0 12-3</span>4 5678';
```


or in the form of an angular pipe:
```typescript
import { Pipe, PipeTransform } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
import { wordHighlighter } from 'matcho/word-highlighter';

@Pipe( {
  name: 'matchoWord'
} )
export class MatchoWordPipe implements PipeTransform {

  constructor( private sanitizer: DomSanitizer ) { }

  transform( value: string, word: string ): string {

    const highlighter = wordHighlighter( word );

    const highlighted = highlighter( value )
      .map( ( { match, part } ) => match ? `<span class="highlight">${ part }</span>` : part )
      .join( '' );

    return this.sanitizer.bypassSecurityTrustHtml( highlighted );
  }
}
```


---

Copyright (c) 2019 **Max Dancau**

License **MIT**

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