gpt4 book ai didi

javascript - 重新定义 promise

转载 作者:数据小太阳 更新时间:2023-10-29 04:45:43 26 4
gpt4 key购买 nike

Promise 现在是 es6 中的全局保留字,并且 linters 会抛出错误。那么这样做有什么坑

var Promise = require("bluebird");

或者我应该做什么

var BluebirdPromise = require("bluebird");

最佳答案

只要不是全局的,重新声明 promise 似乎没有问题。但是第二种是更好的方法

Many of us do that. There's no problem. You're just using a faster implementation, that's all. But note that you may use more and more promises given by various libraries, so this is a very limited replacement (there are discussions in the node world about ways to define a library as a global promise provider). – Denys Séguret

关于javascript - 重新定义 promise ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36428739/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com