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

enumerable-component

v0.3.1

Published

Enumerable mixin.

Readme

Enumerable

Enumerable mixin.

TODO... finish me

users
  .map('friends')
  .select(function(u){ return u.age > 20 })
  .map('name.first')
  .grep(/^T/)

Installation

$ component install component/enumerable

API

mixin()

Mixin to obj.

 var Enumerable = require('enumerable');
 Enumerable(Something.Enumerabletype);

Enumerable#each(fn:Function)

Iterate each value and invoke fn(val, i).

 users.each(function(val, i){
   
 })

Enumerable#map(fn:Function)

Map each return value from fn(val, i).

Passing a callback function:

 users.map(function(user){
   return user.name.first
 })

Passing a property string:

 users.map('name.first')

Enumerable#select(fn:Function)

Select all values that return a truthy value of fn(val, i).

 users.select(function(user){
   return user.age > 20
 })

Enumerable#reject(fn:Function)

Reject all values that return a truthy value of fn(val, i).

Rejecting using a callback:

 users.reject(function(user){
   return user.age < 20
 })

Rejecting values via ==:

 data.reject(null)
 users.reject(tobi)

Enumerable#compact()

Reject null and undefined.

 [1, null, 5, undefined].compact()
 // => [1,5]

Enumerable#find(fn:Function)

Return the first value when fn(val, i) is truthy, otherwise return undefined.

 users.find(function(user){
   return user.role == 'admin'
 })

Enumerable#findLast(fn:Function)

Return the last value when fn(val, i) is truthy, otherwise return undefined.

 users.findLast(function(user){
   return user.role == 'admin'
 })

Enumerable#any(fn:Function)

Assert that at least one invocation of fn(val, i) is truthy.

For example checking to see if any pets are ferrets

 pets.any(function(pet){
   return pet.species == 'ferret'
 })

Enumerable#count(fn:Function)

Count the number of times fn(val, i) returns true.

 var n = pets.count(function(pet){
   return pet.species == 'ferret'
 })

Enumerable#indexOf(obj:Mixed)

Determine the indexof obj or return -1.

Enumerable#grep(re:RegExp)

Grep values using the given re.

 users.map('name').grep(/^tobi/i)

Enumerable#reduce(fn:Function, [val]:Mixed)

Reduce with fn(accumulator, val, i) using optional init value defaulting to the first enumerable value.

Enumerable#max(fn:Function|String)

Determine the max value.

With a callback function:

 pets.max(function(pet){
   return pet.age
 })

With property strings:

 pets.max('age')

With immediate values::

 nums.max()

Enumerable#sum(fn:Function|String)

Determine the sum.

With a callback function:

 pets.sum(function(pet){
   return pet.age
 })

With property strings:

 pets.sum('age')

With immediate values:

 nums.sum()

Enumerable#first([n]:Number|Function)

Return the first value, or first n values.

Enumerable#last([n]:Number|Function)

Return the last value, or last n values.

Enumerable#inGroupsOf(n:Number)

Return values in groups of n.

Enumerable#at(i:Number)

Return the value at the given index.

Enumerable#value()

Return the enumerable value.

License

MIT