typing-genius-sdk
v1.2.0
Published
Open-source typing test content library - quotes, words in multiple languages for typing practice
Maintainers
Readme
Typing Genius Content 📝
The standard, open-source typing content library for building typing tests, educational apps, and games. Provides curated quotes and words in multiple languages.
🌍 Global Support
We support a growing list of languages including English, Kyrgyz, Russian, Kazakh, and Uzbek. We welcome contributions for any language!
📦 Installation
# npm
npm install typing-genius-sdk
# yarn
yarn add typing-genius-sdk
# pnpm
pnpm add typing-genius-sdk🚀 Usage
Everything is written in TypeScript and fully typed.
Basic Import
// Import the SDK core and a language pack
import {
getRandomQuote,
getWords,
getWordsByLength
} from 'typing-genius-sdk';
import { English } from 'typing-genius-sdk/en';1. Working with Quotes
Get a random quote:
const quote = getRandomQuote(English);
console.log(quote.text); // "To be or not to be..."
console.log(quote.author); // "William Shakespeare"Get multiple random quotes (with filters):
const quotes = getRandomQuotes(English, {
count: 5,
minLength: 50,
maxLength: 100
});Filter quotes by author:
import { getFilteredQuotes } from 'typing-genius-sdk';
const shakespeareQuotes = getFilteredQuotes(English, {
author: 'Shakespeare'
});2. Working with Words
By Difficulty:
available difficulties: 'easy' | 'medium' | 'hard'
const easyWords = getWords(English, 'easy');
const hardWords = getWords(English, 'hard');By Length:
// Get all 5-letter words
const fiveLetterWords = getWordsByLength(English, 5);Random Words (Smart Shuffle):
import { getRandomWords } from 'typing-genius-sdk';
const words = getRandomWords(English, 'medium', {
count: 20,
exclude: ['badword'] // Optional exclusions
});3. Statistics
Get insights into the available content for a language.
import { getContentStats } from 'typing-genius-sdk';
const stats = getContentStats(English);
console.log(stats);
/*
{
quotes: 5021,
words: {
easy: 2672,
medium: 8691,
hard: 147026,
total: 158389
},
byLength: [
{ length: 3, count: 576 },
{ length: 4, count: 2096 },
...
]
}
*/4. Dynamic Import (Recommended for Web)
To keep bundle sizes low, import languages dynamically:
// Load language content on demand
async function loadContent(langCode: string) {
// e.g. typing-genius-sdk/en, typing-genius-sdk/fr
const module = await import(`typing-genius-sdk/${langCode}`);
return module.default || module[Object.keys(module)[0]];
}� Types
The SDK exports all necessary TS interfaces.
import type { Quote } from 'typing-genius-sdk';
interface Quote {
text: string;
author: string;
source?: string;
length: number;
}🤝 Contributing
We welcome contributions! See CONTRIBUTING.md for guidelines on adding new languages or fixing content.
📜 License
MIT License - see LICENSE for details.
