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

Function mappingSeparator

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

Source from the content-addressed store, hash-verified

74}
75
76const mappingSeparator = (input: string): number => {
77 let quote: "'" | "\"" | undefined
78 let escaped = false
79 let depth = 0
80 for (let index = 0; index < input.length; index++) {
81 const character = input[index]
82 if (quote === "\"") {
83 if (escaped) escaped = false
84 else if (character === "\\") escaped = true
85 else if (character === quote) quote = undefined
86 } else if (quote === "'") {
87 if (character === quote && input[index + 1] === quote) index++
88 else if (character === quote) quote = undefined
89 } else if (character === "'" || character === "\"") {
90 quote = character
91 } else if (character === "[" || character === "{") {
92 depth++
93 } else if (character === "]" || character === "}") {
94 depth--
95 } else if (character === ":" && depth === 0 && (input[index + 1] === undefined || /\s/.test(input[index + 1]))) {
96 return index
97 }
98 }
99 return -1
100}
101
102const parseDoubleQuoted = (input: string): string => {
103 if (!input.endsWith("\"") || input.length < 2) {

Callers 3

parseNodeMethod · 0.85
parseMappingMethod · 0.85
parseSequenceMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected