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

Function makeExit

packages/effect/src/Micro.ts:778–818  ·  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

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…