Skip to content

Takes a set of letters and returns all the words in a given word list that can be made using all or a subset of those letters.

License

Notifications You must be signed in to change notification settings

DallasHoff/find-partial-anagrams

Repository files navigation

Find Partial Anagrams

Takes a set of letters and returns all the words in a given word list that can be made using all or a subset of those letters.

Install

npm install find-partial-anagrams

Examples

import { findPartialAnagrams } from 'find-partial-anagrams';
import wordList from 'path/to/your/word/list'; // array of strings

const partialAnagrams = findPartialAnagrams('rbalyri', wordList);

// Example return value: ['library', 'brail', 'briar', 'lairy', 'libra', 'riyal', 'ably', 'airy', ...]

The letters can also be passed as an array.

const partialAnagrams = findPartialAnagrams(
	['r', 'b', 'a', 'l', 'y', 'r', 'i'],
	wordList
);

Question marks can be used as wildcards, and they will match any letter.

const partialAnagrams = findPartialAnagrams('ac?t', wordList);

// This input would match words like "cart", "cast", and "cut".

About

Takes a set of letters and returns all the words in a given word list that can be made using all or a subset of those letters.

Topics

Resources

License

Stars

Watchers

Forks