本文整理汇总了TypeScript中@csegames/camelot-unchained.utils.doesSearchInclude方法的典型用法代码示例。如果您正苦于以下问题:TypeScript utils.doesSearchInclude方法的具体用法?TypeScript utils.doesSearchInclude怎么用?TypeScript utils.doesSearchInclude使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@csegames/camelot-unchained.utils
的用法示例。
在下文中一共展示了utils.doesSearchInclude方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: shouldShowItem
export function shouldShowItem(item: InventoryItem.Fragment, activeFilters: ActiveFilters, searchValue: string) {
const hasFilter = hasActiveFilterButtons(activeFilters);
const hasSearch = hasFilterText(searchValue);
const itemName = getItemDefinitionName(item);
// Active filters compared to item gearSlots
const doActiveFiltersIncludeItem = _.findIndex(_.values(activeFilters), (filter) => {
return inventoryFilterButtons[filter.name].filter(item);
}) > -1;
// Search text compared to itemName
const doesSearchValueIncludeItem = utils.doesSearchInclude(searchValue, itemName);
// Do active filters and search include item?
if (hasFilter && hasSearch) {
return doActiveFiltersIncludeItem && doesSearchValueIncludeItem;
// Do active filters include item?
} else if (hasFilter && !hasSearch) {
return doActiveFiltersIncludeItem;
// Does search value include item?
} else if (!hasFilter && hasSearch) {
return doesSearchValueIncludeItem;
// If there are no filters or searchValue, every item should be shown.
} else {
return true;
}
}