obsidian-dev-utils
Version:
This is the collection of useful functions that you can use for your Obsidian plugin development
70 lines (69 loc) • 2.27 kB
text/typescript
/**
* @packageDocumentation
*
* A base class for transformers.
*/
import type { GenericObject } from '../ObjectUtils.cjs';
/**
* A base class for transformers.
*/
export declare abstract class Transformer {
/**
* The id of the transformer.
*/
abstract get id(): string;
/**
* Determines if the transformer can transform the given value.
*
* @param value - The value to check.
* @param key - The key of the value to check.
* @returns A boolean indicating if the transformer can transform the value.
*/
abstract canTransform(value: unknown, key: string): boolean;
/**
* Gets the transformer with the given id.
*
* @param transformerId - The id of the transformer to get.
* @returns The transformer with the given id.
*/
getTransformer(transformerId: string): Transformer;
/**
* Transforms the given object recursively.
*
* @param value - The value to transform.
* @returns The transformed value.
*/
transformObjectRecursively(value: object): GenericObject;
/**
* Transforms the given value.
*
* @param value - The value to transform.
* @param key - The key of the value to transform.
* @returns The transformed value.
*/
abstract transformValue(value: unknown, key: string): unknown;
/**
* Gets the id of the transformer that can transform the given value.
*
* @param value - The value to get the transformer id for.
* @param key - The key of the value to get the transformer id for.
* @returns The id of the transformer that can transform the given value.
*/
protected getTransformerId(value: unknown, key: string): null | string;
/**
* Restores the given value.
*
* @param transformedValue - The value to restore.
* @param key - The key of the value to restore.
* @returns The restored value.
*/
protected abstract restoreValue(transformedValue: unknown, key: string): unknown;
/**
* Transforms the given value recursively.
*
* @param value - The value to transform.
* @param key - The key of the value to transform.
* @returns The transformed value.
*/
private transformValueRecursively;
}