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

Function append

packages/effect/src/SchemaGetter.ts:1966–1986  ·  view source on GitHub ↗
(key: string, value: unknown)

Source from the content-addressed store, hash-verified

1964 const bracketPathEntries: Array<[string, A]> = []
1965
1966 function append(key: string, value: unknown): void {
1967 if (isLeaf(value)) {
1968 bracketPathEntries.push([key, value])
1969 } else if (Array.isArray(value)) {
1970 // If all values are leaves, encode as multiple entries with the same key
1971 const allLeaves = value.every(isLeaf)
1972 if (allLeaves) {
1973 value.forEach((v) => {
1974 bracketPathEntries.push([key, v])
1975 })
1976 } else {
1977 value.forEach((v, i) => {
1978 append(`${key}[${i}]`, v)
1979 })
1980 }
1981 } else if (typeof value === "object" && value !== null) {
1982 for (const [k, v] of Object.entries(value)) {
1983 append(`${key}[${k}]`, v)
1984 }
1985 }
1986 }
1987
1988 for (const [key, value] of Object.entries(input)) {
1989 append(key, value)

Callers 1

Calls 2

pushMethod · 0.80
forEachMethod · 0.65

Tested by

no test coverage detected