Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- userUtils.search = {};
- userUtils.search.byName = function(name, fuzzy) {
- fuzzy = fuzzy || false;
- //let u = fuzzy;
- let expre = new RegExp(`^${name}`, 'i');
- let matchusers = users.filter(function search(item) {
- if (fuzzy === false) {
- if (item.name.first === name || item.name.last === name) {
- return item;
- }
- } else {
- if (expre.test(item.name.first) || expre.test(item.name.last)) return item;
- }
- });
- return matchusers;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement