Code Monkey home page Code Monkey logo

relevant-xkcd's Introduction

Relevant XKCD

Simple XKCD comic fetcher.
Uses Promises and not callbacks!

Example

const xkcd = require('relevant-xkcd');
xkcd.fetchRelevant('meta').then(console.log);

Output

  {
    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<Comic>

xkcd.fetchCurrent()

Fetches the current comic.
=> Promise<Comic>

xkcd.fetchRandom()

Fetches a random comic.
=> Promise<Comic>

xkcd.fetchRelevant(query)

Fetches a comic relevant to query.
Uses Relevant XKCD.
=> Promise<Comic>

xkcd.fetchAllRelevant(query)

Fetches comics relevant to query.
Comics are sorted by descending relevancy.
=> Promise<Comic[]>

comic.fetchImage()

Fetches the image buffer of a comic.
=> Promise<Buffer>

relevant-xkcd's People

Contributors

1computer1 avatar

Stargazers

Gabe Dunn avatar Ezra avatar novara avatar

Watchers

James Cloos avatar

Forkers

j-maas

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.