blob: 5f2e4d56558a17339f8193405cb68645590b3d75 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
import { BigNumber } from '@0x/utils';
import { ValueTransformer } from 'typeorm/decorator/options/ValueTransformer';
export class BigNumberTransformer implements ValueTransformer {
// tslint:disable-next-line:prefer-function-over-method
public to(value: BigNumber | null): string | null {
return value === null ? null : value.toString();
}
// tslint:disable-next-line:prefer-function-over-method
public from(value: string | null): BigNumber | null {
return value === null ? null : new BigNumber(value);
}
}
export const bigNumberTransformer = new BigNumberTransformer();
|