match-sorter

  • Version 6.3.4
  • Published
  • 170 kB
  • 2 dependencies
  • MIT license

Install

npm i match-sorter
yarn add match-sorter
pnpm add match-sorter

Overview

Simple, expected, and deterministic best-match sorting of an array in JavaScript

Index

Variables

variable defaultBaseSortFn

const defaultBaseSortFn: BaseSorter<unknown>;

    variable rankings

    const rankings: {
    readonly CASE_SENSITIVE_EQUAL: 7;
    readonly EQUAL: 6;
    readonly STARTS_WITH: 5;
    readonly WORD_STARTS_WITH: 4;
    readonly CONTAINS: 3;
    readonly ACRONYM: 2;
    readonly MATCHES: 1;
    readonly NO_MATCH: 0;
    };

      Functions

      function matchSorter

      matchSorter: typeof matchSorter;
      • Takes an array of items and a value and returns a new array with the items that match the given value

        Parameter items

        the items to sort

        Parameter value

        the value to use for ranking

        Parameter options

        Some options to configure the sorter {Array} - the new sorted array

      Interfaces

      interface KeyAttributesOptions

      interface KeyAttributesOptions<ItemType> {}

        property key

        key?: string | ValueGetterKey<ItemType>;

          property maxRanking

          maxRanking?: Ranking;

            property minRanking

            minRanking?: Ranking;

              property threshold

              threshold?: Ranking;

                interface MatchSorterOptions

                interface MatchSorterOptions<ItemType = unknown> {}

                  property baseSort

                  baseSort?: BaseSorter<ItemType>;

                    property keepDiacritics

                    keepDiacritics?: boolean;

                      property keys

                      keys?: ReadonlyArray<KeyOption<ItemType>>;

                        property sorter

                        sorter?: Sorter<ItemType>;

                          property threshold

                          threshold?: Ranking;

                            interface RankingInfo

                            interface RankingInfo {}

                              property keyIndex

                              keyIndex: number;

                                property keyThreshold

                                keyThreshold: Ranking | undefined;

                                  property rank

                                  rank: Ranking;

                                    property rankedValue

                                    rankedValue: string;

                                      interface ValueGetterKey

                                      interface ValueGetterKey<ItemType> {}

                                        call signature

                                        (item: ItemType): string | Array<string>;

                                          Type Aliases

                                          type KeyAttributes

                                          type KeyAttributes = {
                                          threshold?: Ranking;
                                          maxRanking: Ranking;
                                          minRanking: Ranking;
                                          };

                                            type KeyOption

                                            type KeyOption<ItemType> =
                                            | KeyAttributesOptions<ItemType>
                                            | ValueGetterKey<ItemType>
                                            | string;

                                              Namespaces

                                              namespace matchSorter

                                              namespace matchSorter {}

                                                variable rankings

                                                var rankings: {
                                                readonly CASE_SENSITIVE_EQUAL: 7;
                                                readonly EQUAL: 6;
                                                readonly STARTS_WITH: 5;
                                                readonly WORD_STARTS_WITH: 4;
                                                readonly CONTAINS: 3;
                                                readonly ACRONYM: 2;
                                                readonly MATCHES: 1;
                                                readonly NO_MATCH: 0;
                                                };

                                                  Package Files (1)

                                                  Dependencies (2)

                                                  Dev Dependencies (3)

                                                  Peer Dependencies (0)

                                                  No peer dependencies.

                                                  Badge

                                                  To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                  You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/match-sorter.

                                                  • Markdown
                                                    [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/match-sorter)
                                                  • HTML
                                                    <a href="https://www.jsdocs.io/package/match-sorter"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>