Redefinition of Promise
Promise is now a global reserved word in es6 and linters throw a error. So what are the pitfalls of doing this
var Promise = require("bluebird");
or should i do
var BluebirdPromise = require("bluebird");
Looks like there isn't a problem to redeclaring promise as long as it's not global. But second one is a better approach
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
只需将这些行放在.jshintrc
{
"undef": true,
"unused": true,
"predef": [ "-Promise" ]
}
链接地址: http://www.djcxy.com/p/91140.html
上一篇: JS堆建议的内存大小
下一篇: 承诺的重新定义