ES6 Text Search.
npm install seaqSeaq is an ES6 string search library heavily inspired by Fuse.js. It is built in Typescript implementing the fantastic string_score string matching algorithm.
| Statements | Branches | Functions | Lines |
| --------------------------------------------------------------------------- | ------------------------------------------------------------------------- | -------------------------------------------------------------------------- | ---------------------------------------------------------------------- |
| !Statements | !Branches | !Functions | !Lines |
``typescript
import { seaq } from 'seaq';
const contacts = [ { name: 'John', ... }, { name: 'Jane', ... }];
const queryString = 'jo';
const orderedContacts = seaq(contacts, queryString, ['name']);
`
`typescript`
/**
* Given an input list Array
* query, Seaq will return a new Array
* their Score which is calculated using a variation of string_score algorithm.
*
* @export
* @template T generic
* @param {Array
* @param {string} query query string to match against keys in objects
* @param {(Array
* @param {number} [fuzzy] optional fuzziness should be between 0 and 1. low fuzziness like 0.01 means a mismatch will drop the score more then a fuzziness of something like 0.9.
* @returns {Array
*/
export function seaq
list: Array
query: string,
keys?: Array
fuzzy?: number,
): Array
Running yarn benchmark yields the follow results comparing seaq to Fuse.jsFuse.js
!Benchmark
Granted this is not an apples to apples comparison because and seaq provide very different results. seaq has fewer configuration options and may not be flexible enough for some use-cases. But generally, if performance is your primary concern, seaq` may be the right tool for the job.