The number to extract digits.
The radix of digit.
The list of digits of the number.
import { digits, toArray } from "./list.ts";
import { assertEquals } from "../deps.ts";
assertEquals(toArray(digits(51413, 10)), [3, 1, 4, 1, 5]);
assertEquals(toArray(digits(0x51413, 16)), [3, 1, 4, 1, 5]);
assertEquals(toArray(digits(0o51413, 8)), [3, 1, 4, 1, 5]);
assertEquals(toArray(digits(0b1001011001, 2)), [
1,
0,
0,
1,
1,
0,
1,
0,
0,
1,
]);
assertEquals(toArray(digits(0, 10)), []);
Generated using TypeDoc
Extracts digits of the number.