Introducing pjs

(Day 19 of 30 Days of Blogging)

I’ve been working on a small project that can basically be summed up as awk for JS developers. pjs is a command-line tool for processing text-based files by writing snippets of JavaScript.

For example, converting each line to upper-case:

cat document.txt | pjs '_.toUpperCase()'

Or filtering lines:

seq 10 | pjs '_ % 2 == 0'

And a whole bunch of other stuff, including support for streaming CSV and JSON.

Under the hood it does some interesting things with static analysis and AST transformation to support all the magic. The magic can always be explained by running pjs with --explain to see the generated program.

I would say v1.0 is nearly finished, ETA being a confident “soon”, and probably will be done by the time anyone reads this.