| 174 | } |
| 175 | |
| 176 | const 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`. |