# tagsearch

> Search a string with a set of tags

Latest version **0.0.5** (published 2015-06-23) · MIT license · 0 weekly downloads

## Install

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

## 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.0.5 |
| Published | 2015-06-23 |
| First published | 2015-06-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Maximilian Schmitt |
| Maintainers | maximilianschmitt |

## Links

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

## Dependencies (4)

- [flatten](https://npm.io/package/flatten.md) 0.0.1
- [array-uniq](https://npm.io/package/array-uniq.md) ^1.0.2
- [object.assign](https://npm.io/package/object.assign.md) ^3.0.0
- [regexp.execall](https://npm.io/package/regexp.execall.md) ^1.0.0

## Recent versions

- 0.0.5 (latest) — 2015-06-23
- 0.0.4 — 2015-06-23
- 0.0.3 — 2015-06-22
- 0.0.2 — 2015-06-22
- 0.0.1 — 2015-06-22

## README

# tagsearch

[![Travis Build](http://img.shields.io/travis/maximilianschmitt/tagsearch.svg?style=flat)](https://travis-ci.org/maximilianschmitt/tagsearch) [![Code Coverage](https://img.shields.io/coveralls/maximilianschmitt/tagsearch.svg)](https://coveralls.io/r/maximilianschmitt/tagsearch) [![npm](https://img.shields.io/npm/dm/tagsearch.svg)](https://www.npmjs.com/package/tagsearch)

Search a string with a set of tags.

## Installation

```
$ npm i tagsearch -S
```

## Usage

### t.matches(string)

`matches` is not case-sensitive and finds all matches within a string.

```js
const t = tagsearch(['slim', 's', 'shady']);
const matches = t.matches('slim shady');

expect(matches).to.deep.equal([
  { start: 0, end: 4, tag: 'slim', original: 'slim' }
  { start: 5, end: 10, tag: 'shady', original: 'shady' },
  { start: 0, end: 1, tag: 's', original: 's' },
  { start: 5, end: 6, tag: 's', original: 's' }
]);
```

### t.highlight(string[, wrappingFunction])

`highlight` wraps every match in `strong`-tags by default:

```js
const t = tagsearch(['slim', 'shady', 's']);
const h = t.highlight('i am the real slim shady');

expect(h).to.equal('i am the real <strong>slim</strong> <strong>shady</strong>');
```

You can specify your own wrapping function:

```js
const t = tagsearch(['slim', 'shady', 's']);
const h = t.highlight('i am the real slim shady', match => `<em>${match.original}</em>`);

expect(h).to.equal('i am the real <em>slim</em> <em>shady</em>');
```

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