import { concat as uint8ArrayConcat } from 'uint8arrays/concat';
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string';
export function base64urlToBuffer(str, len) {
    let buf = uint8ArrayFromString(str, 'base64urlpad');
    if (len != null) {
        if (buf.length > len) {
            throw new Error('byte array longer than desired length');
        }
        buf = uint8ArrayConcat([new Uint8Array(len - buf.length), buf]);
    }
    return buf;
}
export function isPromise(thing) {
    if (thing == null) {
        return false;
    }
    return typeof thing.then === 'function' &&
        typeof thing.catch === 'function' &&
        typeof thing.finally === 'function';
}
//# sourceMappingURL=util.js.map