just-order-by
Version:
Produces a new array, sorted in given order
16 lines (11 loc) • 328 B
TypeScript
type ValueGetter<T, Result = unknown> = (value: T) => Result;
type OrderParamProperty<T> = keyof T | ValueGetter<T>;
type OrderParam<T> = {
property: OrderParamProperty<T>;
order?: 'asc' | 'desc';
};
declare function orderBy<T>(
arr: T[],
params?: [OrderParam<T>, ...OrderParam<T>[]]
): T[];
export default orderBy;