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

Function all

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

Source from the content-addressed store, hash-verified

199export 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
228const defaultBooleanOptions = {
229 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