(input: Input)
| 44 | * @category constructors |
| 45 | */ |
| 46 | export const fromInput = (input: Input): UrlParams => { |
| 47 | const parsed = fromInputNested(input) |
| 48 | const out: Array<[string, string]> = [] |
| 49 | for (let i = 0; i < parsed.length; i++) { |
| 50 | if (Array.isArray(parsed[i][0])) { |
| 51 | const [keys, value] = parsed[i] as [Array<string>, string] |
| 52 | out.push([`${keys[0]}[${keys.slice(1).join("][")}]`, value]) |
| 53 | } else { |
| 54 | out.push(parsed[i] as [string, string]) |
| 55 | } |
| 56 | } |
| 57 | return out |
| 58 | } |
| 59 | |
| 60 | const fromInputNested = (input: Input): Array<[string | Array<string>, any]> => { |
| 61 | const entries = Symbol.iterator in input ? Arr.fromIterable(input) : Object.entries(input) |
no test coverage detected
searching dependent graphs…