MCPcopy
hub / github.com/Effect-TS/effect / all

Function all

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

Source from the content-addressed store, hash-verified

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