@akala/core
Version:
29 lines (28 loc) • 1.03 kB
TypeScript
import type { Expressions } from "./expressions/index.js";
import type { Formatter, ReversibleFormatter } from "../formatters/common.js";
export type SortDirection = 'asc' | 'desc' | 'none';
/**
* A formatter that converts any value to a boolean
*
* @example
* Booleanize.instance.format('truthy value') // returns true
* Booleanize.instance.format(0) // returns false
*/
export default class Sort<T> implements Formatter<T[]> {
static compare<T>(a: T, b: T): number;
private readonly sortSettings;
constructor(sortSettings: {
path: Expressions;
direction: SortDirection;
}[]);
/**
* Converts any input value to a boolean using double negation
* @param a - The value to convert to boolean
* @returns Boolean representation of the input value
*/
format(a: Array<T> | undefined | null): T[];
}
export declare class ParserFormatter implements ReversibleFormatter<Expressions, string> {
unformat(value: Expressions): string;
format(value: string): Expressions;
}