UNPKG

tiny-essentials

Version:

Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.

420 lines 18 kB
export default UltraRandomMsgGen; /** * Defines how the message content is generated: * - `mixed`: Combines readable words, gibberish, symbols, emojis, etc. * - `readable`: Focuses on human-readable words only. * - `chaotic`: Pure chaos, mostly gibberish and symbols. * - `natural`: Uses structured grammar templates to form silly but proper sentences. */ export type RandomMsgModes = "mixed" | "readable" | "chaotic" | "natural"; /** * Controls where emojis are placed: * - `inline`: Emojis may appear throughout the text. * - `end`: Emojis appear at the end of lines. * - `none`: No emojis will be used. */ export type EmojiPlacement = "inline" | "end" | "none"; /** * Configuration object for customizing message generation. */ export type MsgGenConfig = { /** * - Minimum total length (in characters) of the final generated text. */ minLength: number; /** * - Maximum total length (in characters) of the final generated text. */ maxLength: number; /** * - Whether to favor readable word-like strings. */ readable: boolean; /** * - Whether emojis are allowed in the generated content. */ useEmojis: boolean; /** * - Whether random numbers can appear in the text. */ includeNumbers: boolean; /** * - Whether random symbols (e.g., !@#) are included. */ includeSymbols: boolean; /** * - Enables fun spacing effects (e.g., extra spaces, newlines, uppercase words). */ allowWeirdSpacing: boolean; /** * - List of emojis to choose from. Overrides default set if provided. */ emojiSet: string[]; /** * - List of base words used in readable and mixed modes. */ wordSet: string[]; /** * - Determines the overall generation strategy (`mixed`, `readable`, `chaotic`, or `natural`). */ mode: RandomMsgModes; /** * - Grammar configuration used when `mode` is set to `'natural'`. */ grammar: { templates: string[]; nouns: string[]; verbs: string[]; adjectives: string[]; }; /** * - If false, avoids repeating the same word within a single generation. */ repeatWords: boolean; /** * - Controls how emojis are placed in the text. */ emojiPlacement: EmojiPlacement; /** * - Optional paragraph configuration. */ paragraphs?: { /** * - Minimum number of paragraphs to generate. */ min: number; /** * - Maximum number of paragraphs to generate. */ max: number; } | undefined; /** * - Configuration for line-based generation. */ line: { minLength: number; maxLength: number; emojiChance: number; }; }; /** * @typedef {'mixed'|'readable'|'chaotic'|'natural'} RandomMsgModes * Defines how the message content is generated: * - `mixed`: Combines readable words, gibberish, symbols, emojis, etc. * - `readable`: Focuses on human-readable words only. * - `chaotic`: Pure chaos, mostly gibberish and symbols. * - `natural`: Uses structured grammar templates to form silly but proper sentences. */ /** * @typedef {'inline'|'end'|'none'} EmojiPlacement * Controls where emojis are placed: * - `inline`: Emojis may appear throughout the text. * - `end`: Emojis appear at the end of lines. * - `none`: No emojis will be used. */ /** * @typedef {Object} MsgGenConfig * Configuration object for customizing message generation. * * @property {number} minLength - Minimum total length (in characters) of the final generated text. * @property {number} maxLength - Maximum total length (in characters) of the final generated text. * @property {boolean} readable - Whether to favor readable word-like strings. * @property {boolean} useEmojis - Whether emojis are allowed in the generated content. * @property {boolean} includeNumbers - Whether random numbers can appear in the text. * @property {boolean} includeSymbols - Whether random symbols (e.g., !@#) are included. * @property {boolean} allowWeirdSpacing - Enables fun spacing effects (e.g., extra spaces, newlines, uppercase words). * * @property {string[]} emojiSet - List of emojis to choose from. Overrides default set if provided. * @property {string[]} wordSet - List of base words used in readable and mixed modes. * * @property {RandomMsgModes} mode - Determines the overall generation strategy (`mixed`, `readable`, `chaotic`, or `natural`). * * @property {Object} grammar - Grammar configuration used when `mode` is set to `'natural'`. * @property {string[]} grammar.templates - Sentence templates using placeholders (`{noun}`, `{verb}`, `{adj}`). * @property {string[]} grammar.nouns - List of nouns to insert into `{noun}` placeholders. * @property {string[]} grammar.verbs - List of verbs to insert into `{verb}` placeholders. * @property {string[]} grammar.adjectives - List of adjectives to insert into `{adj}` placeholders. * * @property {boolean} repeatWords - If false, avoids repeating the same word within a single generation. * @property {EmojiPlacement} emojiPlacement - Controls how emojis are placed in the text. * * @property {Object} [paragraphs] - Optional paragraph configuration. * @property {number} paragraphs.min - Minimum number of paragraphs to generate. * @property {number} paragraphs.max - Maximum number of paragraphs to generate. * * @property {Object} line - Configuration for line-based generation. * @property {number} line.minLength - Minimum number of characters per line. * @property {number} line.maxLength - Maximum number of characters per line. * @property {number} line.emojiChance - Probability (0 to 1) that a line will end with an emoji when allowed. */ /** * UltraRandomMsgGen - Phrase templates and word lists * * Portions of the templates, word sets, and phrase structures * were generated and expanded by ChatGPT (OpenAI). * * This content was crafted to produce innocent, playful, and diverse * random messages focused on a pudding-themed, whimsical style. * * @class */ declare class UltraRandomMsgGen { /** @type {string[]} */ static "__#private@#defaultWords": string[]; /** @type {string[]} */ static "__#private@#defaultEmojis": string[]; /** @type {string[]} */ static "__#private@#defaultNouns": string[]; /** @type {string[]} */ static "__#private@#defaultVerbs": string[]; /** @type {string[]} */ static "__#private@#defaultAdjectives": string[]; /** @type {string[]} */ static "__#private@#defaultTemplates": string[]; /** * Utility to validate arrays before setting. * @param {any} value * @param {string} field */ static "__#private@#validateArray"(value: any, field: string): void; /** @param {string[]} value */ static set defaultWords(value: string[]); /** @returns {string[]} */ static get defaultWords(): string[]; /** @param {string[]} value */ static set defaultEmojis(value: string[]); /** @returns {string[]} */ static get defaultEmojis(): string[]; /** @param {string[]} value */ static set defaultNouns(value: string[]); /** @returns {string[]} */ static get defaultNouns(): string[]; /** @param {string[]} value */ static set defaultVerbs(value: string[]); /** @returns {string[]} */ static get defaultVerbs(): string[]; /** @param {string[]} value */ static set defaultAdjectives(value: string[]); /** @returns {string[]} */ static get defaultAdjectives(): string[]; /** @param {string[]} value */ static set defaultTemplates(value: string[]); /** @returns {string[]} */ static get defaultTemplates(): string[]; /** * Creates an instance of UltraRandomMsgGen. * * @param {Object} [config={}] - Configuration object to customize the generator. * @param {number} [config.minLength=10] - Minimum total length (in characters) of generated text. * @param {number} [config.maxLength=300] - Maximum total length (in characters) of generated text. * @param {boolean} [config.readable=true] - Whether to generate readable words or random strings. * @param {boolean} [config.useEmojis=true] - Whether to include emojis in the generated text. * @param {boolean} [config.includeNumbers=true] - Whether to include numbers randomly. * @param {boolean} [config.includeSymbols=true] - Whether to include symbols randomly. * @param {boolean} [config.allowWeirdSpacing=false] - Whether to allow weird spacing (newlines, extra spaces, uppercase). * @param {string[]} [config.emojiSet] - Array of emojis to use (defaults to internal emoji set). * @param {string[]} [config.wordSet] - Array of words to use (defaults to internal word set). * @param {RandomMsgModes} [config.mode='mixed'] - Mode of text generation. * @param {Object} [config.grammar] - Grammar configuration with templates and word categories. * @param {string[]} [config.grammar.templates] - Array of string templates with placeholders for generating sentences. * @param {string[]} [config.grammar.nouns] - Array of noun strings for template substitution. * @param {string[]} [config.grammar.verbs] - Array of verb strings for template substitution. * @param {string[]} [config.grammar.adjectives] - Array of adjective strings for template substitution. * @param {boolean} [config.repeatWords=true] - Whether to allow repeating words in the output. * @param {EmojiPlacement} [config.emojiPlacement='inline'] - Placement mode for emojis in generated text. * @param {Object} [config.paragraphs] - Paragraph configuration object or null for single block text. * @param {number} [config.paragraphs.min] - Minimum number of paragraphs to generate. * @param {number} [config.paragraphs.max] - Maximum number of paragraphs to generate. * @param {Object} [config.line] - Line configuration for generated text. * @param {number} [config.line.minLength=20] - Minimum length (characters) per line. * @param {number} [config.line.maxLength=120] - Maximum length (characters) per line. * @param {number} [config.line.emojiChance=0.3] - Probability (0–1) of placing emoji per line. */ constructor(config?: { minLength?: number | undefined; maxLength?: number | undefined; readable?: boolean | undefined; useEmojis?: boolean | undefined; includeNumbers?: boolean | undefined; includeSymbols?: boolean | undefined; allowWeirdSpacing?: boolean | undefined; emojiSet?: string[] | undefined; wordSet?: string[] | undefined; mode?: RandomMsgModes | undefined; grammar?: { templates?: string[] | undefined; nouns?: string[] | undefined; verbs?: string[] | undefined; adjectives?: string[] | undefined; } | undefined; repeatWords?: boolean | undefined; emojiPlacement?: EmojiPlacement | undefined; paragraphs?: { min?: number | undefined; max?: number | undefined; } | undefined; line?: { minLength?: number | undefined; maxLength?: number | undefined; emojiChance?: number | undefined; } | undefined; }); /** @type {MsgGenConfig} */ config: MsgGenConfig; symbols: string[]; /** * Merges new configuration values into the current instance. * @param {Object} newConfig - Object with one or more configuration overrides. * @returns {this} - The instance for chaining. */ configure(newConfig?: Object): this; /** * Replaces the entire list of grammar templates. * @param {...string[]} templates - One or more arrays or strings containing sentence templates. * @returns {this} - The instance for chaining. */ setGrammarTemplates(...templates: string[][]): this; /** * Adds new grammar templates to the existing list. * @param {...string[]} templates - One or more arrays or strings containing sentence templates. * @returns {this} - The instance for chaining. */ addGrammarTemplates(...templates: string[][]): this; /** * Replaces the list of noun words used in grammar templates. * @param {...string[]} nouns - One or more arrays or strings of nouns. * @returns {this} - The instance for chaining. */ setGrammarNouns(...nouns: string[][]): this; /** * Adds noun words to the existing list used in grammar templates. * @param {...string[]} nouns - One or more arrays or strings of nouns. * @returns {this} - The instance for chaining. */ addGrammarNouns(...nouns: string[][]): this; /** * Replaces the list of verb words used in grammar templates. * @param {...string[]} verbs - One or more arrays or strings of verbs. * @returns {this} - The instance for chaining. */ setGrammarVerbs(...verbs: string[][]): this; /** * Adds verb words to the existing list used in grammar templates. * @param {...string[]} verbs - One or more arrays or strings of verbs. * @returns {this} - The instance for chaining. */ addGrammarVerbs(...verbs: string[][]): this; /** * Replaces the list of adjective words used in grammar templates. * @param {...string[]} adjectives - One or more arrays or strings of adjectives. * @returns {this} - The instance for chaining. */ setGrammarAdjectives(...adjectives: string[][]): this; /** * Adds adjective words to the existing list used in grammar templates. * @param {...string[]} adjectives - One or more arrays or strings of adjectives. * @returns {this} - The instance for chaining. */ addGrammarAdjectives(...adjectives: string[][]): this; /** * Removes specific grammar templates from the current list. * @param {...string[]} templates - One or more arrays or strings of templates to remove. * @returns {this} - The instance for chaining. */ removeGrammarTemplates(...templates: string[][]): this; /** * Removes specific noun words from the grammar noun list. * @param {...string[]} nouns - One or more arrays or strings of nouns to remove. * @returns {this} - The instance for chaining. */ removeGrammarNouns(...nouns: string[][]): this; /** * Removes specific verb words from the grammar verb list. * @param {...string[]} verbs - One or more arrays or strings of verbs to remove. * @returns {this} - The instance for chaining. */ removeGrammarVerbs(...verbs: string[][]): this; /** * Removes specific adjective words from the grammar adjective list. * @param {...string[]} adjectives - One or more arrays or strings of adjectives to remove. * @returns {this} - The instance for chaining. */ removeGrammarAdjectives(...adjectives: string[][]): this; /** * Replaces the entire word set used in readable/mixed modes. * @param {...string[]} words - One or more arrays or strings of words. * @returns {this} - The instance for chaining. */ setWords(...words: string[][]): this; /** * Adds new words to the word set used in readable/mixed modes. * @param {...string[]} words - One or more arrays or strings of words. * @returns {this} - The instance for chaining. */ addWords(...words: string[][]): this; /** * Removes specific words from the word set. * @param {...string[]} words - Words to be removed. * @returns {this} - The instance for chaining. */ removeWords(...words: string[][]): this; /** * Replaces the emoji set used in generated output. * @param {...string[]} emojis - One or more arrays or strings of emojis. * @returns {this} - The instance for chaining. */ setEmojis(...emojis: string[][]): this; /** * Adds new emojis to the emoji set. * @param {...string[]} emojis - One or more arrays or strings of emojis. * @returns {this} - The instance for chaining. */ addEmojis(...emojis: string[][]): this; /** * Removes specific emojis from the emoji set. * @param {...string[]} emojis - Emojis to be removed. * @returns {this} - The instance for chaining. */ removeEmojis(...emojis: string[][]): this; /** * Returns a random item from an array. * @private * @param {string[]} array - Array to pick from. * @returns {string} - Random item from array. */ private _getRandomItem; /** * Generates a single random content chunk based on the mode and settings. * @private * @returns {string} - A chunk (word, emoji, symbol, number, etc.). */ private _generateChunk; /** * Generates a natural sentence by replacing placeholders in a template. * @private * @returns {string} - A generated sentence. */ private _generateNaturalSentence; /** * Generates a single line of text with target length and rules. * @private * @param {number} targetLength - Target character length for the line. * @param {Set<string>} [seenWords] - Set of already used words (for avoiding repeats). * @returns {string} - A generated line. */ private _generateLine; /** * Generates lines to form a paragraph based on total length. * @private * @param {number} totalLength - Total target character count for the paragraph. * @returns {string[]} - Array of lines that form the paragraph. */ private _generateParagraphLines; /** * Generates the final random message, which can be a paragraph or block of lines. * Uses full configuration rules (grammar, symbols, emojis, etc). * @returns {string} - A full generated message. */ generate(): string; } //# sourceMappingURL=UltraRandomMsgGen.d.mts.map