# search-context

> show the context around matches for a query

Latest version **0.1.0** (published 2014-01-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install search-context
pnpm add search-context
yarn add search-context
bun add search-context
```

## 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.0 |
| Published | 2014-01-19 |
| First published | 2013-11-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Dominic Tarr |
| Maintainers | dominictarr |

## Links

- npm: https://www.npmjs.com/package/search-context
- Repository: https://github.com/dominictarr/search-context
- Issues: https://github.com/dominictarr/search-context/issues
- npm.io page: https://npm.io/package/search-context

## Dependencies (2)

- [colors](https://npm.io/package/colors.md) 0.6.2
- [indexes-of](https://npm.io/package/indexes-of.md) 1.0.0

## Recent versions

- 0.1.0 (latest) — 2014-01-19
- 0.0.4 — 2013-11-20
- 0.0.3 — 2013-11-16
- 0.0.2 — 2013-11-16
- 0.0.1 — 2013-11-16
- 0.0.0 — 2013-11-16

## README

# search-context

Show where a query matches a document.

# example

``` js
var context = require('search-context')
var fs = require('fs')
var README = fs.readFileSync(__dirname + '/README.md', 'utf-8')

function hi (string) {
  return '***'+string.toUpperCase()+'***'
}

console.log(
  context(README, ['query', 'document', 'search'], 80, hi)
)

```

`hi` is an optional function that marks the matched string.
By default it applies bold ansi escape to display in the terminal.

## output

`search-context` finds the tightest occurance of the terms in the query.
If the terms are far apart, the context around each term is displayed
with ... joining them.

## License

MIT

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