UNPKG

@helpwave/hightide

Version:

helpwave's component and theming library

59 lines (58 loc) 2.41 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/util/simpleSearch.ts var simpleSearch_exports = {}; __export(simpleSearch_exports, { MultiSearchWithMapping: () => MultiSearchWithMapping, MultiSubjectSearchWithMapping: () => MultiSubjectSearchWithMapping, SimpleSearch: () => SimpleSearch, SimpleSearchWithMapping: () => SimpleSearchWithMapping }); module.exports = __toCommonJS(simpleSearch_exports); var MultiSubjectSearchWithMapping = (search, objects, mapping) => { return objects.filter((object) => { const mappedSearchKeywords = mapping(object)?.map((value) => value.toLowerCase().trim()); if (!mappedSearchKeywords) { return true; } return search.every((searchValue) => !!mappedSearchKeywords.find((value) => !!value && value.includes(searchValue.toLowerCase().trim()))); }); }; var MultiSearchWithMapping = (search, objects, mapping) => { return objects.filter((object) => { const mappedSearchKeywords = mapping(object)?.map((value) => value.toLowerCase().trim()); if (!mappedSearchKeywords) { return true; } return !!mappedSearchKeywords.find((value) => value.includes(search.toLowerCase().trim())); }); }; var SimpleSearchWithMapping = (search, objects, mapping) => { return MultiSearchWithMapping(search, objects, (value) => [mapping(value)]); }; var SimpleSearch = (search, objects) => { return SimpleSearchWithMapping(search, objects, (value) => value); }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { MultiSearchWithMapping, MultiSubjectSearchWithMapping, SimpleSearch, SimpleSearchWithMapping }); //# sourceMappingURL=simpleSearch.js.map