An open API service indexing awesome lists of open source software.

https://github.com/netrixone/searchbox

Text input augmented with Lexer magic✨ to support advanced search features.
https://github.com/netrixone/searchbox

javascript lexer parser search searchbox text tokenizer typescript webkitty

Last synced: 9 months ago
JSON representation

Text input augmented with Lexer magic✨ to support advanced search features.

Awesome Lists containing this project

README

          

Searchbox


🌐 stuchl4n3k.net | 💻 stuchl4n3k | 🐦 @stuchl4n3k





Text input augmented with Lexer magic✨ to support advanced search features. Searchbox supports multiple user-defined keywords (filters, variables) and also _NOT_ operator.

## Features

- [x] Parses user input string into a structured formula of literals.
- [x] Supports literal negation.
- [x] Supports unicode.
- [ ] Operators are configurable.

## Usage

```typescript
import * as searchbox from '@webkitty/searchbox';

const inputText = 'Never take title:raisins from -author:rabbits';
const keywords = ['title', 'author'];

const formula = searchbox.parse(inputText, {keywords});

// Formula:
// _: [Never,take,from] // words not matching any keyword (aka fulltext)
// title: [raisins] // "title" keyword match
// -author: [rabbits] // "author" keyword match with NOT operator ("-")
```

Please note that only **case-sensitive** keyword matching is supported.

## 📝 License

Copyright © 2019 [stuchl4n3k](https://github.com/stuchl4n3k).
This project is [MIT](LICENSE) licensed.

[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fwebkitty%2Fsearchbox.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fwebkitty%2Fsearchbox?ref=badge_large)