# use-command-score

> Tiny, fast fuzzy ⚡️earch for React applications

Latest version **0.0.1** (published 2023-05-18) · ISC license · 0 weekly downloads

## Install

```sh
npm install use-command-score
pnpm add use-command-score
yarn add use-command-score
bun add use-command-score
```

## Health

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

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

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2023-05-18 |
| First published | 2023-05-15 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 33.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | codeshifu |
| Keywords | fuzzy, search, use-command-score, command-score, query, filter, list, ranking-algorithm, autocomplete, matching, react, typescript |

## Links

- npm: https://www.npmjs.com/package/use-command-score
- Repository: https://github.com/codeshifu/use-command-score
- Homepage: https://github.com/codeshifu/use-command-score#readme
- Issues: https://github.com/codeshifu/use-command-score/issues
- npm.io page: https://npm.io/package/use-command-score

## Dependencies (1)

- [react](https://npm.io/package/react.md) ^18.2.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.0.1 (latest) — 2023-05-18
- 0.0.1-0 — 2023-05-15

## README

# use-command-score

> Tiny, fast fuzzy ⚡️earch for React applications

Live demo https://use-command-score.vercel.app

## Install

```sh
npm install use-command-score
```

## Usage

```ts
import { useCommandScore } from "use-command-score";

useCommandScore(needle, haystack, options);
```

## Examples

Search array of strings

```ts
useCommandScore("vsc", ["Vim", "Google chrome", "Visual studio code"]); // ['Visual studio code']
```

Search array of objects & limit result [Live demo](https://use-command-score.vercel.app/?path=/story/moviesfuzzysearch--with-limit)

```ts
useCommandScore("hger", movies, {
  limit: 3,
  keys: ["title", "meta.actors", "meta.director"]
});
```

## API

`useCommandScore(needle, haystack, options)`

### needle

Search query

Type: `string`

Required: `true`

### haystack

Array of items to search

Type: `Array<T>`

Required: `true`

### options

Type: `object`

Required: `false`

#### options.keys

Object key paths in `haystack`. The value of the key paths will be matched against `needle`

Type: `Array<string>`

Required: `false`

```ts
const data = [
  { name: "a", address: { code: "123" } },
  { name: "b", address: { code: "456" } }
];

useCommandScore("4", data, { keys: ["name", "address.code"] });
```

#### options.limit

Limits the total results returned

Type: `number`

Required: `false`

```ts
useCommandScore(needle, haystack, { limit: 5 });
```

## Related

- [command score](https://github.com/superhuman/command-score)

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