Skip to content

bjarneo/find-anagrams

Repository files navigation

find anagrams

Travis

What is this?

This package will find all anagrams from an array and group them together in an matrix array. It will discard words without an anagram. https://en.wikipedia.org/wiki/Anagram

Installation

It's available on npm.

npm install --save find-anagrams

Usage

Find all words that are anagrams in an array

const findAnagrams = require('find-anagrams');

findAnagrams([
    'listen',
    'silent',
    'enlist',
    'word',
    'dog',
    'god',
    'server',
    'revers'
]);

/*
[ 
    [ 'listen', 'silent', 'enlist' ], 
    [ 'dog', 'god' ],
    [ 'server', 'revers' ]
]
*/

Find all words that are anagrams to provided word

const findAnagrams = require('find-anagrams');

const words = [
    'listen',
    'silent',
    'enlist',
    'word',
    'dog',
    'god',
    'server',
    'revers'
];

findAnagrams(words, 'silent');

/*
The provided word will be the first in the array

[ 'silent', 'listen', 'enlist' ]
*/

Test

$ npm test

Contribution

Contributions are appreciated.

License

MIT licensed. See LICENSE.

About

This package will find all anagrams from an array and group them together in an matrix array

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors