deep-equality-data-structures
Version:
Javascript data structures (e.g., Map, Set) that support deep object equality
20 lines (19 loc) • 761 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.areEqual = areEqual;
const errors_1 = require("./errors");
const set_1 = require("./set");
/**
* Static utility for doing a one-time equality check across the provided values.
* @param values list whose elements will be compared to each other
* @param options configuration options
* @returns true if every element in `values` is equal to every other element
* @throws {Error} if `values` list is empty
*/
function areEqual(values, options) {
if (values.length === 0) {
throw new errors_1.DeepEqualityDataStructuresError('Empty values list passed to areEqual function');
}
const set = new set_1.DeepSet(values, options);
return set.size === 1;
}