@btc-vision/bsi-common
Version:
Common library for OP_NET.
22 lines (21 loc) • 706 B
JavaScript
import { Decimal128, ObjectId } from 'mongodb';
export class TypeConverter {
static bigintToDecimal128(value) {
return Decimal128.fromString(value.toString());
}
static decimal128ToBigint(value) {
return BigInt(value.toString());
}
static numberToDecimal128(value) {
return Decimal128.fromString(value.toString());
}
static stringToObjectId(value) {
return new ObjectId(value);
}
static decimal128ToBigintArray(values) {
return values.map((value) => TypeConverter.decimal128ToBigint(value));
}
static bigintToDecimal128Array(values) {
return values.map((value) => TypeConverter.bigintToDecimal128(value));
}
}