Callback Parser

Every input passed to jstr can be manipulated by a JavaScript callback function, which is provided as the very last argument of the command.

Notation

(x: ParsedInputJson) => any

Examples

ParsedInputJson will be the provided input already parsed to its JS equivalent, so the callback can be used in many different ways.

For example, if you had the following file.json as input:

file.json
{
  "name": "Some name"
}

You could use the callback to get the value of the "name" key:

jstr file.json 'x => x.name'

This would print to the terminal:

"Some name"

ts-belt is exposed in the callback function to use. Just call your usual namespace such as D or A, or use the functions like pipe or flow.


The handler provided can also be an Examples, meaning you can do any sort of jibbery joo with promise/await and jstr will resolve that to you.

It is highly recommended to use ts-belt to parse your output, as it already has a bunch of useful utility functions to use in a FP style, meaning you can point-free the whole thing and have your output being handled supa fast.

Last updated