Feature/7 migrate to typescript #21
1 changed files with 17 additions and 21 deletions
38
readme.md
38
readme.md
|
@ -4,34 +4,32 @@
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install --save random-bunny
|
||||||
```
|
```
|
||||||
$ npm install --save random-bunny
|
|
||||||
|
or if you're using yarn
|
||||||
|
|
||||||
|
```bash
|
||||||
|
yarn add random-bunny
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```js
|
```ts
|
||||||
const { randomBunny } = require('random-bunny');
|
import randomBunny from "random-bunny";
|
||||||
|
|
||||||
randomBunny('rabbits', 'new', res => {
|
// ... In an async function
|
||||||
console.log(res.title + ": " + res.url);
|
const result = await randomBunny('rabbits', 'hot', 100);
|
||||||
});
|
console.log(result);
|
||||||
```
|
|
||||||
|
|
||||||
```js
|
|
||||||
const { promise } = require('random-bunny');
|
|
||||||
|
|
||||||
promise('rabbits', 'new').then((res) => {
|
|
||||||
console.log(res.title);
|
|
||||||
});
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## API
|
## API
|
||||||
|
|
||||||
### `randomBunny()`
|
### `randomBunny()`
|
||||||
|
|
||||||
Returns a `json string` for a random post to the `callback`. Accepts 3 arguments: `subreddit`, `sortby` ('new', 'hot', 'top'), `callback(res)`
|
Returns a `json string` for a random post. Accepts 3 arguments: `subreddit`, `sortby` ('new', 'hot', 'top'), `maxTries?` (default 100)
|
||||||
|
|
||||||
The json string which gets returned consists of:
|
The json string which gets returned consists of:
|
||||||
- archived
|
- archived
|
||||||
|
@ -44,11 +42,9 @@ The json string which gets returned consists of:
|
||||||
- ups
|
- ups
|
||||||
- url
|
- url
|
||||||
|
|
||||||
### `promise()`
|
`sortBy` will default to 'hot' if not given or invalid
|
||||||
|
|
||||||
Returns a `json string` for a random post in a `promise`. Accepts 2 arguments: `subreddit`, `sortby` ('new', 'hot', 'top').
|
`maxTries` prevents the script from rerolling too many times. The script rerolls the randomiser if the post its given doesn't contain an image. Default 100.
|
||||||
|
|
||||||
The json string returned in the promise consists of the same above.
|
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
|
@ -57,8 +53,8 @@ The json string returned in the promise consists of the same above.
|
||||||
|
|
||||||
## Links
|
## Links
|
||||||
|
|
||||||
* Discord: [Server Link](https://discord.gg/UyAhAVp)
|
* Discord: [Server Link](https://vylpes.xyz/discord)
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
MIT © [Vylpes](https://gitlab.vylpes.com/Vylpes)
|
MIT © [Vylpes](https://www.vylpes.com)
|
Loading…
Reference in a new issue