From 4abf0e18aeb90af9a917ed38237cfb01dcba521e Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Mon, 4 Nov 2024 17:43:09 +0100 Subject: [PATCH] feat(search): improve types `search` is now generic, items returned will match the type closure of searchedEntries (whatever that is). --- lib/features/search/search.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/features/search/search.js b/lib/features/search/search.js index 831dc8029..15c6cd959 100644 --- a/lib/features/search/search.js +++ b/lib/features/search/search.js @@ -6,25 +6,29 @@ * } } Token * * @typedef {Token[]} Tokens + */ + +/** + * @template R * * @typedef { { - * item: Object, + * item: R, * tokens: Record * } } SearchResult - * - * @typedef {SearchResult[]} SearchResults */ /** * Search items by query. * - * @param {Object[]} items + * @template T + * + * @param {T[]} items * @param {string} pattern * @param { { * keys: string[]; * } } options * - * @returns {SearchResults} + * @returns {SearchResult[]} */ export default function search(items, pattern, options) {