Refactoring
All checks were successful
Lint / lint (push) Successful in 11s

This commit is contained in:
Julien Valverdé
2025-07-17 13:31:17 +02:00
parent da3b672441
commit 671156daff

View File

@@ -170,30 +170,40 @@ export namespace make {
i: (_: H, props: NoInfer<P>) => Effect.Effect<React.ReactNode, EOut, ROut>, i: (_: H, props: NoInfer<P>) => Effect.Effect<React.ReactNode, EOut, ROut>,
): Component<EOut, ROut, P> ): Component<EOut, ROut, P>
} }
}
export interface Options { export const make: (
readonly untraced?: boolean & make.Gen
readonly finalizerExecutionMode?: "sync" | "fork" & ((
readonly finalizerExecutionStrategy?: ExecutionStrategy.ExecutionStrategy spanName: string,
spanOptions?: Tracer.SpanOptions,
) => make.Gen)
) = (spanNameOrBody: Function | string, ...pipeables: any[]) => {
if (typeof spanNameOrBody !== "string") {
const displayName = displayNameFromBody(spanNameOrBody)
return Object.setPrototypeOf({
body: displayName
? Effect.fn(displayName)(spanNameOrBody as any, ...pipeables as [])
: Effect.fn(spanNameOrBody as any, ...pipeables),
displayName,
}, ComponentProto)
}
else {
const spanOptions = pipeables[0]
return (body: any, ...pipeables: any[]) => Object.setPrototypeOf({
body: Effect.fn(spanNameOrBody, spanOptions)(body, ...pipeables as []),
displayName: displayNameFromBody(body) ?? spanNameOrBody,
}, ComponentProto)
} }
} }
export const make: make.Gen = (...pipeables: readonly [any]) => { export const makeUntraced: make.Gen = (body: Function, ...pipeables: any[]) => Object.setPrototypeOf({
const displayName: string = !String.isEmpty(pipeables[0].name) ? pipeables[0].name : undefined body: Effect.fnUntraced(body as any, ...pipeables as []),
displayName: displayNameFromBody(body),
return Object.setPrototypeOf({
body: displayName
? Effect.fn(displayName)(...pipeables)
: Effect.fn(...pipeables),
displayName,
}, ComponentProto)
}
export const makeUntraced: make.Gen = (...pipeables: readonly [any]) => Object.setPrototypeOf({
body: Effect.fnUntraced(...pipeables),
displayName: !String.isEmpty(pipeables[0].name) ? pipeables[0].name : undefined,
}, ComponentProto) }, ComponentProto)
const displayNameFromBody = (body: Function) => !String.isEmpty(body.name) ? body.name : undefined
export const withRuntime: { export const withRuntime: {
<E, R, P extends {}>( <E, R, P extends {}>(