iter-tools-es
Version:
The iterable toolbox
39 lines (31 loc) • 760 B
JavaScript
const {
iterableCurry
} = require('../../internal/iterable.js');
const {
__zipAll
} = require('../$zip-all/zip-all.js');
const {
__sliceFromStart
} = require('../$slice/slice.js');
const none = Symbol('none');
const zipAllConfig = {
filler: none
};
function __equal(iterables, same = Object.is) {
if (iterables.length <= 1) return true;
for (const stepValues of __zipAll(iterables, zipAllConfig)) {
const firstValue = stepValues[0];
for (const value of __sliceFromStart(stepValues, 1)) {
if (!same(value, firstValue)) return false;
}
}
return true;
}
exports.__equal = __equal;
const equal = /*#__PURE__*/iterableCurry(__equal, {
minArgs: 0,
maxArgs: 1,
variadic: true,
reduces: true
});
exports.equal = equal;