(methods, instance)
| 15 | } |
| 16 | |
| 17 | export function wrapMethodsWithErrorHandling (methods, instance) { |
| 18 | // if (process.env.NODE_ENV === 'production') return methods |
| 19 | const newMethods = {} |
| 20 | Object.keys(methods).forEach((key) => { |
| 21 | // worklet 函数重新赋值会变成普通函数,这里只处理非worklet函数 |
| 22 | // 微信小程序&RN worklet都有数值类型的 __workletHash |
| 23 | if (isFunction(methods[key]) && !methods[key].__workletHash) { |
| 24 | newMethods[key] = function (...args) { |
| 25 | return callWithErrorHandling(methods[key].bind(this), instance || this?.__mpxProxy, `component method ${key}`, args) |
| 26 | } |
| 27 | } else { |
| 28 | newMethods[key] = methods[key] |
| 29 | } |
| 30 | }) |
| 31 | return newMethods |
| 32 | } |
no test coverage detected