MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / matchesFilter

Function matchesFilter

src/pages/plugins/plugins.js:544–569  ·  view source on GitHub ↗
(plugin, filterState)

Source from the content-addressed store, hash-verified

542 }
543
544 function matchesFilter(plugin, filterState) {
545 if (!plugin) return false;
546
547 switch (filterState.type) {
548 case "verified":
549 return Boolean(plugin.author_verified);
550 case "author": {
551 const authorName = normalizePluginAuthor(plugin);
552 if (!authorName) return false;
553 return authorName.toLowerCase().includes(filterState.value);
554 }
555 case "keywords": {
556 const pluginKeywords = normalizePluginKeywords(plugin)
557 .map((keyword) => keyword.toLowerCase())
558 .filter(Boolean);
559 if (!pluginKeywords.length) return false;
560 return filterState.value.some((keyword) =>
561 pluginKeywords.some((pluginKeyword) =>
562 pluginKeyword.includes(keyword),
563 ),
564 );
565 }
566 default:
567 return true;
568 }
569 }
570
571 function normalizePluginAuthor(plugin) {
572 const { author } = plugin || {};

Callers 1

retrieveFilteredPluginsFunction · 0.85

Calls 2

normalizePluginAuthorFunction · 0.85
normalizePluginKeywordsFunction · 0.85

Tested by

no test coverage detected