Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/wzhouwzhou/easyurban

Urban dictionary definitions. Fast.
https://github.com/wzhouwzhou/easyurban

dictionary easyurban js lightweight promise urban urbandictionary

Last synced: 14 days ago
JSON representation

Urban dictionary definitions. Fast.

Awesome Lists containing this project

README

        






NPM version
NPM downloads
Dependencies
Paypal





# Easyurban
## Urban dictionary definitions. Fast and simple.

Get urban dictionary definitions, immediately.

## One Step Installation:

npm install easyurban

### Why easyurban
• Actually works (😱), without any unnecessary bloat or confusion from using other packages.

• Modern (es6), and lightweight (~4.5 kB packed)

### I'm hooked, how do I begin?

const UrbanDictionary = require('easyurban');
const dictionary = new UrbanDictionary;

The `new` keyword is optional, a dictionary can be created simply with UrbanDictionary() as well.

**Lookup terms with dictionary.lookup (await, promise .then()):**

const result = await dictionary.lookup('Urban dictionary');
dictionary.lookup('Urban dictionary')
.then(result => console.log(result.list))
.catch(console.error)

The result will have a list property, and `result.list` will be an array of (hopefully) a maximum of 10 elements.

**Random:**

const random = await dictionary.random();

**Error handling:**

Request handling errors (hopefully) contain three properties: error, code, and message

• error contains an Error object with a stack trace error.stack

• code contains the status code of the request

• message contains the body returned by the server. If possible, it will be a parsed JSON.

**Pagination:** If more than 10 definitions exist, fetch a specific page by specifying the second parameter as the page number.

const secondpage = await dictionary.lookup('Urban dictionary', 2);

Enjoy this package? Consider starring on [github](https://github.com/wzhouwzhou/easyurban) and checking out some of my other work:

[Youtube Search API](https://npmjs.com/ytsearcher)

[Fluent Filepaths](https://npmjs.com/easypathutil)