| 199 | export const all: < |
| 200 | const Arg extends Iterable<Options.Options<any>> | Record<string, Options.Options<any>> |
| 201 | >(arg: Arg) => Options.All.Return<Arg> = function() { |
| 202 | if (arguments.length === 1) { |
| 203 | if (isOptions(arguments[0])) { |
| 204 | return map(arguments[0], (x) => [x]) as any |
| 205 | } else if (Arr.isArray(arguments[0])) { |
| 206 | return allTupled(arguments[0] as Array<any>) as any |
| 207 | } else { |
| 208 | const entries = Object.entries( |
| 209 | arguments[0] as Readonly<{ [K: string]: Options.Options<any> }> |
| 210 | ) |
| 211 | let result = map(entries[0][1], (value) => ({ [entries[0][0]]: value })) |
| 212 | if (entries.length === 1) { |
| 213 | return result as any |
| 214 | } |
| 215 | const rest = entries.slice(1) |
| 216 | for (const [key, options] of rest) { |
| 217 | result = map(makeBoth(result, options), ([record, value]) => ({ |
| 218 | ...record, |
| 219 | [key]: value |
| 220 | })) |
| 221 | } |
| 222 | return result as any |
| 223 | } |
| 224 | } |
| 225 | return allTupled(arguments[0]) as any |
| 226 | } |
| 227 | |
| 228 | const defaultBooleanOptions = { |
| 229 | ifPresent: true, |