Skip to content

Instantly share code, notes, and snippets.

@devthejo
Created November 25, 2017 06:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devthejo/8ad180c07ff3226fb455b12862955694 to your computer and use it in GitHub Desktop.
Save devthejo/8ad180c07ff3226fb455b12862955694 to your computer and use it in GitHub Desktop.
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