Created
June 14, 2016 11:40
-
-
Save gilgamez/a37d96c078fadeb704bbe7730fa1d886 to your computer and use it in GitHub Desktop.
Promise reject if falsey
This file contains 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
const rejectIfUndefined = (value, E = Error, message = '') => new Promise((resolve, reject) => { | |
if (value) { | |
resolve(value); | |
} else { | |
reject(new E(message)); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment