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

Method captureSegment

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

Source from the content-addressed store, hash-verified

358 this.tagMap.set(handle, prefix);
359 }
360 captureSegment(start: number, end: number, checkJson: boolean) {
361 if (start < end) {
362 const result = this.#scanner.source.slice(start, end);
363
364 if (checkJson) {
365 for (let position = 0; position < result.length; position++) {
366 const character = result.charCodeAt(position);
367 if (
368 !(character === 0x09 ||
369 (0x20 <= character && character <= 0x10ffff))
370 ) {
371 throw this.#createError(
372 `Expected valid JSON character: received "${character}"`,
373 );
374 }
375 }
376 } else if (PATTERN_NON_PRINTABLE_REGEXP.test(result)) {
377 throw this.#createError("Stream contains non-printable characters");
378 }
379
380 return result;
381 }
382 }
383 readBlockSequence(
384 tag: string | null,
385 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