How to use the didyoumean2.ReturnTypeEnums.ALL_CLOSEST_MATCHES function in didyoumean2

To help you get started, we’ve selected a few didyoumean2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github seek-oss / braid-design-system / site / src / App / foundations / iconography / iconography.tsx View on Github external
onChange={({ currentTarget }) => {
                const searchText = currentTarget.value;

                setSearchTerm(searchText);
                const filteredList = iconNames.filter(
                  ({ name }) =>
                    searchText.length === 0 ||
                    name.toLowerCase().indexOf(searchText.toLowerCase()) > -1,
                );

                if (filteredList.length === 0) {
                  const suggestions =
                    didYouMean(searchText, iconNames, {
                      returnType: ReturnTypeEnums.ALL_CLOSEST_MATCHES,
                      matchPath: ['displayName'],
                    }) ?? [];
                  const suggestionList = Array.isArray(suggestions)
                    ? suggestions
                    : [suggestions];

                  setDisambiguated(suggestionList && suggestionList.length > 0);
                  setIconList(suggestionList);
                } else {
                  setDisambiguated(false);
                  setIconList(filteredList);
                }
              }}
            />

didyoumean2

a library for matching human-quality input to a list of potential matches using the Levenshtein distance algorithm

MIT
Latest version published 9 months ago

Package Health Score

71 / 100
Full package analysis