Genotype API Documentation - v0.1.0
    Preparing search index...

    Class CharSet

    A 256-bit lookup table for O(1) ASCII character membership testing.

    CharSet stores one bit per possible byte value (0–255) in a compact 32-byte Uint8Array. Membership tests are a single array lookup and bit mask — no hashing, no branching, no string allocation.

    Use the from factory to create a CharSet from a string of characters. For common nucleotide groupings, use the pre-built sets in Bases instead of constructing your own.

    const vowels = CharSet.from("AEIOU");
    vowels.has(0x41); // true ('A')
    vowels.has(0x42); // false ('B')

    // With GenotypeString:
    const gs = GenotypeString.fromString("ATCG");
    gs.isAnyOf(0, vowels); // true (position 0 is 'A')
    Index

    Methods

    Properties

    Methods

    • Creates a CharSet containing all characters in the given string.

      Each character's ASCII code point sets the corresponding bit in the internal 256-bit table. Duplicate characters are harmless.

      Parameters

      • chars: string

      Returns CharSet

    • Returns whether the given byte value is a member of this set.

      Parameters

      • code: number

        An ASCII code point (0–255)

      Returns boolean

    Properties

    bits: Uint8Array