UNPKG

iter-tools-es

Version:
31 lines (24 loc) 674 B
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;