mirror of
https://github.com/embarklabs/embark.git
synced 2025-01-28 22:45:48 +00:00
refactor(@embark/console): refactor duplicated fuzzy search into a single private method
This commit is contained in:
parent
00be382be7
commit
6858de4ff5
@ -76,7 +76,7 @@ export default class Suggestions {
|
|||||||
suggestions.push({value: "EmbarkJS", command_type: "javascript object", description: "EmbarkJS static functions for Storage, Messages, Names, etc."});
|
suggestions.push({value: "EmbarkJS", command_type: "javascript object", description: "EmbarkJS static functions for Storage, Messages, Names, etc."});
|
||||||
|
|
||||||
if (cmd.indexOf(".") <= 0) {
|
if (cmd.indexOf(".") <= 0) {
|
||||||
return cb(fuzzySearch(cmd, suggestions, (suggestion: Suggestion) => suggestion.value + " " + suggestion.description).map((x: any) => x.original));
|
return cb(this.searchSuggestions(cmd, suggestions));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -92,11 +92,15 @@ export default class Suggestions {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return cb(fuzzySearch(cmd, suggestions, (suggestion: Suggestion) => suggestion.value + " " + suggestion.description).map((x: any) => x.original));
|
return cb(this.searchSuggestions(cmd, suggestions));
|
||||||
}, false, true);
|
}, false, true);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return cb(fuzzySearch(cmd, suggestions, (suggestion: Suggestion) => suggestion.value + " " + suggestion.description).map((x: any) => x.original));
|
return cb(this.searchSuggestions(cmd, suggestions));
|
||||||
|
}
|
||||||
|
|
||||||
|
private searchSuggestions(cmd: string, suggestions: SuggestionsList) {
|
||||||
|
return fuzzySearch(cmd, suggestions, (suggestion: Suggestion) => suggestion.value + " " + suggestion.description).map((x: any) => x.original);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user