Skip to content

Commit

Permalink
perf: 优化判断和赋值逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
anotherso1a committed Mar 6, 2024
1 parent b07ce3e commit 210b028
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/api-proxy/src/common/js/promisify.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ function promisify (listObj, whiteList, customBlackList) {
}

result[key] = function (...args) {
const obj = args[0] || {}
// 不需要转换 or 用户已定义回调,则不处理
if (!promisifyFilter(key) || ['success', 'fail', 'complete'].some(k => args[0] && args[0][k])) {
if (!promisifyFilter(key) || obj.success || obj.fail) {
return listObj[key].apply(envObj, args)
} else { // 其他情况进行转换
const obj = args[0] || { success: noop, fail: noop }
if (!args[0]) args.unshift(obj)
let returned
const promise = new Promise((resolve, reject) => {
Expand Down

0 comments on commit 210b028

Please sign in to comment.