All files / sheaves/src section.ts

100% Statements 2/2
100% Branches 0/0
100% Functions 1/1
100% Lines 2/2

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23                                  6x     105x    
import { makeExo } from '@endo/exo';
import type { InterfaceGuard } from '@endo/patterns';
 
import type { Section } from './types.ts';
 
/**
 * Create a local section from a name, guard, and handler map.
 *
 * Encapsulates the cast from makeExo's opaque return type to Section.
 * Use this when constructing sections for a sheaf; do not use it for
 * the dispatch exo produced by sheafify itself.
 *
 * @param name - Exo tag name.
 * @param guard - Interface guard describing the section's methods.
 * @param handlers - Method handler map.
 * @returns A Section suitable for inclusion in a sheaf.
 */
export const makeSection = (
  name: string,
  guard: InterfaceGuard,
  handlers: Record<string, (...args: unknown[]) => unknown>,
): Section => makeExo(name, guard, handlers) as unknown as Section;