- private checkFunctionInput (fn: (data: Data) => Response): void {
- if (!fn) throw new Error('fn parameter is mandatory')
+ private checkFunctionInput (
+ fn: (data: Data) => Response | Promise<Response>
+ ): void {
+ if (fn == null) throw new Error('fn parameter is mandatory')
+ if (typeof fn !== 'function') {
+ throw new TypeError('fn parameter is not a function')
+ }
+ if (fn.constructor.name === 'AsyncFunction' && this.opts.async === false) {
+ throw new Error(
+ 'fn parameter is an async function, please set the async option to true'
+ )
+ }