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

@drew887121/iteratorfuncs

v0.1.0

Published

A small package to make working with iterators easier

Downloads

17

Readme

IteratorFuncs

A tiny package to simplify working with iterators

tldr: Provides a small set of tools for adding map/filter/reduce functionality to iterators without having to yield their values.

const set = new Set([1, 2, 3, 4, 5]);

const mappedAndFiltered = mapIterator(set, (item) => item * 2).filter((item) => item > 5);

console.log(Array.from(mappedAndFiltered)); // logs out [6, 8, 10]

These functions take an IterableIterator or an Iterator, a function of the appropriate type and will return an AugmentedIterator:

The AugmentedIterator class also provides .map, .filter and .reduce helper functions that are chainable.

Greedy Versions

We also provide small utility functions for if you want to just immediately yield all values from the iterator at the same time but don't want to bother doing an Array.from first:

const set = new Set([1, 2, 3, 4, 5]);

const mappedValues = mapIteratorToArray(set, (item: number): number => {
  return item * 2;
});

console.log(mappedValues); // logs out [2, 4, 6, 8, 10]

For these "greedy" utilities there are:

Docs

Docs are auto generated and live at https://drew887.github.io/iteratorFuncs

Why?

It has become very common for me in places that I work in to need to be able to do the classic map/reduce/filter/etc with iterators (but don't want to have to convert them into arrays first since that is bad for perf, or I need to pass the iterator to another package); while also not being allowed to bring in a package to do so, say lodash or equivalent, due to company/security policy of not allowing new outside packages without having to go through a formal review process.

So here is an MPL-2.0 licensed single file package that gives the ability to do just that.

MPL-2.0 was used so that if need be you can copy the src/index.ts or dist/index.js files as need be to use in your projects. Since MPL-2.0 has so-called "file based copyleft" as long as you don't remove the license call out at the top of the file and don't make changes to the file itself then you're fine to copy the file into your project as needed.

Why not MIT?

TLDR, I Wanted to try out MPL-2.0 based things, and while the MIT license would also fit my use case quite well I want to keep some level of copyleft to my work. This way anyone can use the file untouched so to speak but if they make any changes to the file directly, they're required to distribute said changes.