• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// listen for test cases, and provide the results.
2// give JSON of the test case, receive the result
3// Example:
4// > {"func":"tan", "args":["12.5"], "config":{"precision":8}}
5// -0.066468242
6
7
8import {Decimal} from '../../decimal.mjs';
9import {createInterface} from 'readline';
10
11const readline = createInterface({
12	input: process.stdin,
13	output: process.stdout
14});
15
16readline.on("close", () => {console.log('\n'); process.exit(0);});
17
18readline.on("line", (line) => {
19    if (line) {
20        const {func, args, config} = JSON.parse(line);
21        config.defaults = true;
22        Decimal.set(config);
23        const result = Decimal[func](...args);
24        console.log(result);
25    }
26});