Function consumeBase

  • Consume all characters in a given base.

    Example

    consumeBase(8, 0, "0123456789")  // => [8, 342391]
    consumeBase(8, 1, "999") // => [1, 0]

    Returns

    the new offset and the number it consumed converted to base 10

    Parameters

    • base: number

      the base to use i.e. one of 2, 3, 4, 5 ,...

    • offset: number

      where in the string to start consuming

    • string: string

      the source string

    Returns [number, number]