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

Function fromInputNested

packages/effect/src/unstable/http/UrlParams.ts:176–198  ·  view source on GitHub ↗
(input: Input)

Source from the content-addressed store, hash-verified

174}
175
176const fromInputNested = (input: Input): Array<[string | Array<string>, any]> => {
177 const entries = typeof (input as any)[Symbol.iterator] === "function"
178 ? Arr.fromIterable(input as Iterable<readonly [string, Coercible]>)
179 : Object.entries(input)
180 const out: Array<[string | Array<string>, string]> = []
181 for (const [key, value] of entries) {
182 if (Array.isArray(value)) {
183 for (let i = 0; i < value.length; i++) {
184 if (value[i] !== undefined) {
185 out.push([key, String(value[i])])
186 }
187 }
188 } else if (typeof value === "object") {
189 const nested = fromInputNested(value as CoercibleRecord)
190 for (const [k, v] of nested) {
191 out.push([[key, ...(typeof k === "string" ? [k] : k)], v])
192 }
193 } else if (value !== undefined) {
194 out.push([key, String(value)])
195 }
196 }
197 return out
198}
199
200/**
201 * Provides an order-sensitive `Equivalence` instance for `UrlParams`.

Callers 1

fromInputFunction · 0.85

Calls 2

pushMethod · 0.80
StringInterface · 0.50

Tested by

no test coverage detected