node 笔记整理
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 笔记整理的更多相关文章
- 学习ReactNative笔记整理一___JavaScript基础
学习ReactNative笔记整理一___JavaScript基础 ★★★笔记时间- 2017-1-9 ★★★ 前言: 现在跨平台是一个趋势,这样可以减少开发和维护的成本.第一次看是看的ReactNa ...
- java笔记整理
Java 笔记整理 包含内容 Unix Java 基础, 数据库(Oracle jdbc Hibernate pl/sql), web, JSP, Struts, Ajax Spring, E ...
- NPM 学习笔记整理
NPM 学习笔记整理 阅读 550,2017年06月04日 发布,来源:blog.ihoey.com 什么是 NPM npm 之于 Node ,就像 pip 之于 Python , gem 之于 Ru ...
- python学习笔记整理——字典
python学习笔记整理 数据结构--字典 无序的 {键:值} 对集合 用于查询的方法 len(d) Return the number of items in the dictionary d. 返 ...
- 从0开始学Swift笔记整理(五)
这是跟在上一篇博文后续内容: --Core Foundation框架 Core Foundation框架是苹果公司提供一套概念来源于Foundation框架,编程接口面向C语言风格的API.虽然在Sw ...
- Deep Learning(深度学习)学习笔记整理系列之(五)
Deep Learning(深度学习)学习笔记整理系列 zouxy09@qq.com http://blog.csdn.net/zouxy09 作者:Zouxy version 1.0 2013-04 ...
- Deep Learning(深度学习)学习笔记整理系列之(八)
Deep Learning(深度学习)学习笔记整理系列 zouxy09@qq.com http://blog.csdn.net/zouxy09 作者:Zouxy version 1.0 2013-04 ...
- Deep Learning(深度学习)学习笔记整理系列之(七)
Deep Learning(深度学习)学习笔记整理系列 zouxy09@qq.com http://blog.csdn.net/zouxy09 作者:Zouxy version 1.0 2013-04 ...
- Deep Learning(深度学习)学习笔记整理系列之(六)
Deep Learning(深度学习)学习笔记整理系列 zouxy09@qq.com http://blog.csdn.net/zouxy09 作者:Zouxy version 1.0 2013-04 ...
随机推荐
- string::crbegin string::crend
const_reverse_iterator crbegin() const noexcept;功能:crbegin是最后一个字符,crend第一个字符的前一个.迭代器向左移动是“+”,向右移动是“- ...
- appium自动化 - android
1. 获取driver appium通过生成driver来识别和操作app的UI元素.生成driver时,需要给出被测设备的相关信息.appium官方上的例子如下: https://github.co ...
- windows OpenCV 2.4.9 Python 2.7配置
1 .下载 OpenCV 2.4.9 .下载OpenCV-2.4.9,使用方便 下载地址 2. OpenCV-自解压文件,直接运行.即可解压.解压到想要的opencv文件夹里E:\Programme\ ...
- python3 scrapy爬虫项目的诞生
前提安装好scrapy模块最好 requests和bs4模块都安装好 可以概括为五个步骤 步骤一:新建一个项目 无论你用windows也好,linux也罢,在cmd或者终端 切换到目标文件夹,然后输入 ...
- Git始终忽略特定文件的某一行内容
笔者在编写Z Shell文件的时候经常会使用到set -x来开启调试,但不希望提交到仓库 解决方案 Git提供了一种文件过滤器,此方法可以帮助在提交时移除set -x 我们先来编写脚本,如何移除这一行 ...
- 02 CSS和DIV对界面优化
01 网站首页的优化 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> &l ...
- 解决ubuntu安装软件has install-snap change in progress错误
解决ubuntu安装软件has install-snap change in progress错误 2018年05月06日 13:45:39 山间明月江上清风_ 阅读数:14316 标签: ubunt ...
- Error: 'The service did not respond in a timely fashion'
Windows启动时候报这个错,不应在OnStart放执行长的过程,需要开另一个线程来做才能顺利启动 Windows Services: OnStart loop - do I need to del ...
- learing cbor protocol
https://tools.ietf.org/html/rfc7049 https://github.com/panzidongfamily/tinycbor
- 【csp模拟赛5】加减法--宽搜维护联通快
题目大意: 一开始想用并查集,发现很难维护联通块的代表元素,所以用了宽搜,开数组会炸,所以开一个优先队列维护,每扫完一个联通块,统计答案,清空优先队列,!!千万记住注意数组的大小!!! 代码: #in ...