lorem-ipsum
Version:
Generates lorem ipsum placeholder text for Node.js, Deno, browsers, and React Native. Developed with Bun.
64 lines (56 loc) • 1.55 kB
TypeScript
export type LoremFormat = "plain" | "html";
export type LoremUnit =
| "words"
| "word"
| "sentences"
| "sentence"
| "paragraphs"
| "paragraph";
export interface Bounds {
min: number;
max: number;
}
export type Prng = () => number;
export interface GeneratorOptions {
sentencesPerParagraph?: Bounds;
wordsPerSentence?: Bounds;
random?: Prng;
words?: string[];
}
export interface LoremIpsumParams {
count?: number;
format?: LoremFormat;
paragraphLowerBound?: number;
paragraphUpperBound?: number;
random?: Prng;
sentenceLowerBound?: number;
sentenceUpperBound?: number;
units?: LoremUnit;
words?: string[];
suffix?: string;
}
export class Generator {
constructor(options?: GeneratorOptions);
sentencesPerParagraph: Bounds;
wordsPerSentence: Bounds;
random: Prng;
words: string[];
generateRandomInteger(min: number, max: number): number;
generateRandomWords(num?: number): string;
generateRandomSentence(num?: number): string;
generateRandomParagraph(num?: number): string;
pluckRandomWord(): string;
}
export class LoremIpsum {
constructor(options?: GeneratorOptions, format?: LoremFormat, suffix?: string);
generator: Generator;
format: LoremFormat;
suffix?: string;
getLineEnding(): string;
formatString(value: string): string;
formatStrings(values: string[]): string[];
generateWords(num?: number): string;
generateSentences(num?: number): string;
generateParagraphs(num: number): string;
}
export function loremIpsum(options?: LoremIpsumParams): string;