UNPKG

nepali-lorem-ipsum

Version:

A lightweight Lorem Ipsum generator for Nepali placeholder text in Devanagari script. Perfect for mocking up UI designs, testing fonts, or generating content for Nepali-language applications.

33 lines (27 loc) 860 B
import { shuffleArray } from "./utils"; import nepaliWords from "./nepali-words"; type LoremOptions = { paragraphs?: number; sentencesPerParagraph?: number; wordsPerSentence?: number; }; const shuffledWords = shuffleArray(nepaliWords); export function getSentence(wordCount: number = 15): string { const words: string[] = []; for (let i = 0; i < wordCount; i++) { words.push(shuffledWords[i % shuffledWords.length]); // Cycle through shuffled words } return words.join(" ") + "।"; } export function getNepaliLorem(options: LoremOptions = {}): string { const { paragraphs = 3, sentencesPerParagraph = 5, wordsPerSentence = 15, } = options; return Array.from({ length: paragraphs }, () => Array.from({ length: sentencesPerParagraph }, () => getSentence(wordsPerSentence), ).join(" "), ).join("\n\n"); }