(sd = 20)
| 6 | } |
| 7 | |
| 8 | static random(sd = 20): Decimal { |
| 9 | if (TARGET_BUILD_TYPE === 'wasm-compiler-edge') { |
| 10 | const bytes = globalThis.crypto.getRandomValues(new Uint8Array(sd)) |
| 11 | const result = bytes.reduce((acc, byte) => acc + byte, '') |
| 12 | return new DecimalLight(`0.${result.slice(0, sd)}`) |
| 13 | } else { |
| 14 | throw new Error('Not implemented for Node.js yet') |
| 15 | } |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | export default Decimal |