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 🙏

© 2025 – Pkg Stats / Ryan Hefner

nv-task-simple-loop

v1.0.1

Published

nv-task-simple-loop =================== - simple reusable promise

Readme

nv-task-simple-loop

  • simple reusable promise

install

  • npm install nv-task-simple-loop

usage

 const {creat_loop, creat_loop_ignore_error} = require("nv-task-simple-loop")

 

example

auto

    function tsk(RETURN,THROW,self) {
        setTimeout(
           ()=>{
               console.log(new Date,self.count);
               self.count = self.count +1;
               RETURN();
           },
           3000
        )
    }

    var loop = creat_loop("tmout",tsk);
    loop.count = 0;
    /*
    > loop
    _LoopStopIfError(3) [ 'tmout', [Function: tsk], false, count: 0 ]
    >
    */
    var p = loop.run()
    /*
    > 2022-05-14T11:09:46.697Z 0

    > 2022-05-14T11:09:49.703Z 1

    > 2022-05-14T11:09:52.715Z 2
    2022-05-14T11:09:55.724Z 3
    2022-05-14T11:09:58.729Z 4
    ....
    > loop.is_running()
    true

    > p
    Promise {
      <pending>,
      [Symbol(async_id_symbol)]: 88,
      [Symbol(trigger_async_id_symbol)]: 5,
      [Symbol(destroyed)]: { destroyed: false }
    }

    */

stop

    loop.stop();

    /*

    > loop
    _LoopStopIfError(3) [ 'tmout', [Function: tsk], false, count: 28 ]
    >
    > loop.is_running()
    false
    > p
    Promise {
      undefined,
      [Symbol(async_id_symbol)]: 88,
      [Symbol(trigger_async_id_symbol)]: 5,
      [Symbol(destroyed)]: { destroyed: false }
    }
    >
    */

manual

    loop.manual();
    await loop
    await loop
    await loop
    /*
    > await loop
    2022-05-14T11:55:22.102Z 28
    undefined
    > await loop
    2022-05-14T11:55:25.109Z 29
    undefined
    > await loop
    2022-05-14T11:55:28.117Z 30
    undefined
    >

    */

clone

    > loop.clone()
    _LoopStopIfError(3) [ 'tmout', [Function: tsk], false, count: 28 ]
    >

performance

    var loops = Array.from({length:10000}).map((r,i)=>creat_loop(`tsk${i}`,tsk))
    loops.forEach(loop=>loop.run())

    /*

    PID USER      PR  NI    VIRT    RES    SHR S   %CPU  %MEM     TIME+ COMMAND
    44014 root      20   0  701288 111544  33400 S  28.2  5.5   0:10.47 node


    */

METHODS

 loop.clone()                            
 loop.exec_                executor, cant change it when running  
 loop.is_running            
 loop.manual()             set-to-manual-mode   using await loop   for next                
 loop.name_                 
 loop.run()                   
 loop.stop()

APIS

    Handle: (RETURN:,THROW,self:Loop) => {}                 //RETURN is resolve , THROW is reject,  self is the Loop

    {
      ERRORS: Error(2) { 'already_running', 'not_running' },
      DFLT_EXEC: [AsyncFunction: DFLT_EXEC],
      DFLT_CLONE: [Function: DFLT_CLONE],
      creat_loop: [Function: creat_loop](name:String,executor:Handle),
      creat_loop_ignore_error: [Function: creat_loop_ignore_error](name:String,executor:Handle)
    }

LICENSE

  • ISC