-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
First of all, to read from the Standard Input (stdin) the library purescript-node-process is needed. This library exposes stdin which is a Readable (a simple readable stream) and it will be the key component around which we’ll create our function. Since we are dealing with a simple stream, what we want to create is a function that takes that same stream and return a new string:
This looks a bit messy but it’s actually simple. Since the process of handling a stream is “event-driven” we are going to use a safe mutable string (from purescript-st) to accumulate our input every time the onDataString event will be triggered. This whole process is asynchronous, meaning that we have to wait for the onEnd event (or onError if something bad happened) to actually return the accumulated string. The effect monad Aff solves this through makeAff. The res callback has to be called with an Either parameter, and only when this callback will be triggered the program can continue its execution.