UNPKG

is-awaitable

Version:

A lightweight solution for detecting async functions.

2 lines (1 loc) 346 B
const t=Object.getPrototypeOf((async()=>{})).constructor,n=Object.getPrototypeOf((async function*(){})).constructor;function o(o){if("function"!=typeof o)return!1;if(o instanceof t||o instanceof n)return!0;const c=Function.prototype.toString.call(o).trim();return c.startsWith("async ")||c.startsWith("async function*")}export{o as isAwaitable};