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

@joepie91/range

v1.0.0

Published

Generates a range of numbers (optionally with step size) as an iterator with array methods

Readme

@joepie91/range

Generates an iterator containing all numbers in a specified range, optionally with a defined step size. The iterator also has (proxied) array methods, so that you can use methods like .map or .filter as if it were an array, without needing an explicit Array.from call. Negative step sizes are supported.

Warning: Using the array methods really uses the array methods. This means that the entire iterator is turned into an array, meaning all values are loaded into memory at once. If you want an iterator because you're working with very large ranges (millions of numbers), then don't use the array methods. This is an edge case, and the vast majority of people can use the array methods safely. If you're not sure whether this applies to you, it probably doesn't!

Usage

As an iterator:

const range = require("@joepie91/range");

/* Prints (each on a new line) the numbers 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 */
for (let i of range(0, 10)) {
	console.log(i);
}

/* Prints (each on a new line) the numbers 0, 2, 4, 6, 8 */
for (let i of range(0, 10, 2)) {
	console.log(i);
}

/* Prints (each on a new line) the numbers 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 */
for (let i of range(10, 0, -1)) {
	console.log(i);
}

As an array:

const range = require("@joepie91/range");

/* Prints (each on a new line) the numbers 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 */
range(0, 10).forEach((i) => {
	console.log(i);
});

/* Prints (each on a new line) the numbers 0, 2, 4, 6, 8 */
range(0, 10, 2).forEach((i) => {
	console.log(i);
});

/* Prints (each on a new line) the numbers 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 */
range(0, 10, -1).forEach((i) => {
	console.log(i);
});

/* Or for example, using `.map`: */
let numbers = range(0, 10).map((i) => i * 10);
console.log(numbers); // [ 0, 10, 20, 30, 40, 50, 60, 70, 80, 90 ]

API

range(start, end, step = 1)

Generates and returns the iterator-with-array-methods.

  • start: Required. The value to start at. This value is inclusive.
  • end: Required. The value to end at. This value is exclusive,, ie. it isn't included in the sequence. Take a careful look at the negative-step examples above to see the implications for counting down, as it may be unintuitive!
  • step: Optional, defaults to 1. The step size to increment with. Specify a negative step size to count down instead of up.