find-partial-anagrams
v0.2.1
Published
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.
Downloads
30
Maintainers
Readme
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
# or...
yarn add find-partial-anagrams
# or...
pnpm install find-partial-anagrams
# or...
deno add jsr:@dallashoff/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".