Now, with JS Array getting more and more powerful, especially with upcoming groupBy()
and at()
methods, projects like this become unneeded. Please use standard APIs.
Below is the original README.
Fluent Streams is a JavaScript and TypeScript library providing rich API for lazy iterables (arrays, sets, etc) processing. The main construct is a Stream which is a thin stateless wrapper over an iterable; there is also an Optional modeling existing or lacking value.
npm i fluent-streams
Fluent Streams lib is distributed compiled to ES5, so no additional transpilation needed, however it needs the following polyfills in older environments:
Optionally:
To create or generate a stream or an optional use one of factory functions; the most generic is stream() which creates a stream from any iterable.
Fluent Streams exports all functions and interfaces by name from index files,
so you import everything with import { ... } from 'fluent-streams'
.
import { stream } from 'fluent-streams';
stream(['Aspire', 'to', 'inspire', 'before', 'we', 'expire'])
.flatMap(word => word)
.groupBy(char => char)
.map(([char, chars]) => ([char, chars.length]))
.sortBy(([_, count]) => -count)
.take(3)
.toArray() // => [['e', 7], ['i', 4], ['r', 4]]
All exported members are documented with TSDoc. Docs are also available online. The concept of stream and its main properties are described in Stream interface documentation.
The lib is not the first to provide such a functionality. However, there are things specific to the lib:
Fluent Streams is compared to the native JS Array and two other popular very similar libs. Because each lib is specific, there is no the only winner, and in general all libs show reasonable performance. Results are here, and benchmarks are here.
The following great libs influenced Fluent Streams the most:
The library is provided under the ISC license.
Generated using TypeDoc