# @bithero/simple-search-lib

> Javascript library for an simple search engine to power searchbars

Latest version **1.0.3** (published 2022-07-22) · SEE LICENSE IN LICENSE license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @bithero/simple-search-lib
pnpm add @bithero/simple-search-lib
yarn add @bithero/simple-search-lib
bun add @bithero/simple-search-lib
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2022-07-22 |
| First published | 2022-07-20 |
| Weekly downloads | 0 |
| License | SEE LICENSE IN LICENSE |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 43.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | mai-lapyst |
| Maintainers | mai-lapyst |
| Keywords | front-end, react, react-component, component, components, ecosystem-react |

## Links

- npm: https://www.npmjs.com/package/@bithero/simple-search-lib
- Repository: https://codeark.it/Bithero-Agency/simple-search-lib-js
- Issues: https://codeark.it/Bithero-Agency/simple-search-lib-js/issues
- npm.io page: https://npm.io/package/@bithero/simple-search-lib

## 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

- 1.0.3 (latest) — 2022-07-22
- 1.0.2 — 2022-07-22
- 1.0.1 — 2022-07-20

## README

# simple-search-lib

Javascript library for an simple search engine to power searchbars

## License

This project is licensed under AGPL-3.0. See the `LICENSE` file for more informations.

## Usage

```ts
import { compileQuery, executeQuery } from '@bithero/simple-search-lib';

var query = 'name:John';
var person = {
    name: 'John',
    age: 24,
}

// First we need to "compile" the query
var compiledQuery = compileQuery(query);

// Before we can start using the query, we first need an namespace resolver.
// an namespace resolve is responsible to feed the execution process with the data
// an namespace (or attribute) has; an namespace has following syntax: `field:value`.
// You also can specify an negative match so: `field:-value`.
//
// Note: the resolver below is the same as the libraries defaultResolver.
function resolver(name: string, data: any): string {
    return data[name].toString();
}

// An global matcher is also needed; this function is responsible to
// match any given text across all namespaces. Its typically called on normal words.
//
// Note: the matcher below is the same as the libraries defaultMatcher
function matcher(value: string, data: any): boolean {
    for (const key in obj) {
        if (data[key].toString().includes(value)) {
            return true;
        }
    }
    return false;
}

// Next, we can execute the compiled query as many times as we want:
var result = executeQuery(compiledQuery, person, resolver, matcher);
// result should now be `true`
```

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