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

Function makeExit

packages/effect/src/Micro.ts:779–819  ·  view source on GitHub ↗
(options: {
  readonly op: "Success" | "Failure"
  readonly prop: Prop
  readonly eval: (
    this:
      & MicroExit<unknown, unknown>
      & { [args]: Parameters<Fn>[0] },
    fiber: MicroFiberImpl<unknown, unknown>
  ) => Primitive | Yield
})

Source from the content-addressed store, hash-verified

777}
778
779const makeExit = <Fn extends (...args: Array<any>) => any, Prop extends string>(options: {
780 readonly op: "Success" | "Failure"
781 readonly prop: Prop
782 readonly eval: (
783 this:
784 & MicroExit<unknown, unknown>
785 & { [args]: Parameters<Fn>[0] },
786 fiber: MicroFiberImpl<unknown, unknown>
787 ) => Primitive | Yield
788}): Fn => {
789 const Proto = {
790 ...makePrimitiveProto(options),
791 [MicroExitTypeId]: MicroExitTypeId,
792 _tag: options.op,
793 get [options.prop](): any {
794 return (this as any)[args]
795 },
796 toJSON(this: any) {
797 return {
798 _id: "MicroExit",
799 _tag: options.op,
800 [options.prop]: this[args]
801 }
802 },
803 [Equal.symbol](this: any, that: any): boolean {
804 return isMicroExit(that) && that._tag === options.op &&
805 Equal.equals(this[args], (that as any)[args])
806 },
807 [Hash.symbol](this: any): number {
808 return Hash.cached(this, Hash.combine(Hash.string(options.op))(Hash.hash(this[args])))
809 }
810 }
811 return function(value: unknown) {
812 const self = Object.create(Proto)
813 self[args] = value
814 self[successCont] = undefined
815 self[failureCont] = undefined
816 self[ensureCont] = undefined
817 return self
818 } as Fn
819}
820
821/**
822 * Creates a `Micro` effect that will succeed with the specified constant value.

Callers 1

Micro.tsFile · 0.85

Calls 2

makePrimitiveProtoFunction · 0.85
createMethod · 0.80

Tested by

no test coverage detected