Getting Started
jetl
is a data processing library for JavaScript built on top of asynchronous iterators.
It is written in TypeScript and compiles to pure JavaScript, meaning that it can be used in both server and browser environments.
Quick Start
This example processes an array of integer numbers by:
- filtering out the odd numbers
- increasing each remaining number by 1
- computing their sum
The example is editable so you can play around with it
Live Editor
Result
Loading...
How it works
[1, 2, 3, 4, 5, 6]
provides the initial data source to the pipeline as an array of numbersfilter(n => n % 2 === 0)
adds an operation which filters only the even numbersmap(n => n + 1)
transforms each element by incrementing it by 1apply(reduce((acc, c) => acc + c, 0))
applies an operator which, given the transformed array of numbers, turns it into the sum of those numbers.run()
executes the pipeline and returns an asynchronously iterable of resultsawait first(result)
asynchronously returns the first element of the result
Concepts
In the example above:
new pipeline()
creates a new pipelinefilter
,map
,apply
are operations. Operations are functions which accept iterables as inputs and return iterables as outputreduce
andfirst
are operator. Operators are functions which accept iterables as input and can return anything (including scalar values)