DieselDepot-APP/node_modules/es-toolkit/dist/fp/array/orderBy.js
SJCoetz def597c157 chore: add generated build artifacts and node module type files
add all Next.js build outputs and third-party dependency type declaration files
2026-07-20 01:18:42 +02:00

26 lines
974 B
JavaScript

const require_orderBy = require("../../array/orderBy.js");
//#region src/fp/array/orderBy.ts
/**
* Creates a function that sorts objects by criteria and order directions.
*
* Criteria can be object keys or selector functions. The returned function does not mutate
* the input array; it returns a sorted copy following the main {@link orderBy} behavior.
*
* @template T - The object type in the array.
* @param criteria - Keys or selector functions used for comparison.
* @param orders - Sort directions corresponding to the criteria.
* @returns A function that maps a readonly array to a sorted copy.
*
* @example
* import { orderBy, pipe } from 'es-toolkit/fp';
*
* pipe([{ name: 'a', age: 2 }, { name: 'b', age: 1 }], orderBy(['age'], ['asc']));
* // => [{ name: 'b', age: 1 }, { name: 'a', age: 2 }]
*/
function orderBy(criteria, orders) {
return function(array) {
return require_orderBy.orderBy(array, criteria, orders);
};
}
//#endregion
exports.orderBy = orderBy;