| 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) |
| 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 |