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

Function all

packages/cli/src/internal/args.ts:164–187  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

162export const all: <
163 const Arg extends Iterable<Args.Args<any>> | Record<string, Args.Args<any>>
164>(arg: Arg) => Args.All.Return<Arg> = function() {
165 if (arguments.length === 1) {
166 if (isArgs(arguments[0])) {
167 return map(arguments[0], (x) => [x]) as any
168 } else if (Arr.isArray(arguments[0])) {
169 return allTupled(arguments[0] as Array<any>) as any
170 } else {
171 const entries = Object.entries(arguments[0] as Readonly<{ [K: string]: Args.Args<any> }>)
172 let result = map(entries[0][1], (value) => ({ [entries[0][0]]: value }))
173 if (entries.length === 1) {
174 return result as any
175 }
176 const rest = entries.slice(1)
177 for (const [key, options] of rest) {
178 result = map(makeBoth(result, options), ([record, value]) => ({
179 ...record,
180 [key]: value
181 }))
182 }
183 return result as any
184 }
185 }
186 return allTupled(arguments[0]) as any
187}
188
189/** @internal */
190export const boolean = (config?: Args.Args.BaseArgsConfig): Args.Args<boolean> =>

Callers

nothing calls this directly

Calls 5

isArgsFunction · 0.85
entriesMethod · 0.80
allTupledFunction · 0.70
makeBothFunction · 0.70
mapFunction · 0.50

Tested by

no test coverage detected