Callback Parser
Last updated
Last updated
Every input passed to jstr
can be manipulated by a JavaScript callback function, which is provided as the very last argument of the command.
(x: ParsedInputJson) => any
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:
You could use the callback to get the value of the "name"
key:
This would print to the terminal:
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 , 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.