homophones
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Homophones Finder

A utility to find homophones of a given word using the Datamuse API.

Installation

npm install homophones

Usage

Basic Usage

const HomophonesFinder = require('homophones');

const finder = new HomophonesFinder();

finder.find('bear').then(homophones => {
    console.log(homophones);  // e.g., ['bear', 'bare']
});

Advanced Usage

(Remember that records have to match the response interface HomophoneResponse, which is derived from the Datamuse API.)

If you want to provide a custom fetcher or set a different API endpoint:

const HomophonesFinder, { ApiFetcher } = require('homophones');

const customFetcher = new ApiFetcher('https://customapi.com');
const finder = new HomophonesFinder(customFetcher);

finder.find('lead').then(homophones => {
    console.log(homophones);  // e.g., ['lead', 'led']
});

Running Tests

Before running the tests, ensure you've installed the necessary dev dependencies:

npm install

Then, run the tests:

npm test

Package Sidebar

Install

npm i homophones

Weekly Downloads

4

Version

1.0.1

License

MIT

Unpacked Size

11.9 kB

Total Files

14

Last publish

Collaborators

  • jpcaparas