dCBOR Pattern TypeScript - v1.0.0-alpha.20
    Preparing search index...

    Interface Matcher

    Interface for objects that can match against CBOR values.

    This interface defines the contract for all pattern types in the system. Implementations handle matching, path collection, and VM bytecode compilation.

    interface Matcher {
        pathsWithCaptures(haystack: Cbor): MatchWithCaptures;
        paths(haystack: Cbor): Path[];
        matches(haystack: Cbor): boolean;
        compile(code: Instr[], literals: Pattern[], captures: string[]): void;
        collectCaptureNames(names: string[]): void;
        isComplex(): boolean;
        toString(): string;
    }
    Index

    Methods

    • Return only the matching paths, discarding any captures.

      Parameters

      • haystack: Cbor

        The CBOR value to match against

      Returns Path[]

      Array of paths to matching elements

    • Check if the pattern matches the given CBOR value.

      Parameters

      • haystack: Cbor

        The CBOR value to test

      Returns boolean

      true if the pattern matches

    • Compile this pattern into VM bytecode.

      Parameters

      • code: Instr[]

        The instruction array to append to

      • literals: Pattern[]

        The literals array to append to

      • captures: string[]

        The capture names array

      Returns void

    • Recursively collect all capture names from this pattern.

      Parameters

      • names: string[]

        The array to collect names into

      Returns void

    • Check if the pattern display is "complex" (requires parentheses).

      Returns boolean

      true if the pattern requires grouping