How pjs works: Expressions and Variables
masterpjs is a CLI tool that processes input from stdin or files using a streaming API. It applies operations in a specific order: filter, then map, then reduce.
To make one-liners easier, pjs automatically binds identifiers from String.prototype to the current line. You can also use specific variables to access data:
$: The current line (value).i: The current index.prev: The accumulated value (used in customreduceexpressions).curr: The current value (used in customreduceexpressions).array: The full array (used in customreduceexpressions).
Additionally, pjs provides access to:
_: Lodash functions.R: Ramda functions.$$: Used for chaining expressions.
# Example of using $ and String.prototype methods
echo 'foo' | pjs -m 'toUpperCase()'