Created
November 25, 2017 06:41
-
-
Save devthejo/8ad180c07ff3226fb455b12862955694 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function hasPromise(mixed, stack=new Set()){ | |
if(stack.has(mixed)){ | |
return; | |
} | |
stack.add(mixed); | |
if(mixed instanceof Promise){ | |
return true; | |
} | |
if(typeof mixed == 'object' && mixed !== null){ | |
mixed = Object.values(mixed); | |
} | |
if(mixed instanceof Array){ | |
return mixed.some(v=>hasPromise(v, stack)); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment