0.2.0 • Published 1 year ago

find-partial-anagrams v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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".