Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jpcaparas/homophones

Get homophones of a word via the Datamuse API
https://github.com/jpcaparas/homophones

Last synced: about 10 hours ago
JSON representation

Get homophones of a word via the Datamuse API

Awesome Lists containing this project

README

        

# Homophones Finder

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

## Installation

```bash
npm install homophones
```

## Usage

### Basic Usage

```javascript
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:

```javascript
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:

```bash
npm install
```

Then, run the tests:

```bash
npm test
```