Created
July 5, 2023 20:05
-
-
Save freddan88/b85f360c3bdfa9134d5aa713ca2ef4d4 to your computer and use it in GitHub Desktop.
This file contains 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
import _ from "lodash"; | |
// Lodash search function | |
export const searchByQuery = (collection, query, include) => { | |
query = _.toLower(query); | |
return _.filter(collection, function (object) { | |
return _(object) | |
.pick(include) | |
.some((string) => { | |
return _(string).toLower().includes(query); | |
}); | |
}); | |
}; | |
---- | |
const filtered = searchByQuery(sortedArray, query, ["technologies", "created", "name"]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment