npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

fluent-streams

v0.9.2

Published

Fluent API for JavaScript iterables processing

Downloads

510

Readme

Fluent Streams

Travis CI NPM version Read the docs

Fluent Streams is a JavaScript and TypeScript library that offers a rich API for lazily processing iterables such as arrays, sets, and more. At its core is the Stream, a lightweight, stateless wrapper around an iterable. The library also includes Optional, which represents a value that may or may not exist.

The library's primary goal is to provide an API that closely mirrors JavaScript's Array, while introducing a variety of additional, powerful methods inspired by libraries like Ramda and Underscore.

Installation

npm i fluent-streams

Usage

The stream() function is the primary entry point for creating a stream from an iterable or generator function. Refer to the documentation for additional ways to create Stream or Optional.

import { abc, stream } from 'fluent-streams'

// Check if it's really a pangram
stream('The quick brown fox jumps over the lazy dog')
    .filter(c => c !== ' ')
    .map(c => c.toLowerCase())
    .distinctBy(c => c)
    .sort()
    .equals(abc())

// => true, indeed a pangram

Note that we created a stream from the string — this is possible because strings implement the iterable protocol, just like Arrays and Sets. More examples.

Why Choose Fluent Streams?

Fluent Streams is not the first library to offer this kind of functionality, but it stands out for several reasons:

  • Prioritizes Standard Array and Iteration Protocols:
    • Stream follows familiar Array naming and method signatures, enabling seamless integration or removal.
    • Stream and Optional implement the Iterable protocol, making them compatible with JavaScript constructs such as for-of loops and spread syntax.
    • The library is optimized for arrays. If the input is an array, it will iterate faster and consume less memory.
  • Compact Size:
  • Includes Optional:
    • Clearly distinguishes between null or undefined as a value, and the absence of a value.
    • Allows conversion of Optional back to Stream to continue the fluent pipeline.
  • Extensive Testing:
    • Over 200 tests rigorously cover 100% of the library's source code, validating various stream types in multiple combinations.
    • Laziness and statelessness are also thoroughly tested.

Platform requirements

Fluent Streams relies on widely available ES6+ features, such as generators, spread operators, for-of loops, and arrow functions. The library doesn't use newly available features, or features with limited availability. The library is shipped untranspiled to ES5.

Why? Modern language features have concise syntax, helping to minimize the bundle size.

While it is possible to transpile the library to ES5 and polyfill it, this is not recommended, as it may increase the library footprint in the bundle by 2.5 to 3 times.

Benchmarks

The library demonstrates generally reasonable performance, though it is slightly slower in some benchmarks compared to similar libraries. This is due to:

  • Use of Generators. While they allow for iteration with very compact syntax, generators are typically slightly slower than simple iterators.
  • Standard Iteration Protocol. Ensures compatibility with for-of loops, spread syntax, and other language features, though custom protocols can be faster at the cost of losing these benefits.

Inspirations and Acknowledgements

Fluent Streams was inspired by several great libraries:

License

This library is provided under the ISC license.