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

Function makePrimitive

packages/effect/src/internal/core.ts:418–459  ·  view source on GitHub ↗
(options: {
  readonly op: string
  readonly single?: Single
  readonly [evaluate]?: (
    this: Primitive & {
      readonly [args]: Single extends true ? Parameters<Fn>[0] : Parameters<Fn>
    },
    fiber: FiberImpl
  ) => Primitive | Effect.Effect<any, any, any> | Yield
  readonly [contA]?: (
    this: Primitive & {
      readonly [args]: Single extends true ? Parameters<Fn>[0] : Parameters<Fn>
    },
    value: any,
    fiber: FiberImpl,
    exit?: Exit.Exit<any, any>
  ) => Primitive | Effect.Effect<any, any, any> | Yield
  readonly [contE]?: (
    this: Primitive & {
      readonly [args]: Single extends true ? Parameters<Fn>[0] : Parameters<Fn>
    },
    cause: Cause.Cause<any>,
    fiber: FiberImpl,
    exit?: Exit.Exit<any, any>
  ) => Primitive | Effect.Effect<any, any, any> | Yield
  readonly [contAll]?: (
    this: Primitive & {
      readonly [args]: Single extends true ? Parameters<Fn>[0] : Parameters<Fn>
    },
    fiber: FiberImpl
  ) => void | ((value: any, fiber: FiberImpl) => void)
})

Source from the content-addressed store, hash-verified

416
417/** @internal */
418export const makePrimitive = <
419 Fn extends (...args: Array<any>) => any,
420 Single extends boolean = true
421>(options: {
422 readonly op: string
423 readonly single?: Single
424 readonly [evaluate]?: (
425 this: Primitive & {
426 readonly [args]: Single extends true ? Parameters<Fn>[0] : Parameters<Fn>
427 },
428 fiber: FiberImpl
429 ) => Primitive | Effect.Effect<any, any, any> | Yield
430 readonly [contA]?: (
431 this: Primitive & {
432 readonly [args]: Single extends true ? Parameters<Fn>[0] : Parameters<Fn>
433 },
434 value: any,
435 fiber: FiberImpl,
436 exit?: Exit.Exit<any, any>
437 ) => Primitive | Effect.Effect<any, any, any> | Yield
438 readonly [contE]?: (
439 this: Primitive & {
440 readonly [args]: Single extends true ? Parameters<Fn>[0] : Parameters<Fn>
441 },
442 cause: Cause.Cause<any>,
443 fiber: FiberImpl,
444 exit?: Exit.Exit<any, any>
445 ) => Primitive | Effect.Effect<any, any, any> | Yield
446 readonly [contAll]?: (
447 this: Primitive & {
448 readonly [args]: Single extends true ? Parameters<Fn>[0] : Parameters<Fn>
449 },
450 fiber: FiberImpl
451 ) => void | ((value: any, fiber: FiberImpl) => void)
452}): Fn => {
453 const Proto = makePrimitiveProto(options as any)
454 return function() {
455 const self = Object.create(Proto)
456 self[args] = options.single === false ? arguments : arguments[0]
457 return self
458 } as Fn
459}
460
461/** @internal */
462export const makeExit = <

Callers 2

effect.tsFile · 0.90
core.tsFile · 0.70

Calls 1

makePrimitiveProtoFunction · 0.85

Tested by

no test coverage detected