Extract part of fuzzyMatch
@@ -57,26 +57,29 @@ export function truncateString(string, maxLength = 30) {
return truncString;
}
+export function fuzzyMatchRegex(matchStr) {
+ var regexpStr = '';
+ for (var i = 0; i < matchStr.length; i++) {
+ regexpStr += matchStr.charAt(i);
+ regexpStr += '.*';
+ }
+ return new RegExp(regexpStr, 'i');
+}
+
// fuzzyMatch replicates the command-P in vscode matching all the characters in order'
// but not necessarily sequential
export function fuzzyMatch(strings, matchStr) {
if (!matchStr) {
return strings;
}
- var regexpStr = '';
- for (var i = 0; i < matchStr.length; i++) {
- regexpStr += matchStr.charAt(i);
- regexpStr += '.*';
- }
- var regexp = new RegExp(regexpStr, 'i');
- return strings.filter(str => str.match(regexp));
+ return strings.filter(str => str.match(fuzzyMatchRegex(matchStr)));
}
// fuzzyMatchHighlight works with fuzzyMatch to highlight the matching substrings
export function fuzzyMatchHighlight(
str,
matchStr,
- matchStyle = {backgroundColor: 'yellow'},
+ matchStyle = {backgroundColor: 'yellow'}
) {
if (!matchStr) {
return str;
@@ -98,7 +101,7 @@ export function fuzzyMatchHighlight(
))
) : (
<span key={'span' + j}>{c.toString()}</span>
- ),
+ )
)}
</span>
);
@@ -447,7 +450,7 @@ export function defaultViews(run) {
// Generates relay compatible bucket id
export function relayBucketId(params) {
return btoa(
- ['BucketType', 'v1', params.run, params.model, params.entity].join(':'),
+ ['BucketType', 'v1', params.run, params.model, params.entity].join(':')
);
}
@@ -478,7 +481,7 @@ export function updateRuns(oldBuckets, newBuckets, prevResult) {
}
oldBuckets = oldBuckets || {edges: []};
let oldBucketsMap = _.fromPairs(
- oldBuckets.edges.map(edge => [edge.node.name, edge.node]),
+ oldBuckets.edges.map(edge => [edge.node.name, edge.node])
);
let prevResultMap = _.fromPairs(prevResult.map(row => [row.name, row]));
return newBuckets.edges
@@ -547,8 +550,8 @@ export function flatKeySuggestions(keySuggestions) {
return _.flatMap(keySuggestions, section =>
section.suggestions.map(
suggestion =>
- section.title === 'run' ? suggestion.name : Run.displayKey(suggestion),
- ),
+ section.title === 'run' ? suggestion.name : Run.displayKey(suggestion)
+ )
);
}
@@ -567,7 +570,7 @@ export function getColumns(runs) {
['Ran', 'Runtime', 'Config'],
configColumns,
['Summary'],
- summaryColumns,
+ summaryColumns
);
}
