@webkitty/searchbox
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

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

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. This project is MIT licensed.

FOSSA Status

Package Sidebar

Install

npm i @webkitty/searchbox

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

32.6 kB

Total Files

16

Last publish

Collaborators

  • stuchl4n3k
  • f3l1x