Skip to content

Instantly share code, notes, and snippets.

@ldmarz
Last active August 23, 2018 19:51
Show Gist options
  • Save ldmarz/9b5d8c085f5b2976b98121e42a79fdc1 to your computer and use it in GitHub Desktop.
Save ldmarz/9b5d8c085f5b2976b98121e42a79fdc1 to your computer and use it in GitHub Desktop.
Example how use fuse operators
const query = 'old man && scalzi';
const result = fuseWithOperators(query, mockData);
// → [{"title": "Old Man's War", "author": {"firstName": "John", "lastName": "Scalzi"}}]
$ npm i fuse-operators
// Data example
const mockData = [
{
"title": "Old Man's War",
"author": {
"firstName": "John",
"lastName": "Scalzi"
}
},
{
"title": "The Lock Artist",
"author": {
"firstName": "John",
"lastName": "Hamilton"
}
}
];
const query = 'old man || artist';
const result = fuseWithOperators(query, mockData);
// → [{"title": "Old Man's War", "author": {"firstName": "John", "lastName": "Scalzi"}}, {"title": "The Lock Artist", "author": {"firstName": "John", "lastName": "Hamilton"}}]
const query = 'old man || the lock artist > scalzi';
const result = fuseWithOperators(query, mockData);
// → [{"title": "Old Man's War", "author": {"firstName": "John", "lastName": "Scalzi"}}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment