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

Function fromInput

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

Source from the content-addressed store, hash-verified

157 * @since 4.0.0
158 */
159export const fromInput = (input: Input): UrlParams => {
160 if (isUrlParams(input)) {
161 return input
162 }
163 const parsed = fromInputNested(input)
164 const out: Array<[string, string]> = []
165 for (let i = 0; i < parsed.length; i++) {
166 if (Array.isArray(parsed[i][0])) {
167 const [keys, value] = parsed[i] as [Array<string>, string]
168 out.push([`${keys[0]}[${keys.slice(1).join("][")}]`, value])
169 } else {
170 out.push(parsed[i] as [string, string])
171 }
172 }
173 return make(out)
174}
175
176const fromInputNested = (input: Input): Array<[string | Array<string>, any]> => {
177 const entries = typeof (input as any)[Symbol.iterator] === "function"

Callers 2

UrlParams.tsFile · 0.70
toStringFunction · 0.70

Calls 5

isUrlParamsFunction · 0.85
fromInputNestedFunction · 0.85
pushMethod · 0.80
joinMethod · 0.80
makeFunction · 0.70

Tested by

no test coverage detected