var http = require('http');var Promise = require('bluebird'); // 第三方 Promises 模块var cheerio = require('cheerio'); // 爬虫分析模块var BufferHelper = require( ...
分类:
Web程序 时间:
2016-07-04 21:51:19
阅读次数:
264
Promise.join Promise.join( Promise|any values..., function handler ) – -> Promise For coordinating multiple concurrent discrete promises. While .all i... ...
.error .error([function(any error) rejectedHandler]) -> Promise 和catch一样,但是catch捕获了所有错误类型的异常,而error捕获是操作异常 注:“errors”意为错误,作为对象能 够instanceof Error,不是字符... ...
new Promise new Promise(function(function resolve, function reject) resolver) -> Promise 创建一个新的Promise,传入一个函数,这个函数有两个函数resolve、reject作为参数。这两个参数函数能在这个函... ...
nodejs-使用request和bluebird编写的http请求模块 http://blog.csdn.net/o6875461/article/details/44594545 ...
分类:
其他好文 时间:
2016-06-06 16:40:38
阅读次数:
147
最近项目迭代,从express到koa,面对callback,想偷懒,就想到了Proxy对象 有这么一个基本的思路,由于局限较多,而且具体执行如何还是不知,考虑到可能的性能原因,还是用了 bluebird模块。 ...
分类:
其他好文 时间:
2016-04-21 18:24:56
阅读次数:
130
CoffeeScript 1.9 开始提供了类似ES6的yield关键字。 自己结合co和bluebird做了个试验。 co -- http://npmjs.org/package/co -- for generator bluebird -- https://www.npmjs.com/packa ...
分类:
其他好文 时间:
2016-04-13 07:19:03
阅读次数:
158
英文原文https://github.com/petkaantonov/bluebird/wiki/Optimization-killers这篇文档包含了如何避免使代码性能远低于预期的建议. 尤其是一些会导致 V8 (牵涉到 Node.js, Opera, Chromium 等) 无法优化相关函数的...
分类:
编程语言 时间:
2015-09-18 20:30:23
阅读次数:
410
Promise是异步代码实现控制流的一种方式。这一方式可以让你的代码干净、可读并且健壮。
比如,你用来异步处理文件事件的回调代码:
fs.readFile('directory/file-to-read', function(err, file){
if (error){
//handle error
} else {
//do some...
分类:
Web程序 时间:
2015-07-30 00:49:46
阅读次数:
141
Promise是异步代码实现控制流的一种方式。这一方式可以让你的代码干净、可读并且健壮。比如,你用来异步处理文件事件的回调代码:fs.readFile('directory/file-to-read', function(err, file){ if (error){ //han...
分类:
Web程序 时间:
2015-07-30 00:31:01
阅读次数:
175