blob: aa489e8ae4b319654d2c843631c0deb506d90db4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
import cbor from 'cbor';
export function decodeCborFirst(input: string | Buffer | ArrayBufferView): any {
try {
// throws if there are extra bytes
return cbor.decodeFirstSync(input);
} catch (err) {
// if the error was due to extra bytes, return the unpacked value
if (err.value) {
return err.value;
}
throw err;
}
}
|