Last active
August 23, 2018 19:51
-
-
Save ldmarz/9b5d8c085f5b2976b98121e42a79fdc1 to your computer and use it in GitHub Desktop.
Example how use fuse operators
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const query = 'old man && scalzi'; | |
const result = fuseWithOperators(query, mockData); | |
// → [{"title": "Old Man's War", "author": {"firstName": "John", "lastName": "Scalzi"}}] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ npm i fuse-operators |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Data example | |
const mockData = [ | |
{ | |
"title": "Old Man's War", | |
"author": { | |
"firstName": "John", | |
"lastName": "Scalzi" | |
} | |
}, | |
{ | |
"title": "The Lock Artist", | |
"author": { | |
"firstName": "John", | |
"lastName": "Hamilton" | |
} | |
} | |
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"}}] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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