Skip to content

Commit

Permalink
feat(search): improve types
Browse files Browse the repository at this point in the history
`search` is now generic, items returned will match the type closure
of searchedEntries (whatever that is).
  • Loading branch information
nikku committed Nov 4, 2024
1 parent f1a8efe commit 4abf0e1
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/features/search/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,29 @@
* } } Token
*
* @typedef {Token[]} Tokens
*/

/**
* @template R
*
* @typedef { {
* item: Object,
* item: R,
* tokens: Record<string, Tokens>
* } } 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<T>[]}
*/
export default function search(items, pattern, options) {

Expand Down

0 comments on commit 4abf0e1

Please sign in to comment.