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

fill-repeating

v1.0.3

Published

This is sort of like `Array.prototype.fill` but supports multiple values. Its the fastest way to fill an Array or TypedArray with multiple values repeatedly.

Readme

fill-repeating

This is sort of like Array.prototype.fill but supports multiple values. Its the fastest way to fill an Array or TypedArray with multiple values repeatedly.

You probably want to use this with a TypedArray instead of a native array. The bigger the array, the bigger the performance win.

Note that this won't set the initial values, you must copy them:

const array = [8, 6, 7, 5, 3, 0, 9];
const repeatLength = array.length;
array.length = 100;
// 0 is the start
// repeatLength is the end
fillRepeating(array, 0, repeatLength);

array becomes:

 [
    8, 6, 7, 5, 3, 0, 9, 8, 6, 7, 5, 3,
    0, 9, 8, 6, 7, 5, 3, 0, 9, 8, 6, 7,
    5, 3, 0, 9, 8, 6, 7, 5, 3, 0, 9, 8,
    6, 7, 5, 3, 0, 9, 8, 6, 7, 5, 3, 0,
    9, 8, 6, 7, 5, 3, 0, 9, 8, 6, 7, 5,
    3, 0, 9, 8, 6, 7, 5, 3, 0, 9, 8, 6,
    7, 5, 3, 0, 9, 8, 6, 7, 5, 3, 0, 9,
    8, 6, 7, 5, 3, 0, 9, 8, 6, 7, 5, 3,
    0, 9, 8, 6
  ]

Install

There are no dependencies (only dev dependencies) and types, esm build, cjs build, and iife build are included.

yarn add fill-repeating

Benchmark

With a typed array of length 1,000 its about 2.4x faster:

fill repeatedly using for loop x 2,249,395 ops/sec ±1.28% (87 runs sampled)
fill-repeating x 5,473,125 ops/sec ±0.80% (85 runs sampled)
Fastest is fill-repeating

With a typed array of length 10,000 its about 12x faster:

fill repeatedly using for loop x 256,877 ops/sec ±0.88% (90 runs sampled)
fill-repeating x 3,250,653 ops/sec ±0.99% (92 runs sampled)
Fastest is fill-repeating

With a typed array of length 100,000 its about 18x faster:

fill repeatedly using for loop x 26,012 ops/sec ±1.33% (86 runs sampled)
fill-repeating x 478,939 ops/sec ±1.70% (86 runs sampled)
Fastest is fill-repeating

Run it yourself: node benchmark.js

It's faster than manually looping through the entire array because it repeatedly copies memory instead of assigning each value.

To ensure performance, make sure you pass the same type of array to this method (otherwise v8 will deopt it). For convience, there are versions of this function built for every array type.

Credit goes to the author of this Stack Overflow answer for the original implementation: https://stackoverflow.com/questions/46313130/more-efficient-way-to-copy-repeating-sequence-into-typedarray