europa-core
Version:
Europa core engine for converting HTML into valid Markdown
87 lines (86 loc) • 3.46 kB
TypeScript
declare const _map: unique symbol;
/**
* Contains contextual information relating to a {@link Conversion}; either globally or a limited scope single element
* conversion.
*
* The scope of entries can be restricted further by using symbols as keys.
*/
export declare class ConversionContext {
private readonly [_map];
/**
* Deletes the entry for the specified `key` from this {@link ConversionContext}.
*
* @param key - The key whose entry is to be deleted.
* @return A reference to this {@link ConversionContext} for chaining purposes.
*/
delete(key: ConversionContextKey): this;
/**
* Iterates over all non-private entries within this {@link ConversionContext}, calling `callback` for each entry.
*
* Private entries are those set using a symbol as a key.
*
* @param callback - The function to be called for each non-private entry.
* @return A reference to this {@link ConversionContext} for chaining purposes.
*/
forEach(callback: (key: string, value: any) => void): this;
/**
* Returns the value of the entry with the specified `key` within this {@link ConversionContext}.
*
* An error is thrown if no entry was found for `key`.
*
* @param key - The key of the entry whose value is to be returned.
* @return The entry value for `key`.
* @throws If no entry exists for `key`.
*/
get<T = any>(key: ConversionContextKey): T;
/**
* Returns whether an entry for the specified `key` exists within this {@link ConversionContext}.
*
* @param key - The key to be checked.
* @return A reference to this {@link ConversionContext} for chaining purposes.
*/
has(key: ConversionContextKey): boolean;
/**
* Returns the keys for all non-private entries within this {@link ConversionContext}.
*
* Private entries are those set using a symbol as a key.
*
* @return The keys for non-private entries.
*/
keys(): string[];
/**
* Iterates over all non-private entries within this {@link ConversionContext}, calling `callback` for each entry in
* order to map its key/value pair, returning the results of all mapped entries.
*
* Private entries are those set using a symbol as a key.
*
* @param callback - The function to be called for each non-private entry.
* @return The mapped non-private entries.
*/
map<T>(callback: (key: string, value: any) => T): T[];
/**
* Sets the value of the entry with the specified `key` within this {@link ConversionContext} to `value`.
*
* The entry can be considered private if `key` is a symbol.
*
* @param key - The key of the entry whose value is to be set.
* @param value - The value to be set.
* @return A reference to this {@link ConversionContext} for chaining purposes.
*/
set<T = any>(key: ConversionContextKey, value: T): this;
/**
* Returns the values for all non-private entries within this {@link ConversionContext}.
*
* Private entries are those set using a symbol as a key.
*
* @return The values for non-private entries.
*/
values(): any[];
}
/**
* A key which can be used to store contextual information within a {@link ConversionContext}.
*
* The scope of an entry can be restricted further by using a symbol.
*/
export declare type ConversionContextKey = string | symbol;
export {};