Function binstrtonamearray

  • convert bit string to array of names to

    Parameters

    • binstr: string

      binary string (ex. "1001")

    • namedb: Record<string, number>

      associative array of name and index

    Returns string[]

    array of names

    See

    namearraytobinstr

    Description

    This function converts from binary string to an array of names defined in namedb.

    Example

    const db: Record<string, number> = { a: 0, b: 3, c: 8, d: 9, e: 17, f: 19 };
    binstrtonamearray('1000000011', db) -> ['a', 'c', 'd']
    binstrtonamearray(''000100001', db) -> ['b', 'c']

    const db2: Record<string, number> = { "apple": 0, "orange": 1, "grape": 2, "mango", 3 };
    binstrtonamearray('0101', db2) -> ['orange', 'mango']
    binstrtonamearray('101', db2) -> ['apple', 'grape']