Promise){ var Promise = require("bluebird"); // Configure Promise.config({ longStackTraces
今天,有朋友反映说,我的微信小程序的例子在andriod真机环境下运行出错,研究调试了半天,发现原来是使用的bluebird.js(Promise实现库)导致的。...由于小程序框架最近的更新中移除了原生Promise的支持,喜欢使用Promise特性的开发者都会去引入其他的第三方Promise库来替代,bluebird.js是一个性能不错,特性又丰富的Promise...不过,由于bluebird.js中有些代码还是用到了document对象上的方法,在iOS的真机JavascriptCore环境中,貌似这些代码并不会被触及到,而在Android真机环境中,就会被执行到这块代码...: npm install es6-promise 然后在下载下来的文件夹下,把dist目录中的es6-promise.js或es6-promise.min.js复制到你的微信小程序项目中,替换原来的bluebird.js...而且es6-promise的代码文件体积比bluebird小个3,4倍,也算一个好处吧(只能这么自我安慰了...哈哈) 希望这篇文章能解决同样遇到这个问题的朋友。
_settlePromise (D:\Blog\node_modules\bluebird\js\release\promise.js:604:18) at Promise...._settlePromise0 (D:\Blog\node_modules\bluebird\js\release\promise.js:649:10) at Promise....:\Blog\node_modules\bluebird\js\release\async.js:93:12) at _drainQueue (D:\Blog\node_modules\bluebird..._settlePromise (D:\Blog\node_modules\bluebird\js\release\promise.js:604:18) at Promise....:\Blog\node_modules\bluebird\js\release\async.js:93:12) at _drainQueue (D:\Blog\node_modules\bluebird
_settlePromise0 (/Users/DA1SY1/Blog/Gitee/node_modules/bluebird/js/release/promise.js:649:10) at..._settlePromises (/Users/DA1SY1/Blog/Gitee/node_modules/bluebird/js/release/promise.js:729:18) at..._fulfill (/Users/DA1SY1/Blog/Gitee/node_modules/bluebird/js/release/promise.js:673:18) at Promise..._resolveCallback (/Users/DA1SY1/Blog/Gitee/node_modules/bluebird/js/release/promise.js:466:57) at..._settlePromise0 (/Users/DA1SY1/Blog/Gitee/node_modules/bluebird/js/release/promise.js:649:10) at
(C:\Users\L\Desktop\MyBlog-matery\node_modules\bluebird\js\release\method.js:15:34) at C:\Users\L..._promiseFulfilled (C:\Users\L\Desktop\MyBlog-matery\node_modules\bluebird\js\release\map.js:68:38)..._iterate (C:\Users\L\Desktop\MyBlog-matery\node_modules\bluebird\js\release\promise_array.js:115:31)...(C:\Users\L\Desktop\MyBlog-matery\node_modules\bluebird\js\release\async.js:97:12) at _drainQueue...(C:\Users\L\Desktop\MyBlog-matery\node_modules\bluebird\js\release\async.js:86:9) at Async.
_settlePromise (G:\blog\node_modules\bluebird\js\release\promise.js:574:18) at Promise...._settlePromise0 (G:\blog\node_modules\bluebird\js\release\promise.js:619:10) at Promise...._settlePromises (G:\blog\node_modules\bluebird\js\release\promise.js:699:18) at Promise...._fulfill (G:\blog\node_modules\bluebird\js\release\promise.js:643:18) at PromiseArray...._settlePromise (G:\blog\node_modules\bluebird\js\release\promise.js:571:21) at Promise.
(H:\hexo\hexo\node_modules\_bluebird@3.5.1@bluebird\js\release\method.js:15:34) at H:..._promiseFulfilled (H:\hexo\hexo\node_modules\_bluebird@3.5.1@bluebird\js\release\map.js:61:38) at..._iterate (H:\hexo\hexo\node_modules\_bluebird@3.5.1@bluebird\js\release\promise_array.js:114:31)..._asyncInit (H:\hexo\hexo\node_modules\_bluebird@3.5.1@bluebird\js\release\map.js:30:10) at Async...._drainQueue (H:\hexo\hexo\node_modules\_bluebird@3.5.1@bluebird\js\release\async.js:138:12) at Async
_settlePromiseFromHandler (C:\Users\huyuc\AppData\Roaming\nvm\v8.9.4\node_modules\npm\node_modules\bluebird..._settlePromise0 (C:\Users\huyuc\AppData\Roaming\nvm\v8.9.4\node_modules\npm\node_modules\bluebird\js\..._settlePromises (C:\Users\huyuc\AppData\Roaming\nvm\v8.9.4\node_modules\npm\node_modules\bluebird\js\..._drainQueue (C:\Users\huyuc\AppData\Roaming\nvm\v8.9.4\node_modules\npm\node_modules\bluebird\js\release..._drainQueues (C:\Users\huyuc\AppData\Roaming\nvm\v8.9.4\node_modules\npm\node_modules\bluebird\js\release
_settlePromiseFromHandler (/path/to/myblog/node_modules/bluebird/js/release/promise.js:547:31)..._settlePromise (/path/to/myblog/node_modules/bluebird/js/release/promise.js:604:18) at Promise...._settlePromise0 (/path/to/myblog/node_modules/bluebird/js/release/promise.js:649:10) at Promise.../node_modules/bluebird/js/release/async.js:86:9) at Async..../node_modules/bluebird/js/release/async.js:86:9) at Async.
(/root/cloudbase-workspace/node_modules/bluebird/js/release/method.js:15:34) [2021-12-23..._settlePromiseFromHandler (/root/cloudbase-workspace/node_modules/bluebird/js/release/promise.js:547:..._settlePromise0 (/root/cloudbase-workspace/node_modules/bluebird/js/release/promise.js:649:10) [2021-..._settlePromises (/root/cloudbase-workspace/node_modules/bluebird/js/release/promise.js:729:18) [2021-..._drainQueues (/root/cloudbase-workspace/node_modules/bluebird/js/release/async.js:102:5) [2021-12-23
"bluebird": "^3.5.1", 但是我们发现还是没有正确的使用,还是使用的是 @types 的方式。...为了让使用 JS 的库能够在 TypeScript 上使用,那么我们在导入的时候需要添加 @types 但是我们的这个问题是,我们并没有添加需要的 @types/bluebird, 但是这个是从哪里来的呢...在这个文件中,我们会看到 "_requiredBy": [ "/@types/request-promise" ], 这个就是让 @types/bluebird 导入的元凶了,因为这个类型是... @types 的,所以我们按照 @types 导入了 bluebird。
-- 兼容低版本浏览器 (包括 IE),可移除 --> bluebird@3/js/browser/bluebird.min.js
v8 Node.js v8.4.0 (Carbon) / V8 6.0.286.52 Async Type Time, ms Memory, MB Callbacks 376 73.55 Bluebird...Promises 600 106.58 Async Functions + Bluebird promisify 636 114.67 Async Functions + util.promisify...both native Chrome V8 ES2015 promises and ES2017 async functions perform roughly 2 times slower than Bluebird
-- 兼容低版本浏览器 (包括 IE),可移除 --> bluebird@3/js/browser/bluebird.min.js...-- 兼容低版本浏览器 (包括 IE),可移除 --> bluebird@3/js/browser/bluebird.min.js
【更新说明】 由于微信开发者工具和微信真机环境的不断升级,小程序中要使用Promise的话,已经不需要像文中描述的再引入第三方库如bluebird或es6-promise了,可直接使用。...ES6中原生支持了Promise,不过在原生不支持Promise的环境中,我们有很多第三方库来支持,比如Q.js和Bluebird。.../libs/bluebird.min') //我用了bluebird.js /** * 将小程序的API封装成支持Promise的API * @params fn {Function} 小程序原始
node、redis服务 在第一步代码的基础上,我们使用node连接一个redis,模拟一个访客计数的功能,修改后的node代码如下: const Koa = require('koa'); const bluebird...= require("bluebird"); const redis = require("redis"); bluebird.promisifyAll(redis.RedisClient.prototype...); bluebird.promisifyAll(redis.Multi.prototype); const app = new Koa(); // 注意这里的host被指定为 redis,这是docker
4].name}`); } showJianShuRequest(); 07 在循环中正确使用 await const fetch = require('node-fetch'), bluebird...= require('bluebird'); async function JianShuRequest(id) { await bluebird.delay(1000); const...console.timeEnd('time'); } showJianShuRequest(); const fetch = require('node-fetch'), bluebird...= require('bluebird'); async function JianShuRequest(id) { await bluebird.delay(1000); const
return变量,无需使用Promise.resolve进行转换 下面,我们可以通过一个非常简单的示例来体验一下Async/Await的酸爽: 示例1 const Promise = require("bluebird...重构代码之后,我仍然用到了Promise库bluebird。”Talk is cheap, Show me the code!”,大家不妨看看两个示例。...Promise.promisify 使用Promise.promisify将不支持Promise的方法Promise化,调用异步接口的时候有两种方式: const Promise = require("bluebird...示例3:Promise.map 使用Promise.map读取多个文件的数据,调用异步接口的时候有两种方式: const Promise = require("bluebird") var readFile...示例4 const Promise = require("bluebird") var readFile = Promise.promisify(require("fs").readFile) //
const profiler = require ( 'v8-profiler-node8' ); const fs = require ( 'fs' ); const Bluebird = require...( 'bluebird' ); class PackageController extends Controller { async cpuProf () { console.log...( '开始收集' ); // Start Profiling profiler . startProfiling ( 'CPU profile' ); await Bluebird.delay
领取专属 10元无门槛券
手把手带您无忧上云