Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sapphdevelopment/sappquestions
https://github.com/sapphdevelopment/sappquestions
question question-generator questions
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/sapphdevelopment/sappquestions
- Owner: SapphDevelopment
- License: gpl-3.0
- Created: 2023-12-25T15:56:27.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-25T16:00:26.000Z (about 1 year ago)
- Last Synced: 2024-11-19T08:45:52.645Z (about 2 months ago)
- Topics: question, question-generator, questions
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/sappquestions
- Size: 18.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sappQuestions
sappQuestions is a very lightweight npm package that provides a collection of questions with various categories. It allows you to retrieve random questions or questions from specific categories. All questions were manually curated, ensuring no duplicates, no API reliance, and no downtime.
## Installation
You can install sappQuestions using npm:
```shh
npm install sappquestions@latest
```## Usage
Here's an example how to use sappQuestions:
```typescript
/* JavaScript */ const { Language, getRandomQuestion, fetchCategories, fetchQuestions } = require("sappquestions")
/* TypeScrippt */ import { Language, getRandomQuestion, fetchCategories, fetchQuestions } from "sappquestions"// Fetch and display a random quote
await getRandomQuestion().then((question) => {
console.log(`"${question.question}" - ${question.category}`);
});// Fetch and display a random quote from a specific category
const category = "coding";
await getRandomQuestion(category).then((question) => {
console.log(`"${question.question}" - ${question.category}`);
});// Fetch and display available categories
await fetchCategories().then((categories) => {
console.log("Available categories:", categories);
});// Fetch and display available questions
await fetchQuestions(Language["en-US"]).then((questions) => {
console.log("Available questions:", questions);
});
```## API
The sappQuestions package provides the following functions:
### `getRandomQuestion(category?: string, language: Language)`
Retrieve a random question from a specific category.
- `category?`: The category from which to retrieve the question.
- `language`: The language from which to retrieve the question.### `fetchCategories`
Retrieve all available questions.
### `fetchQuestions(Language)`
Retrieve all available questions.
- `language`: The language from which to retrieve the question.
### `Languages`
All available languages
- Arabic, Egypt (العربية، مصر)
- Bulgarian (български)
- ChineseCN (简体中文)
- ChineseTW (繁體中文)
- Croatian (Hrvatski)
- Czech (čeština)
- Danish (Dansk)
- Dutch (Nederlands)
- English (United Kingdom)
- English (United States)
- Finnish (Suomi)
- French (Français)
- German (Deutsch)
- Greek (Ελληνικά)
- Hindi (हिन्दी)
- Hungarian (Magyar)
- Indonesian (Bahasa Indonesia)
- Italian (Italiano)
- Japanese (日本語)
- Korean (한국어)
- Lithuanian (Lietuvių)
- Norwegian (Norsk)
- Polish (Polski)
- PortugueseBR (Português)
- Romanian (Română)
- Russian (Русский)
- SpanishES (Español)
- Swedish (Svenska)
- Thai (ไทย)
- Turkish (Türkçe)
- Ukrainian (Українська)
- Vietnamese (Tiếng Việt)## License
[License](https://raw.githubusercontent.com/SapphDevelopment/.github/main/profile/LICENSE)