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

asynctsync

v1.0.0

Published

async waterfall

Downloads

2

Readme

async2sync

将异步数据请求按publish的顺序串联,中间有数据传递,形成瀑布流,并且可以设置初始参数

引入

方法1:

因为没有发布的npm,是以npm私包存放的,so以私包方式加载
npm install git+ssh://[email protected]:canwhite/async2sync.git
使用的时候可以自己在git上fork一下,同样格式去调用安装

方法2:

直接下zip包到本地加载

使用

import AsyncWaterfall from 'async2sync'
//定义初始传入的参数
let queue = new AsyncWaterfall(['name']);
console.time('cost6');

//发布,因为是瀑布流,resolve的值可以往下传递
queue.publish_promise('1',function(name){
   return new Promise(function(resolve,reject){
       setTimeout(function(){
           console.log(name, 1);
           resolve('1');
 
       },1000)
   });
});
queue.publish_promise('2',function(data){
    return new Promise(function(resolve,reject){
        setTimeout(function(){
            console.log('this is 2 , get data form 1:', data);
            resolve('2')
        },2000)
    });
});
queue.publish_promise('3',function(data){
    return new Promise(function(resolve,reject){
        setTimeout(function(){
            console.log('this is 3 , get data from 2:',data);
            resolve()
        },3000)
    });
});
//订阅,传入初始参数,按顺序执行异步操作
queue.promise('series promise').then(res=>{
    console.log(res);
    console.timeEnd('cost6');
}).catch((err)=>{
    console.log('error',err);
    console.timeEnd('cost6');
});

/*
输出:
series promise 1 Home.vue:26
this is 2 , get data form 1: 1 Home.vue:35
this is 3 , get data from 2: 2 Home.vue:43
2 Home.vue:50
cost6:6007 毫秒 - 倒计时结束


*/