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

Function all

packages/cli/src/internal/options.ts:200–225  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected