Skip to content

Instantly share code, notes, and snippets.

@gnacu
Created October 18, 2025 00:39
Show Gist options
  • Select an option

  • Save gnacu/f2d4cb569a4cdf12caba946e3dc8fc3f to your computer and use it in GitHub Desktop.

Select an option

Save gnacu/f2d4cb569a4cdf12caba946e3dc8fc3f to your computer and use it in GitHub Desktop.
#!/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