MCPcopy Index your code
hub / github.com/JavaScriptRegenerated/yieldparser / optional

Function optional

src/index.ts:153–158  ·  view source on GitHub ↗
(...potentials: Array<ParseYieldable | any>)

Source from the content-addressed store, hash-verified

151}
152
153export function optional(...potentials: Array<ParseYieldable | any>): () => ParseGenerator<any> {
154 return function* () {
155 const result = yield [...potentials, ''];
156 return result === '' ? undefined : result;
157 };
158}
159
160export function lookAhead(regex: RegExp) {
161 const lookAheadRegex = new RegExp(`^(?=${regex.source})`);

Callers 8

WeekdayParserFunction · 0.90
AnotherWeekdayParserFunction · 0.90
WeekdaysParserFunction · 0.90
TimeOfDayParserFunction · 0.90
TimespanSuffixParserFunction · 0.90
TimespanParserFunction · 0.90
NaturalDateParserFunction · 0.90
ParserMethod · 0.90

Calls

no outgoing calls

Tested by 8

WeekdayParserFunction · 0.72
AnotherWeekdayParserFunction · 0.72
WeekdaysParserFunction · 0.72
TimeOfDayParserFunction · 0.72
TimespanSuffixParserFunction · 0.72
TimespanParserFunction · 0.72
NaturalDateParserFunction · 0.72
ParserMethod · 0.72