MCPcopy Create free account
hub / github.com/denoland/std / captureSegment

Method captureSegment

yaml/_loader_state.ts:349–371  ·  view source on GitHub ↗
(start: number, end: number, checkJson: boolean)

Source from the content-addressed store, hash-verified

347 this.tagMap.set(handle, prefix);
348 }
349 captureSegment(start: number, end: number, checkJson: boolean) {
350 if (start < end) {
351 const result = this.#scanner.source.slice(start, end);
352
353 if (checkJson) {
354 for (let position = 0; position < result.length; position++) {
355 const character = result.charCodeAt(position);
356 if (
357 !(character === 0x09 ||
358 (0x20 <= character && character <= 0x10ffff))
359 ) {
360 throw this.#createError(
361 `Expected valid JSON character: received "${character}"`,
362 );
363 }
364 }
365 } else if (PATTERN_NON_PRINTABLE_REGEXP.test(result)) {
366 throw this.#createError("Stream contains non-printable characters");
367 }
368
369 return result;
370 }
371 }
372 readBlockSequence(
373 tag: string | null,
374 anchor: string | null,

Callers 4

readPlainScalarMethod · 0.95
readBlockScalarMethod · 0.95

Calls 2

#createErrorMethod · 0.95
sliceMethod · 0.45

Tested by

no test coverage detected