@akala/core
Version:
26 lines (25 loc) • 869 B
TypeScript
import type { Formatter, ReversibleFormatter } from "./common.js";
/**
* A formatter that returns the input value unchanged.
* This is useful for scenarios where no transformation is needed.
*/
export default class Identity implements Formatter<unknown>, ReversibleFormatter<unknown, unknown> {
/**
* Singleton instance for reuse.
*/
static readonly instance: Identity;
/**
* Returns the input value without modification.
* @template T - The type of the input value.
* @param {T} value - The value to format.
* @returns {T} The same input value.
*/
format<T>(value: T): T;
/**
* Returns the input value without modification.
* @template T - The type of the input value.
* @param {T} value - The value to unformat.
* @returns {T} The same input value.
*/
unformat<T>(value: T): T;
}