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

Function fromInputNested

packages/platform/src/UrlParams.ts:60–80  ·  view source on GitHub ↗
(input: Input)

Source from the content-addressed store, hash-verified

58}
59
60const fromInputNested = (input: Input): Array<[string | Array<string>, any]> => {
61 const entries = Symbol.iterator in input ? Arr.fromIterable(input) : Object.entries(input)
62 const out: Array<[string | Array<string>, string]> = []
63 for (const [key, value] of entries) {
64 if (Array.isArray(value)) {
65 for (let i = 0; i < value.length; i++) {
66 if (value[i] !== undefined) {
67 out.push([key, String(value[i])])
68 }
69 }
70 } else if (typeof value === "object") {
71 const nested = fromInputNested(value as CoercibleRecord)
72 for (const [k, v] of nested) {
73 out.push([[key, ...(typeof k === "string" ? [k] : k)], v])
74 }
75 } else if (value !== undefined) {
76 out.push([key, String(value)])
77 }
78 }
79 return out
80}
81
82/**
83 * @since 1.0.0

Callers 1

fromInputFunction · 0.85

Calls 2

StringInterface · 0.85
entriesMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…