Skip to content

Instantly share code, notes, and snippets.

@mathieuancelin
Last active October 2, 2015 13:00
Show Gist options
  • Save mathieuancelin/617330b48108bfbfb690 to your computer and use it in GitHub Desktop.
Save mathieuancelin/617330b48108bfbfb690 to your computer and use it in GitHub Desktop.
const Types = Object.freeze({
Unit: Symbol('Unit')
});
function uselessPromise() {
return new Promise(resolve => {
console.log('Doing stuff !!!');
setTimeout(() => resolve(Types.Unit), 200)
}).then(res => {
if (res === Types.Unit &&
res !== 'unit' &&
res !== Symbol('unit')) {
return 'Success !!!';
} else {
return 'Failure :(';
}
});
}
uselessPromise()
.then(res => console.log('Result is : ', res));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment