Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
formatHeader(data: IHeaderRenderData): h.Child {
if (!data.indices || data.indices.length === 0) {
return data.category;
}
return StringExt.highlight(data.category, data.indices, h.mark);
}
private _filter(): IIterator {
let options = this._options || [];
let query = this._query;
if (!query) {
return map(options, option => ({ raw: option, text: option }));
}
let results: Private.IMatch[] = [];
for (let option of options) {
let match = StringExt.matchSumOfSquares(option, query);
if (match) {
let marked = StringExt.highlight(option, match.indices, Private.mark);
results.push({
raw: option,
score: match.score,
text: marked.join('')
});
}
}
return map(results.sort(Private.scoreCmp), result => ({
text: result.text,
raw: result.raw
}));
}
formatItemLabel(data: IItemRenderData): h.Child {
if (!data.indices || data.indices.length === 0) {
return data.item.label;
}
return StringExt.highlight(data.item.label, data.indices, h.mark);
}