Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const validateFnDescriptor = (effectName, fnDescriptor) => {
check(fnDescriptor, is.notUndef, `${effectName}: argument fn is undefined or null`)
if (is.func(fnDescriptor)) {
return
}
let context = null
let fn
if (is.array(fnDescriptor)) {
;[context, fn] = fnDescriptor
check(fn, is.notUndef, `${effectName}: argument of type [context, fn] has undefined or null \`fn\``)
} else if (is.object(fnDescriptor)) {
;({ context, fn } = fnDescriptor)
check(fn, is.notUndef, `${effectName}: argument of type {context, fn} has undefined or null \`fn\``)
} else {
check(fnDescriptor, is.func, `${effectName}: argument fn is not function`)
return
}
if (context && is.string(fn)) {
check(context[fn], is.func, `${effectName}: context arguments has no such method - "${fn}"`)
return
}
check(fn, is.func, `${effectName}: unpacked fn argument (from [context, fn] or {context, fn}) is not a function`)
}