DieselDepot-APP/node_modules/es-toolkit/dist/fp/array/unionWith.mjs
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
964 B
JavaScript

import { unionWith as unionWith$1 } from "../../array/unionWith.mjs";
//#region src/fp/array/unionWith.ts
/**
* Creates a function that returns unique values using a custom equality function.
*
* Values from the piped array are considered before values from secondArray. The equality
* function decides whether two values represent the same item.
*
* @template T - The type of elements in the arrays.
* @param secondArray - Values to include after the piped array.
* @param areItemsEqual - Returns true when two values are equal.
* @returns A function that maps a readonly array to its union with secondArray.
*
* @example
* import { pipe, unionWith } from 'es-toolkit/fp';
*
* pipe([{ id: 1 }], unionWith([{ id: 1 }, { id: 2 }], (a, b) => a.id === b.id));
* // => [{ id: 1 }, { id: 2 }]
*/
function unionWith(secondArray, areItemsEqual) {
return function(array) {
return unionWith$1(array, secondArray, areItemsEqual);
};
}
//#endregion
export { unionWith };