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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@bemoje/iter

v2.0.0

Published

Utility functions for working with iterables, especially map-like key-value pair structures.

Readme

@bemoje/iter

Utility functions for working with iterables, especially map-like key-value pair structures.

TypeScript Module

Exports

  • filterArray: Filter an array based on a predicate function.
  • filterIterable: Filter an iterable based on a predicate function.
  • filterIterableEntries: Filter an iterable of key-value entries based on a predicate function.
  • filterIterableKeys: Filter an iterable of key-value entries based on a predicate function that tests keys.
  • filterIterableValues: Filter an iterable of key-value entries based on a predicate function that tests values.
  • filterMap: Filter a Map based on a predicate function.
  • filterObject: Filter an object's properties based on a predicate function.
  • filterSet: Filter a Set based on a predicate function.
  • forEachArray: Execute a callback function for each element in an array.
  • forEachIterable: Execute a callback function for each element in an iterable.
  • forEachIterableEntries: Execute a callback function for each entry in a map-like iterable.
  • forEachIterableKeys: Execute a callback function for each key in an iterable of key-value pairs.
  • forEachIterableValues: Execute a callback function for each value in an iterable of key-value pairs.
  • forEachMap: Execute a callback function for each entry in a Map.
  • forEachObject: Execute a callback function for each property in an object.
  • forEachSet: Execute a callback function for each value in a Set.
  • mapArray: Transform each element in an array using a mapper function.
  • mapIterable: Transform each element in an iterable using a mapper function.
  • mapIterableEntries: Transform each entry in an iterable of key-value pairs using a mapper function.
  • mapIterableKeys: Transform the keys in an iterable of key-value pairs using a mapper function.
  • mapIterableValues: Transform the values in an iterable of key-value pairs using a mapper function.
  • mapMap: Transform the values in a Map using a mapper function.
  • mapObject: Transform the values in an object using a mapper function.
  • mapSet: Transform each value in a Set using a mapper function.
  • reduceArray: Reduce an array to a single value using a reducer function.
  • reduceIterable: Reduce an iterable to a single value using a reducer function.
  • reduceIterableEntries: Reduce an iterable of key-value entries to a single value using a reducer function.
  • reduceIterableKeys: Reduce an iterable of key-value entries based on keys using a reducer function.
  • reduceIterableValues: Reduce an iterable of key-value entries based on values using a reducer function.
  • reduceMap: Reduce a Map to a single value using a reducer function.
  • reduceObject: Reduce an object to a single value using a reducer function.
  • reduceSet: Reduce a Set to a single value using a reducer function.
  • toObjectIterable: Convert a map-like iterable to a regular object.

Installation

npm install @bemoje/iter

Usage

Transform Iterables

import { mapIterable, mapIterableKeys, mapIterableValues } from '@bemoje/iter'

const entries: Iterable<[string, number]> = new Map([
  ['a', 1],
  ['b', 2],
])

// Transform both keys and values
const mapped = mapIterable(entries, (value, key) => [key.toUpperCase(), value * 10])
// [['A', 10], ['B', 20]]

// Transform only keys
const newKeys = mapIterableKeys(entries, (key) => key.toUpperCase())
// [['A', 1], ['B', 2]]

// Transform only values
const doubled = mapIterableValues(entries, (value) => value * 2)
// [['a', 2], ['b', 4]]

Filter and Reduce

import { filterIterable, reduceIterable, forEachIterable } from '@bemoje/iter'

const entries: Iterable<[string, number]> = new Map([
  ['a', 1],
  ['b', 2],
  ['c', 3],
])

// Filter entries by value
const filtered = filterIterable(entries, (value) => value > 1)
// [['b', 2], ['c', 3]]

// Reduce to a single value
const sum = reduceIterable(entries, (acc, value) => acc + value, 0)
// 6

// Side effects
forEachIterable(entries, (value, key) => console.log(`${key}: ${value}`))

Count Unique Values

import { countUniques } from '@bemoje/iter'

const words = ['apple', 'banana', 'apple', 'cherry', 'banana', 'apple']
const counts = countUniques(words)
// ExtMap { 'apple' => 3, 'banana' => 2, 'cherry' => 1 } (sorted by count desc)

Convert to Object

import { toObjectIterable } from '@bemoje/iter'

const entries: Iterable<[string, number]> = [
  ['a', 1],
  ['b', 2],
]
const obj = toObjectIterable(entries)
// { a: 1, b: 2 }