Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@types/autosuggest-trie

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/autosuggest-trie

TypeScript definitions for autosuggest-trie

  • 2.1.3
  • ts4.5
  • ts4.6
  • ts4.7
  • ts4.8
  • ts4.9
  • ts5.0
  • ts5.1
  • ts5.2
  • ts5.3
  • ts5.4
  • ts5.5
  • ts5.6
  • ts5.7
  • ts5.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
255
decreased by-51.8%
Maintainers
1
Weekly downloads
 
Created
Source

Installation

npm install --save @types/autosuggest-trie

Summary

This package contains type definitions for autosuggest-trie (https://github.com/moroshko/autosuggest-trie#readme).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/autosuggest-trie.

index.d.ts

/**
 * Creates a trie containing the given items.
 * @param items Array of items. Every item must be an object.
 * @param textKey Key that every item in items must have. item will be inserted to the trie based on item[textKey].
 * @param options Additional options
 */
declare function createTrie<T extends object>(
    items: T[],
    textKey: keyof T,
    options?: TrieOptions<T>,
): Trie<T>;

interface Trie<T> {
    /**
     * Returns items that match the given query.
     * @param query Non-blank query string. If query is blank, [] is returned..
     * @param options Additional query options.
     */
    getMatches(query: string, options?: MatchOptions): T[];
}

interface TrieOptions<T> {
    /**
     * Items comparator, similar to Array#sort's compareFunction.
     * It gets two items, and should return a number.
     *
     * Note: Matches in the first word (let's call it "group 1") are prioritized over matches in the second word ("group 2"),
     * which are prioritized over matches in the third word ("group 3"), and so on.
     * comparator will only sort the matches within each group.
     *
     * When comparator is not specified, items within each group will preserve their order in items.
     */
    comparator?: (a: T, b: T) => number;
    /**
     * Used to split items' textKey into words.
     * @default /\s+/
     */
    splitRegex?: RegExp;
}

interface MatchOptions {
    /**
     * Integer >= 1
     * For example: getMatches('me', { limit: 3 }) will return no more than 3 items that match 'me'.
     * @default Infinity
     */
    limit?: number;
    /**
     * Used to split the query into words.
     * @default /\s+/
     */
    splitRegex?: RegExp;
}

export = createTrie;

Additional Details

  • Last updated: Mon, 06 Nov 2023 22:41:04 GMT
  • Dependencies: none

Credits

These definitions were written by Hemand.

FAQs

Package last updated on 06 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc