Created
October 18, 2025 00:39
-
-
Save gnacu/f2d4cb569a4cdf12caba946e3dc8fc3f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env node | |
| import { Parser } from "expr-eval"; | |
| function readStdin(callback) { | |
| let data = ""; | |
| process.stdin.setEncoding("utf8"); | |
| process.stdin.on("data",(chunk) => { | |
| data += chunk; | |
| }); | |
| process.stdin.on("end",() => { | |
| callback(data); | |
| }); | |
| } | |
| readStdin((expression) => { | |
| const parser = new Parser(); | |
| let result = parser.evaluate(expression); | |
| process.stdout.write(result.toString()); | |
| }); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment