node 合并多个请求的数据

     function getList1(num) {

           var url= "netease/search?keyword=独孤天下&type=song&pageSize=10&page=0";

             return    ajaxGET(url)

   }

       function getList2(num) {

       return new Promise((resolve, reject) => {

             setTimeout(() => {

                 resolve("haha第2个啊")

             }, 1100);

         } )

   }

function getList0(num) {

       return new Promise((resolve, reject) => {

             setTimeout(() => {

                 resolve("haha第 0个啊")

             }, 10);

         } )

   }

      async function testResult() {

       try {

      let result0 = await getList0(); // 搜索 id

      let result1 = await getList1();//搜索歌词

       let result2 = await getList2(); // 搜索 id

        console.log(result0,result1,result2);

       } catch(err) {

                    console.log(err);

        }

    }

 testResult();

  

  

eventproxy 控制并发

var ep = new eventproxy();
ep.all('data1_event', 'data2_event', 'data3_event', function (data1, data2, data3) {
var html = fuck(data1, data2, data3);
render(html);
});
$.get('http://data1_source', function (data) {
ep.emit('data1_event', data);
});
$.get('http://data2_source', function (data) {
ep.emit('data2_event', data);
});
$.get('http://data3_source', function (data) {
ep.emit('data3_event', data);
});

async控制并发,可以控制并发数

ar async=require('async')

var test=function(item,callback){
setTimeout(function(){
console.log(item+'ok')
callback(null,item+'result')
},2000)
} var items=[1,2,3,4,5,7,8,9,10] async.mapLimit(items,2,function(item,callback){
test(item,callback)
},function(err,result){
console.log(result)
})

  

node 笔记整理的更多相关文章

  1. 学习ReactNative笔记整理一___JavaScript基础

    学习ReactNative笔记整理一___JavaScript基础 ★★★笔记时间- 2017-1-9 ★★★ 前言: 现在跨平台是一个趋势,这样可以减少开发和维护的成本.第一次看是看的ReactNa ...

  2. java笔记整理

    Java 笔记整理 包含内容     Unix Java 基础, 数据库(Oracle jdbc Hibernate pl/sql), web, JSP, Struts, Ajax Spring, E ...

  3. NPM 学习笔记整理

    NPM 学习笔记整理 阅读 550,2017年06月04日 发布,来源:blog.ihoey.com 什么是 NPM npm 之于 Node ,就像 pip 之于 Python , gem 之于 Ru ...

  4. python学习笔记整理——字典

    python学习笔记整理 数据结构--字典 无序的 {键:值} 对集合 用于查询的方法 len(d) Return the number of items in the dictionary d. 返 ...

  5. 从0开始学Swift笔记整理(五)

    这是跟在上一篇博文后续内容: --Core Foundation框架 Core Foundation框架是苹果公司提供一套概念来源于Foundation框架,编程接口面向C语言风格的API.虽然在Sw ...

  6. Deep Learning(深度学习)学习笔记整理系列之(五)

    Deep Learning(深度学习)学习笔记整理系列 zouxy09@qq.com http://blog.csdn.net/zouxy09 作者:Zouxy version 1.0 2013-04 ...

  7. Deep Learning(深度学习)学习笔记整理系列之(八)

    Deep Learning(深度学习)学习笔记整理系列 zouxy09@qq.com http://blog.csdn.net/zouxy09 作者:Zouxy version 1.0 2013-04 ...

  8. Deep Learning(深度学习)学习笔记整理系列之(七)

    Deep Learning(深度学习)学习笔记整理系列 zouxy09@qq.com http://blog.csdn.net/zouxy09 作者:Zouxy version 1.0 2013-04 ...

  9. Deep Learning(深度学习)学习笔记整理系列之(六)

    Deep Learning(深度学习)学习笔记整理系列 zouxy09@qq.com http://blog.csdn.net/zouxy09 作者:Zouxy version 1.0 2013-04 ...

随机推荐

  1. unity里framebuffer fetch相关问题

    https://docs.unity3d.com/Manual/SL-PlatformDifferences.html 开了framebuffer fetch 如果你再在里面sample 那张rt ( ...

  2. lnmp配置

    yum源切换 下载wegt工具 yum install -y wget 备份 mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS- ...

  3. bzoj1458: 士兵占领(最大流)

    题目描述 有一个M * N的棋盘,有的格子是障碍.现在你要选择一些格子来放置一些士兵,一个格子里最多可以放置一个士兵,障碍格里不能放置士兵.我们称这些士兵占领了整个棋盘当满足第i行至少放置了Li个士兵 ...

  4. CodeForces 835D - Palindromic characteristics | Codeforces Round #427 (Div. 2)

    证明在Tutorial的评论版里 /* CodeForces 835D - Palindromic characteristics [ 分析,DP ] | Codeforces Round #427 ...

  5. [Python自学] day-20 (Django-ORM、Ajax)

    一.外键跨表操作(一对多) 在 [Python自学] day-19 (2) (Django-ORM) 中,我们利用外键实现了一对多的表操作. 可以利用以下方式来获取外键指向表的数据: def orm_ ...

  6. /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- redis (LoadError)

    报错信息: /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file ...

  7. loj541

    七曜圣贤 sol:我标算还没写过,似乎分块就可以过(因为数据是随机的),我写个set可以有70~80分 //C++ #include<bits/stdc++.h> using namesp ...

  8. C#中如何去掉字"/0"

    string str = "you/0are/0sweet/0"; str = str.replace("/0","")); 备忘一下

  9. codeforces#1167F. Scalar Queries(树状数组+求贡献)

    题目链接: https://codeforces.com/contest/1167/problem/F 题意: 给出长度为$n$的数组,初始每个元素为$a_i$ 定义:$f(l, r)$为,重排$l$ ...

  10. django-admin 配置

    本节讲django-admin配置方法: 1.在工程配置文件中(settings.py)中启用admin组件.确保有如下两行配置: 2.执行数据库迁移的命令,确保对应的表在数据库中已经添加了 #pyt ...