Files
coopgo/node_modules/dnd-core/lib/utils/equality.js
sgauthier 6e64e138e2
All checks were successful
Publish To Prod / deploy_and_publish (push) Successful in 35s
planning
2024-10-14 09:15:30 +02:00

34 lines
807 B
JavaScript

export const strictEquality = (a, b) => a === b;
/**
* Determine if two cartesian coordinate offsets are equal
* @param offsetA
* @param offsetB
*/
export function areCoordsEqual(offsetA, offsetB) {
if (!offsetA && !offsetB) {
return true;
}
else if (!offsetA || !offsetB) {
return false;
}
else {
return offsetA.x === offsetB.x && offsetA.y === offsetB.y;
}
}
/**
* Determines if two arrays of items are equal
* @param a The first array of items
* @param b The second array of items
*/
export function areArraysEqual(a, b, isEqual = strictEquality) {
if (a.length !== b.length) {
return false;
}
for (let i = 0; i < a.length; ++i) {
if (!isEqual(a[i], b[i])) {
return false;
}
}
return true;
}