easyurban

Urban dictionary definitions. Fast and simple.

Usage no npm install needed!

<script type="module">
  import easyurban from 'https://cdn.skypack.dev/easyurban';
</script>

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 and checking out some of my other work:

Youtube Search API

Fluent Filepaths