MCPcopy Create free account
hub / github.com/Effect-TS/effect / parse

Function parse

packages/effect/src/unstable/encoding/Yaml.ts:526–541  ·  view source on GitHub ↗
(input: string)

Source from the content-addressed store, hash-verified

524 * @since 4.0.0
525 */
526export const parse = (input: string): unknown => {
527 const source = input.replace(/^\uFEFF/, "").replace(/\r\n?/g, "\n")
528 const lines = source.split("\n").map((raw, index): Line => {
529 const indentation = /^( *)/.exec(raw)![1].length
530 if (raw.slice(0, indentation + 1).includes("\t")) {
531 throw new SyntaxError(`Tabs cannot be used for YAML indentation at line ${index + 1}`)
532 }
533 return {
534 raw,
535 text: stripComment(raw.slice(indentation)),
536 indent: indentation,
537 number: index + 1
538 }
539 })
540 return new YamlParser(lines).parse()
541}

Callers

nothing calls this directly

Calls 6

stripCommentFunction · 0.85
execMethod · 0.80
replaceMethod · 0.45
mapMethod · 0.45
splitMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected