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

Function makeLine

packages/effect/src/encoding/Yaml.ts:907–925  ·  view source on GitHub ↗
(raw: string, number: number)

Source from the content-addressed store, hash-verified

905}
906
907const makeLine = (raw: string, number: number): Line => {
908 let indentation = 0
909 while (raw.charCodeAt(indentation) === 32) indentation++
910 // Scan `raw` once, including indentation, so comment and separator indices share an origin.
911 const found = { separator: -1 }
912 const comment = findIndicator(raw, "#", 0, found)
913 return {
914 raw,
915 text: comment === -1
916 ? raw.slice(indentation)
917 : raw.slice(indentation, Math.max(indentation, whiteEnd(raw, comment))),
918 indent: indentation,
919 number,
920 // Rejected where the line is read as structure; block scalar content may hold tabs.
921 tabIndent: raw.charCodeAt(indentation) === 9,
922 comment: comment !== -1,
923 separator: found.separator === -1 ? -1 : found.separator - indentation
924 }
925}
926
927// Removes the comment from a marker or directive line, keeping characters before
928// it that are not YAML separation so they can be rejected.

Callers 2

parseStreamMethod · 0.85
decodeFunction · 0.85

Calls 3

findIndicatorFunction · 0.85
whiteEndFunction · 0.85
sliceMethod · 0.80

Tested by

no test coverage detected