hili-lipsum
Version:
Hilichurlian language lorem ipsum generator and web scraper
69 lines (68 loc) • 2.99 kB
TypeScript
export = Hilichurl;
/**
* Manages hilichurl words-related data processing and formatting
*/
declare class Hilichurl {
/**
* Initializes the Hilichurl class with Hilichurlian JSON data from `jsonFile`
* @param {string} jsonFile - Full file path to a target JSON file containing object[] object arrays
*/
constructor(jsonFile: string);
/**
* Array of Objects containing the raw Hilichurlian data extracted from web-scraped data.
* @type {object[]}
*/
hilichurlianRAW: object[];
/**
* Array of Objects containing processed and formatted Hilichurlian data.
* @type {object[]}
*/
hilichurlianDB: object[];
/**
* Number of columns in the Hilichurlian Lexicon website's HTML table. Default value should be 4 (as of 20241018).
* @type {number}
*/
COLUMN_LENGTH: number;
/**
* Scrapes Hilichurlian words and definitions from the Hilichurl Lexicon website whose URL is defined in the .env.example "HILICHURLIAN_TEXT_URL" variable
* and remove special chars on the scraped content
* @returns {Promise<void>} Stores an array of raw sraped Hilichurlian words minus special characters in this.hilichurlianRAW[]
* [{ word: String, eng: String, notes: String },...]
*/
scrapewords(): Promise<void>;
/**
* Post-processing and extra formating of raw-scraped Hilichurlian words from `this.hilichurlianRAW[]`.
* Stores the formatted words in `this.hilichurlianDB[]`.
* @param {object[]} [data] - (Optional) Array of objects containing raw Hilichurlian data. Uses the `this.hilichurlianRAW[]` data if not provided.
* @returns {void}
*/
formatwords(data?: object[]): void;
/**
* Loads the contents of a JSON file containing Hilichulian-like data items to `this.hilichurlianDB[]` for further processing
* @param {string} jsonFile - Full file path to a target JSON file containing object[] object arrays
* @returns {void}
*/
loadrecords(jsonFile: string): void;
/**
* Writes the contents of `this.hilichurlianDB[]` into a JSON file
* @param {string} directory
* - (Optional) Full directory path minus the filename where to save the JSON file
* - Will write the JSON file to the project's root directory if ommitted
* @returns {string} Random-generated file name
*/
writerecords(directory: string): string;
/**
* Refreshes the in-memory Hilichurlian dictionaries by scraping data
* from the `HILICHURLIAN_TEXT_URL` environment variable into:
* - `this.hilichurlianRAW[]`
* - `this.hilichurlianDB[]`
* @returns {Promise<void>}
*/
fetchrecords(): Promise<void>;
/**
* Generates a Hilichurlian sentence made up of non-sensical Hilichurlian words
* @param {number} wordCount - Maximum number of words to include in the sentence
* @returns {string} Random Hilichurlian words
*/
lipsum(wordCount?: number): string;
}