@buka/class-transformer-extra
Version:
class-transformer-extra contains methods that's aren't included in the class-transform package.
17 lines (16 loc) • 389 B
JavaScript
import { Transform } from 'class-transformer';
/**
* @returns BigInt Or NaN
*/
export function ToBigInt(options) {
return Transform(function ToBigIntTransform({ value }) {
if (options?.optional && value === undefined)
return undefined;
try {
return BigInt(value);
}
catch {
return NaN;
}
}, options);
}