find-partial-anagrams
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

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

Package Sidebar

Install

npm i find-partial-anagrams

Weekly Downloads

1

Version

0.2.0

License

MIT

Unpacked Size

5.8 kB

Total Files

7

Last publish

Collaborators

  • dallashoff