This library is based on fusejs.
It was inspired on adding logic operators to be able to apply different conditions on a string search just like would normally do on the SQL Language. No back-end database is needed, just javascript objects.
$ npm i fuse-operators// Data exampleconstmockData=[{"title": "Old Man's War","author": {"firstName": "John","lastName": "Scalzi"}},{"title": "The Lock Artist","author": {"firstName": "John","lastName": "Hamilton"}}];importfuseWithOperatorsfrom'fuse-operators';constoptions={};// Here you can add all options from http://fusejs.io/ packageconstresult=fuseWithOperators(query,mockData,options);importfuseWithOperatorsfrom'fuse-operators';constquery='old man && scalzi';constresult=fuseWithOperators(query,mockData);// → [{"title": "Old Man's War", "author": {"firstName": "John", "lastName": "Scalzi"}}]importfuseWithOperatorsfrom'fuse-operators';constquery='old man || artist';constresult=fuseWithOperators(query,mockData);// → [{"title": "Old Man's War", "author": {"firstName": "John", "lastName": "Scalzi"}}, {"title": "The Lock Artist", "author": {"firstName": "John", "lastName": "Hamilton"}}]importfuseWithOperatorsfrom'fuse-operators';constquery='old man || the lock artist > scalzi';constresult=fuseWithOperators(query,mockData);// → [{"title": "Old Man's War", "author": {"firstName": "John", "lastName": "Scalzi"}}]| Operator | Description |
|---|---|
| || | OR operator |
| && | AND operator |
| > | SUBSET operator. Applies a second search on the left side result |
$ npm run test:watchAll PRs are welcome :) just make sure you pass all tests.
MIT License