import varint from './vendor/varint.js';
export function decode(data, offset = 0) {
    const code = varint.decode(data, offset);
    const length = varint.decode.bytes;
    if (length > 9) {
        throw new RangeError('Invalid varint: too long');
    }
    if (length > 1 && data[offset + length - 1] === 0) {
        throw new RangeError('Invalid varint: not minimally encoded');
    }
    return [code, length];
}
export function encodeTo(int, target, offset = 0) {
    varint.encode(int, target, offset);
    return target;
}
export function encodingLength(int) {
    return varint.encodingLength(int);
}
//# sourceMappingURL=varint.js.map