Skip to content

Instantly share code, notes, and snippets.

@matthewhively
matthewhively / is_promise_like.js
Created July 12, 2022 00:29
Test if can function as a promise. Copied from paypal sdk/js for subscriptions
function is_promise_like(n) {
try {
if (!n)
{cl('falsy'); return !1; }
if ("undefined" != typeof Promise && n instanceof Promise)
{cl('is Promise (ok)'); return !0; }
if ("undefined" != typeof window && "function" == typeof window.Window && n instanceof window.Window)
{cl('is Window'); return !1; }
if ("undefined" != typeof window && "function" == typeof window.constructor && n instanceof window.constructor)
{cl('is constructor'); return !1; }