@fourlights/mapper
Version:
A simple data mapper written in typescript
22 lines (20 loc) • 799 B
text/typescript
type MapperFn<T> = (data: T, outerKey?: string, innerKey?: string | number) => any;
type MapperPropertyOptions = {
structure?: MapperFn<any>;
init?: MapperFn<any>;
};
type MapperProperty<TData, TOptions extends {} = {}> = {
value: MapperFn<TData>;
apply?: MapperFn<any>;
options?: MapperPropertyOptions & TOptions;
};
type MapperConfig<TData, TOptions extends {} = {}> = {
[key: string | symbol]: MapperProperty<TData, TOptions> | MapperFn<TData>;
};
type MapperPlugin = {
config: <TData, TOptions extends {} = {}>(config: MapperConfig<TData, TOptions>, options?: MapperOptions) => MapperConfig<TData>;
};
type MapperOptions = {
plugins?: MapperPlugin[];
};
export type { MapperConfig, MapperFn, MapperOptions, MapperPlugin, MapperProperty, MapperPropertyOptions };