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

nv-facutil-simple-ratelimit

v1.0.7

Published

nv-facutil-simple-ratelimit =============== - simple promise ratelimit

Readme

nv-facutil-simple-ratelimit

  • simple promise ratelimit

install

  • npm install nv-facutil-simple-ratelimit

usage

  const {creat_by_end_at,creat_by_begin_at} = require("nv-facutil-simple-ratelimit")

example

   creat_by_end_at             based on the task end-time     
      by_end_at is more reasonable
   creat_by_begin_at           based on the task begin-time

by_end_at

       const _tmout = require('timers/promises').setTimeout; 

       var rl = creat_by_end_at(5,10000);  // max 5 times every 10-seconds
       
       var f =  async (rl,name)=> {
           console.log(`${name} pending at:`,new Date())
           let sema = await rl.acquire();
           {
               console.log(`<${name} begin executing> at :`,new Date())
               await _tmout(1500)          
               console.log(`</${name} finished> at:`,new Date())                 
           }
           sema.release();
       }

       for(let i=0;i<10;i++) {f(rl,`task${i}`)}
      
       /*
            task0 pending at: 2022-11-01T03:13:36.188Z
            task1 pending at: 2022-11-01T03:13:36.189Z
            task2 pending at: 2022-11-01T03:13:36.189Z
            task3 pending at: 2022-11-01T03:13:36.190Z
            task4 pending at: 2022-11-01T03:13:36.190Z
            task5 pending at: 2022-11-01T03:13:36.190Z
            task6 pending at: 2022-11-01T03:13:36.190Z
            task7 pending at: 2022-11-01T03:13:36.190Z
            task8 pending at: 2022-11-01T03:13:36.191Z
            task9 pending at: 2022-11-01T03:13:36.191Z
            Promise {
              <pending>,
              [Symbol(async_id_symbol)]: 83,
              [Symbol(trigger_async_id_symbol)]: 5,
              [Symbol(destroyed)]: { destroyed: false }
            }
            > <task0 begin executing> at : 2022-11-01T03:13:36.193Z
            <task1 begin executing> at : 2022-11-01T03:13:36.193Z
            <task2 begin executing> at : 2022-11-01T03:13:36.193Z
            <task3 begin executing> at : 2022-11-01T03:13:36.193Z
            <task4 begin executing> at : 2022-11-01T03:13:36.194Z

            > </task0 finished> at: 2022-11-01T03:13:37.694Z
            </task1 finished> at: 2022-11-01T03:13:37.695Z
            </task2 finished> at: 2022-11-01T03:13:37.695Z
            </task3 finished> at: 2022-11-01T03:13:37.695Z
            </task4 finished> at: 2022-11-01T03:13:37.696Z

            > <task5 begin executing> at : 2022-11-01T03:13:47.709Z
            <task6 begin executing> at : 2022-11-01T03:13:47.709Z
            <task7 begin executing> at : 2022-11-01T03:13:47.709Z
            <task8 begin executing> at : 2022-11-01T03:13:47.709Z
            <task9 begin executing> at : 2022-11-01T03:13:47.710Z
            </task5 finished> at: 2022-11-01T03:13:49.216Z
            </task6 finished> at: 2022-11-01T03:13:49.217Z
            </task7 finished> at: 2022-11-01T03:13:49.217Z
            </task8 finished> at: 2022-11-01T03:13:49.218Z
            </task9 finished> at: 2022-11-01T03:13:49.218Z
       */

by_begin_at

                   const _tmout = require('timers/promises').setTimeout;

                   var rl = creat_by_begin_at(5,10000);  // max 5 times every 10-seconds

                   var f =  async (rl,name)=> {
                       console.log(`${name} pending at:`,new Date())
                       let sema = await rl.acquire();
                       {
                           console.log(`<${name} begin executing> at :`,new Date())
                           await _tmout(1500)
                           console.log(`</${name} finished> at:`,new Date())
                       }
                       sema.release();
                   }

                   for(let i=0;i<10;i++) {f(rl,`task${i}`)}

        task0 pending at: 2022-11-01T03:16:20.462Z
        task1 pending at: 2022-11-01T03:16:20.464Z
        task2 pending at: 2022-11-01T03:16:20.465Z
        task3 pending at: 2022-11-01T03:16:20.465Z
        task4 pending at: 2022-11-01T03:16:20.466Z
        task5 pending at: 2022-11-01T03:16:20.466Z
        task6 pending at: 2022-11-01T03:16:20.466Z
        task7 pending at: 2022-11-01T03:16:20.467Z
        task8 pending at: 2022-11-01T03:16:20.467Z
        task9 pending at: 2022-11-01T03:16:20.468Z
        Promise {
          <pending>,
          [Symbol(async_id_symbol)]: 83,
          [Symbol(trigger_async_id_symbol)]: 5,
          [Symbol(destroyed)]: { destroyed: false }
        }
        > <task0 begin executing> at : 2022-11-01T03:16:20.470Z
        <task1 begin executing> at : 2022-11-01T03:16:20.471Z
        <task2 begin executing> at : 2022-11-01T03:16:20.471Z
        <task3 begin executing> at : 2022-11-01T03:16:20.472Z
        <task4 begin executing> at : 2022-11-01T03:16:20.472Z

        > </task0 finished> at: 2022-11-01T03:16:21.974Z
        </task1 finished> at: 2022-11-01T03:16:21.975Z
        </task2 finished> at: 2022-11-01T03:16:21.975Z
        </task3 finished> at: 2022-11-01T03:16:21.976Z
        </task4 finished> at: 2022-11-01T03:16:21.977Z

        > 
        > 
        > <task5 begin executing> at : 2022-11-01T03:16:31.986Z
        <task6 begin executing> at : 2022-11-01T03:16:31.987Z
        <task7 begin executing> at : 2022-11-01T03:16:31.987Z
        <task8 begin executing> at : 2022-11-01T03:16:31.987Z
        <task9 begin executing> at : 2022-11-01T03:16:31.987Z
        </task5 finished> at: 2022-11-01T03:16:33.495Z
        </task6 finished> at: 2022-11-01T03:16:33.495Z
        </task7 finished> at: 2022-11-01T03:16:33.495Z
        </task8 finished> at: 2022-11-01T03:16:33.495Z
        </task9 finished> at: 2022-11-01T03:16:33.496Z

METHODS

rate limit

    rl.acquire               rl.avaliable_            rl.constructor           rl.is_by_begin_mode
    rl.is_by_end_mode        rl.pending_              rl.pq_                   rl.set_mode_to_by_begin
    rl.set_mode_to_by_end    rl.tmhist_               rl.used_

hist

    hidden

tsk

    hidden 

APIS

  • creat_by_end_at(max_count_per_tm_window=1,tm_window_msec=1000)
  • creat_by_begin_at(max_count_per_tm_window=1,tm_window_msec=1000)

LICENSE

  • ISC