Here's the official solution in case you want to compare notes:

 var http = require('http')
var bl = require('bl')
var results = []
var count = 0 function printResults () {
for (var i = 0; i < 3; i++)
console.log(results[i])
} function httpGet (index) {
http.get(process.argv[2 + index], function (response) {
response.pipe(bl(function (err, data) {
if (err)
return console.error(err) results[index] = data.toString()
count++ if (count == 3)
printResults()
}))
})
} for (var i = 0; i < 3; i++)
httpGet(i)

[freeCodeCamp] solution to JUGGLING ASYNC的更多相关文章

  1. [freeCodeCamp] solution to HTTP JSON API SERVER passed!

    var http = require('http') var url = require('url') function parsetime (time) { return { hour: time. ...

  2. 编程概念--使用async和await的异步编程

    Asynchronous Programming with Async and Await You can avoid performance bottlenecks and enhance the ...

  3. 图与例解读Async/Await

    JavaScript ES7的async/await语法让异步promise操作起来更方便.如果你需要从多个数据库或者接口按顺序异步获取数据,你可能最终写出一坨纠缠不清的promise与回调.然而使用 ...

  4. Ubuntu 12.04 LTS 及ubuntu14.10 -- NFS安装

    在Linux 服务器上配置好NFS 根文件系统后,在单板侧挂载NFS 文件系统,具体操作如下:ifconfig eth0 hw ether 00:10:85:18:01:84 /*配置MAC地址*/i ...

  5. nodeschool.io 9

    ~~ JUGGLING ASYNC ~~ 其实就是一个循环,在循环里面输出的顺序,和排列后在外面的顺序不一样,这是为什么呢? 用第三方async包,直接报错了…… This problem is th ...

  6. HttpContext.Current and Web Api

    Using HttpContext.Current in WebApi is dangerous because of async HttpContext.Current gets the curre ...

  7. A complex 16-Level XSS Challenge

    A complex 16-Level XSS Challenge, held in summer 2014 (+1 Hidden Level) Index Level 0 Level 1 Level ...

  8. Async IO

    I was recently reading a series on “Write Sequential Non-Blocking IO Code With Fibers in NodeJS” by  ...

  9. Async All the Way

    Asynchronous code reminds me of the story of a fellow who mentioned that the world was suspended in ...

随机推荐

  1. Java集合类性能分析

    [转]对于Android开发者来说深入了解Java的集合类很有必要主要是从Collection和Map接口衍生出来的,目前主要提供了List.Set和Map这三大类的集合,今天Android吧(ard ...

  2. django-后台sms管理系统的css框架

    地址:https://adminlte.io/ 下载代码.使用index.html的页面及相关文件 通过下在线检查adminlte.io的后台的各种模块元素,仿写.

  3. vmware esxi6.5安装使用教程(图文安装)

    准备工作: 下载ESXI5.5镜像和client客户端. 将ISO写入到U盘或是刻录光盘然后启动安装. 一.开始安装 欢迎界面 协议界面 安装在本地 键盘的键入方式 设置登录密码 开始安装 重启 安装 ...

  4. Spring MVC 确定目标方法POJO 类型参数

    1:确定一个Key 2. 在implicitMode 中存在Key 对应的对象, 若存在则作为参数传入 3. 在implicitMode 中不存在Key 对应的对象, 则检查当前@SessionAtr ...

  5. as3 三行三列 布满9个为一个界面

    var n:int=int(iconIndex/3); e.x =(int(n/3)*3+iconIndex%3)*557; e.y = int(iconIndex / 3) % 3 * 260; i ...

  6. 5 Python3 函数进阶&迭代器与生成器

    1.函数进阶 1.1.名称空间 又名name space, 顾名思义就是存放名字的地方,存什么名字呢?举例说明,若变量x=1,1存放于内存中,那名字x存放在哪里呢?名称空间正是存放名字x与1绑定关系的 ...

  7. pandas datafram重命名列名称

    方法一: 直接给column赋值 df.columns=["a", "b"], 所有的column全部重命名 example: import pandas as ...

  8. java web 跨域

    服务器端解决跨域问题的三种方法   跨域是指html文件所在的服务器与ajax请求的服务器是不同的ip+port,例如: - ‘192.168.1.1:8080’ 与 ‘192.168.1.2:808 ...

  9. 多字段非连续模糊查询java实现

    工作需要,写了一个实现数据库多字段模糊查询的方法,背景是输入用户的信息,如用户的userid,姓名,拼音等,可以查出相关的用户 具体如下 1. 操作一张表,可以设置表前缀 2. 可以实现中文的不连续查 ...

  10. Hadoop 执行 hdfs 命令烦人的警告信息

    问题描述: 安装完 hadoop,执行 hdfs dfs -ls 命令时,报警告如下: -- ::, WARN util.NativeCodeLoader: Unable to load native ...