0.1.2 • Published 3 years ago

aniquiz v0.1.2

Weekly downloads
8
License
ISC
Repository
github
Last release
3 years ago

Anime Quiz

Generate random anime quiz!

Installation

npm i aniquiz

Usage

Generate random anime quiz

const animequiz = require('aniquiz')

// Random quiz object
console.log(animequiz.getEntry())

// Quiz object with difficulty
console.log(animequiz.getEntry({ difficulty: 'easy' }))

// Quiz object with image
console.log(animequiz.getEntry({ image: true })

// Quiz object without image
console.log(animequiz.getEntry({ image: false }))

Options

propertytypedefault
difficultystringnone
imagebooleannone

Quiz object

Propertytypedescription
difficultystringThe difficulty of the question
timenumberThe time in ms the question should be answered
questionstringThe question
answersarrayThe array of possible answers
imagestringThe image of the question, if applicable
submittedBystringThe one created the question
idstringThe id of this question
custombooleanWhether this quiz object was manually added

Example response

Success

{
  difficulty: 'Hard',
  time: 20000,
  question: 'The name of Junko Enoshima’s imposter at the beginning of Danganronpa: Trigger Happy Havoc is?',
  answers: [ 'mukuro ikusaba', 'ikusaba mukuro' ],
  image: null,
  submittedBy: 'Sakurajimai',
  id: '111'
}

Error

{ error: 'error msg.' }

Create instance

Creating a quiz instance allows you to prevent receiving the same question twice

const { Quiz } = require('aniquiz');

// class parameters accepts options
const quiz = new Quiz({ difficulty: 'easy' })

// Quiz object
console.log(quiz.getEntry())

// Quiz entries
console.log(quiz.getEntries())

// Accepts options parameter as well

Error

If instance runs out of quiz entry, you encounter the following error

{ error: 'Exhausted entries.' }

You can reload entries by using

quiz.reload(options)

or add your own entries via

quiz.addEntries([])

Added entries will be appended with custom property which is set to true.

Total Entries: 132

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago