src/0-core/_fast/_from_digit.js
import assert from 'assert';
import {One, Two, Three, Four} from '../../1-digit/index.js';
import {Empty, Single, Deep} from '../../3-tree/index.js';
import {cache} from '../measure/index.js';
export function _from_digit(M, digit) {
if (digit instanceof One) return new Single(M, digit.a);
assert(
digit instanceof Two || digit instanceof Three || digit instanceof Four,
);
return new Deep(M, digit.init(), new Empty(cache(M)), new One(digit.last()));
}