@ffflorian/xkcdjs
TypeScript icon, indicating that this package has built-in type declarations

3.2.8 • Public • Published

xkcdjs npm version

An xkcd API client with a CLI.

Usage

A complete documentation is available at https://ffflorian.github.io/api-clients/packages/xkcdjs/.

CLI

To use xkcdjs globally, run yarn global add @ffflorian/xkcdjs or npm i -g @ffflorian/xkcdjs.

Usage: xkcdjs [options] [command]

An xkcd API client with a CLI.

Options:
  -v, --version       output the version number
  -o, --output <dir>  Specify the output directory (default: current directory)
  -h, --help          output usage information

Commands:
  latest              Save the latest comic
  random              Save a random comic
  number <index>      Save comic by index number

Installation

Run yarn add @ffflorian/xkcdjs or npm install @ffflorian/xkcdjs.

Example

import {XKCD} from '@ffflorian/xkcdjs';

const xkcd = new XKCD();

xkcd.api.getLatest().then(result => {
  // XKCDResult { ... }
});

xkcd.api.getRandom().then(result => {
  // XKCDResult
});

xkcd.api.getById(2036).then(result => {
  // XKCDResult
});

xkcd.api.getLatest({withData: true}).then(result => {
  // XKCDResultWithData
});

xkcd.api.getRandom({withData: true}).then(result => {
  // XKCDResultWithData
});

xkcd.api.getById(2036, {withData: true}).then(result => {
  // XKCDResultWithData
});

Build and test

yarn
yarn test

Readme

Keywords

Package Sidebar

Install

npm i @ffflorian/xkcdjs

Weekly Downloads

36

Version

3.2.8

License

GPL-3.0

Unpacked Size

55.1 kB

Total Files

18

Last publish

Collaborators

  • ffflorian