Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/jpcaparas/homophones
- Owner: jpcaparas
- Created: 2023-08-19T03:42:01.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-08-19T04:33:01.000Z (over 1 year ago)
- Last Synced: 2025-01-05T08:53:23.088Z (16 days ago)
- Language: TypeScript
- Size: 24.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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
```