Accessing stdin with file descriptor 0
In Node.js, you can access stdin
using file descriptor 0 to take input stream:
const fs = require("fs");
const data = fs.readFileSync(0, "utf-8");
This can be used on the Node.js CLI:
echo Peter Mekhaeil | node -p "fs.readFileSync(0, 'utf8').toLowerCase().replaceAll(' ','-')"