Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/1computer1/relevant-xkcd
Fetches XKCD comics. https://www.npmjs.com/package/relevant-xkcd
https://github.com/1computer1/relevant-xkcd
xkcd
Last synced: 6 days ago
JSON representation
Fetches XKCD comics. https://www.npmjs.com/package/relevant-xkcd
- Host: GitHub
- URL: https://github.com/1computer1/relevant-xkcd
- Owner: 1Computer1
- License: mit
- Created: 2017-02-08T04:52:38.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-12-08T13:38:49.000Z (almost 7 years ago)
- Last Synced: 2024-10-26T18:05:11.543Z (10 days ago)
- Topics: xkcd
- Language: JavaScript
- Homepage:
- Size: 4.88 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Relevant XKCD
Simple XKCD comic fetcher.
Uses Promises and not callbacks!## Example
```js
const xkcd = require('relevant-xkcd');
xkcd.fetchRelevant('meta').then(console.log);
```## Output
```js
{
id: 917,
day: 27,
month: 6,
year: 2011,
date: 2011-06-27, // Date object.
title: 'Hofstadter',
safeTitle: 'Hofstadter',
transcript: '[...]', // Too long for here!
altText: '[...]',
xkcdURL: 'https://xkcd.com/917',
imageURL: 'https://imgs.xkcd.com/comics/hofstadter.png',
explainURL: 'http://www.explainxkcd.com/wiki/index.php/917'
}
```## Methods
### `xkcd.fetchComic([id])`
Fetches a comic.
ID can be left blank for current comic.
`=> Promise`### `xkcd.fetchCurrent()`
Fetches the current comic.
`=> Promise`### `xkcd.fetchRandom()`
Fetches a random comic.
`=> Promise`### `xkcd.fetchRelevant(query)`
Fetches a comic relevant to query.
Uses [Relevant XKCD](https://relevantxkcd.appspot.com/).
`=> Promise`### `xkcd.fetchAllRelevant(query)`
Fetches comics relevant to query.
Comics are sorted by descending relevancy.
`=> Promise`### `comic.fetchImage()`
Fetches the image buffer of a comic.
`=> Promise`