iter-tools-es
Version:
The iterable toolbox
26 lines (20 loc) • 615 B
JavaScript
const {
asyncIterableCurry
} = require('../../internal/async-iterable.js');
const {
__asyncFirstOr
} = require('../$first-or/async-first-or.js');
const none = Symbol('none');
async function __asyncStartsWith(iterable, value, same = Object.is) {
const first = await __asyncFirstOr(iterable, none);
if (first === none) return false;
return same(value, first);
}
exports.__asyncStartsWith = __asyncStartsWith;
const asyncStartsWith = /*#__PURE__*/asyncIterableCurry(__asyncStartsWith, {
minArgs: 1,
maxArgs: 2,
reduces: true,
validateArgs(args) {}
});
exports.asyncStartsWith = asyncStartsWith;