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 🙏

© 2024 – Pkg Stats / Ryan Hefner

nv-task-event-transcation

v1.0.1

Published

nv-task-event-transcation ========================== - nv-task-event-transcation - resolve until all tasks success

Downloads

2

Readme

nv-task-event-transcation

  • nv-task-event-transcation
  • resolve until all tasks success

install

  • npm install nv-task-event-transcation

usage

 const {creat_parallel,creat_serial,repeat_until_succ} = require("nv-task-event-transcation")

example

parallel

var [parallel,forest] = creat_parallel()

function tsk(rs,rj,self) {
    console.log(self.name,"start:",new Date())
    setTimeout(
        () => {
            let cond =  (Math.random() >0.5)?true:false;
            if(cond) {
                 console.log(self.name,"succ:",new Date())
                rs(Math.random())
            } else {
                console.log(self.name,"fail:",new Date())
                rj(Math.random())
            }
        },
        Math.random()*10000 + 2000
    )
}
parallel.add("t0",tsk)
parallel.add("t1",tsk)
parallel.add("t2",tsk)

var r = await parallel.start();

t0 start: 2021-11-29T11:55:55.839Z
t1 start: 2021-11-29T11:55:55.841Z
t2 start: 2021-11-29T11:55:55.842Z
t1 fail: 2021-11-29T11:55:57.945Z
Uncaught 0.5145146224195394
> parallel.p_
Promise { <rejected> 0.5145146224195394 }
>

parallel.reset();
var r = await parallel.start();
t0 start: 2021-11-29T11:57:05.228Z
t1 start: 2021-11-29T11:57:05.229Z
t2 start: 2021-11-29T11:57:05.231Z
t2 succ: 2021-11-29T11:57:08.335Z
t1 fail: 2021-11-29T11:57:10.427Z
Uncaught 0.6311975765253766
> t0 fail: 2021-11-29T11:57:12.983Z

> parallel.p_
Promise { <rejected> 0.6311975765253766 }
>

> parallel.reset();
undefined
> var r = await parallel.start();
t0 start: 2021-11-29T11:58:31.406Z
t1 start: 2021-11-29T11:58:31.407Z
t2 start: 2021-11-29T11:58:31.407Z
t0 succ: 2021-11-29T11:58:35.156Z
t1 succ: 2021-11-29T11:58:37.350Z
t2 succ: 2021-11-29T11:58:39.032Z
undefined
> r
[ 0.5653168905010539, 0.08952979280941764, 0.3345300882481612 ]
>
> parallel.p_
Promise {
  [ 0.5653168905010539, 0.08952979280941764, 0.3345300882481612 ]
}
>

serial

        var [serial,forest] = creat_serial()
        
        function tsk(rs,rj,self) {
            console.log(self.name,"start:",new Date())
            setTimeout(
                () => {
                    let cond =  (Math.random() >0.5)?true:false;
                    if(cond) {
                         console.log(self.name,"succ:",new Date())
                        rs(Math.random())
                    } else {
                        console.log(self.name,"fail:",new Date())
                        rj(Math.random())
                    }
                },
                Math.random()*10000 + 2000
            )
        }
        serial.append("t0",tsk)
        serial.append("t1",tsk)
        serial.append("t2",tsk)
    > serial.$sdfs_
    [
      Serial [1 %1fb1e375:1% ] {},
      Base [2 %1fb1e375:2% ] { name: 't0' },
      Base [3 %1fb1e375:3% ] { name: 't1' },
      Base [4 %1fb1e375:4% ] { name: 't2' }
    ]
    >

        
        
        > var r = await serial.start();
        t0 start: 2021-11-29T12:22:45.176Z
        t0 fail: 2021-11-29T12:22:49.110Z
        Uncaught 0.42121530707919574
        > serial.p_
        Promise { <rejected> 0.42121530707919574 }
        >
        > serial.reset()
        undefined
        > serial.p_
        Promise { <pending> }
        >
        > var r = await serial.start();
        t0 start: 2021-11-29T12:27:29.928Z
        t0 succ: 2021-11-29T12:27:34.366Z
        t1 start: 2021-11-29T12:27:34.367Z
        t1 succ: 2021-11-29T12:27:43.180Z
        t2 start: 2021-11-29T12:27:43.181Z
        t2 succ: 2021-11-29T12:27:51.746Z
        undefined
        > r
        0.582265217409822
        >

repeat_until_succ

  var [serial,forest] = creat_serial()
  serial.append("t0",tsk)
  serial.append("t1",tsk)
  serial.append("t2",tsk)

    > var r = await repeat_until_succ(serial);
    t0 start: 2021-11-29T12:49:43.565Z
    t0 succ: 2021-11-29T12:49:54.730Z
    t1 start: 2021-11-29T12:49:54.733Z
    t1 fail: 2021-11-29T12:50:04.885Z
    t0 start: 2021-11-29T12:50:04.888Z
    t0 succ: 2021-11-29T12:50:13.329Z
    t1 start: 2021-11-29T12:50:13.329Z
    t1 succ: 2021-11-29T12:50:17.245Z
    t2 start: 2021-11-29T12:50:17.246Z
    t2 succ: 2021-11-29T12:50:26.110Z
    undefined
    > r
    0.5662500511974513
    > var r = await repeat_until_succ(serial);
    can_only_ready_when_init
    can_only_ready_when_init
    undefined
    undefined
    undefined
    > serial.reset()
    undefined
    > var r = await repeat_until_succ(serial);
    t0 start: 2021-11-29T12:50:58.218Z
    t0 succ: 2021-11-29T12:51:09.006Z
    t1 start: 2021-11-29T12:51:09.007Z
    t1 succ: 2021-11-29T12:51:15.825Z
    t2 start: 2021-11-29T12:51:15.825Z
    t2 succ: 2021-11-29T12:51:25.403Z
    undefined
    > serial.reset()
    undefined
    > var r = await repeat_until_succ(serial);
    t0 start: 2021-11-29T12:51:29.899Z
    t0 fail: 2021-11-29T12:51:32.722Z
    t0 start: 2021-11-29T12:51:32.724Z
    t0 fail: 2021-11-29T12:51:35.228Z
    t0 start: 2021-11-29T12:51:35.230Z
    t0 fail: 2021-11-29T12:51:40.988Z
    t0 start: 2021-11-29T12:51:40.990Z
    t0 fail: 2021-11-29T12:51:44.218Z
    t0 start: 2021-11-29T12:51:44.220Z
    t0 fail: 2021-11-29T12:51:50.296Z
    t0 start: 2021-11-29T12:51:50.298Z
    t0 succ: 2021-11-29T12:52:00.018Z
    t1 start: 2021-11-29T12:52:00.018Z
    t1 fail: 2021-11-29T12:52:07.573Z
    t0 start: 2021-11-29T12:52:07.575Z
    t0 succ: 2021-11-29T12:52:10.666Z
    t1 start: 2021-11-29T12:52:10.667Z
    t1 succ: 2021-11-29T12:52:14.720Z
    t2 start: 2021-11-29T12:52:14.721Z
    t2 succ: 2021-11-29T12:52:18.700Z
    undefined
    >
    > r
    0.5614520757889236
    >
    serial.reset()
    var r = await repeat_until_succ(serial,2);
    t0 start: 2021-11-29T13:18:49.486Z
    t0 succ: 2021-11-29T13:18:59.269Z
    t1 start: 2021-11-29T13:18:59.273Z
    t1 fail: 2021-11-29T13:19:07.131Z
    t0 start: 2021-11-29T13:19:07.135Z
    t0 fail: 2021-11-29T13:19:13.493Z
    Uncaught 0.6774315518935192

    serial.reset()

    > var r = await repeat_until_succ(serial,2);
    t0 start: 2021-11-29T13:24:46.992Z
    t0 fail: 2021-11-29T13:24:54.831Z
    t0 start: 2021-11-29T13:24:54.834Z
    t0 succ: 2021-11-29T13:25:04.002Z
    t1 start: 2021-11-29T13:25:04.003Z
    t1 succ: 2021-11-29T13:25:08.444Z
    t2 start: 2021-11-29T13:25:08.445Z
    t2 succ: 2021-11-29T13:25:14.790Z
    undefined

    serial.reset()

    var r = await repeat_until_succ(serial,10,false);
    > var r = await repeat_until_succ(serial,10,false);
    t0 start: 2021-11-29T14:17:52.944Z
    t0 fail: 2021-11-29T14:18:00.691Z

    t0 start: 2021-11-29T14:18:00.693Z
    t0 fail: 2021-11-29T14:18:05.864Z

    t0 start: 2021-11-29T14:18:05.866Z
    t0 succ: 2021-11-29T14:18:10.440Z
    t1 start: 2021-11-29T14:18:10.441Z
    t1 succ: 2021-11-29T14:18:15.240Z
    t2 start: 2021-11-29T14:18:15.241Z
    t2 fail: 2021-11-29T14:18:26.888Z

    t2 start: 2021-11-29T14:18:26.889Z
    t2 fail: 2021-11-29T14:18:38.000Z

    t2 start: 2021-11-29T14:18:38.002Z
    t2 succ: 2021-11-29T14:18:43.329Z
    undefined
    >
    >
    > r
    0.22477518894573745
    >

APIS

  • creat_parallel(forest,max_size,rtrn_forest=true)
  • creat_serial(forest,max_size,rtrn_forest=true)
  • repeat_unti_succ( task, max_repeat_times=Infinity, reset_all=true, forest,max_size,rtrn_forest=true )

LICENSE

  • ISC