iter-tools-es
Version:
The iterable toolbox
31 lines (24 loc) • 674 B
JavaScript
const {
iterableCurry
} = require('../../internal/iterable.js');
const {
__firstOr
} = require('../$first-or/first-or.js');
const none = Symbol('none');
function __startsWith(iterable, value, same = Object.is) {
const first = __firstOr(iterable, none);
if (first === none) return false;
return same(value, first);
}
exports.__startsWith = __startsWith;
const startsWith = /*#__PURE__*/iterableCurry(__startsWith, {
minArgs: 1,
maxArgs: 2,
reduces: true,
validateArgs(args) {
if (true && typeof args[0] === 'string') {
console.warn('For string inputs use startsWithSeq instead of startsWith');
}
}
});
exports.startsWith = startsWith;