Published
Edited
Feb 4, 2019
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
handleQuery = queryString => {
const queryStringLower = queryString.toLowerCase();
const matchedQuestions = augmentedQuestions.map(q => {
const match = q.regex.exec(queryStringLower);
const isMatch = match && match.length === q.groupTypes.length + 1;
const groups = [];
if (isMatch) {
match.forEach((d, i) => {
if (i > 0) {
groups.push({ query: d, type: q.groupTypes[i - 1] });
}
});
}
const isPartialMatch = queryStringLower.match(q.prefixRegex);
return {
isMatch,
isPartialMatch,
groups,
model: q.model,
};
});
return queryStringLower.length > 0
? matchedQuestions.filter(q => q.isPartialMatch)
: matchedQuestions;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more