Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wzhouwzhou/easyurban
Urban dictionary definitions. Fast.
https://github.com/wzhouwzhou/easyurban
dictionary easyurban js lightweight promise urban urbandictionary
Last synced: 11 days ago
JSON representation
Urban dictionary definitions. Fast.
- Host: GitHub
- URL: https://github.com/wzhouwzhou/easyurban
- Owner: wzhouwzhou
- Created: 2018-08-19T04:28:23.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-08-19T04:42:41.000Z (over 6 years ago)
- Last Synced: 2024-12-01T08:12:05.754Z (29 days ago)
- Topics: dictionary, easyurban, js, lightweight, promise, urban, urbandictionary
- Language: JavaScript
- Homepage: https://npmjs.com/easyurban
- Size: 6.84 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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)