iter-tools-es
Version:
The iterable toolbox
35 lines (27 loc) • 794 B
JavaScript
const {
iterableCurry
} = require('../../internal/iterable.js');
const {
__firstOr
} = require('../$first-or/first-or.js');
const {
__includes
} = require('../$includes/includes.js');
const none = Symbol('none');
function __startsWithAny(iterable, values, same = Object.is) {
const first = __firstOr(iterable, none);
if (first === none) return false;
return __includes(values, first, (a, b) => same(b, a));
}
exports.__startsWithAny = __startsWithAny;
const startsWithAny = /*#__PURE__*/iterableCurry(__startsWithAny, {
minArgs: 1,
maxArgs: 2,
reduces: true,
validateArgs(args) {
if (true && typeof args[0] === 'string') {
console.warn('For string inputs use startsWithAnySeq instead of startsWithAny');
}
}
});
exports.startsWithAny = startsWithAny;