UNPKG

iter-tools-es

Version:
35 lines (27 loc) 794 B
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;