Skip to content

Instantly share code, notes, and snippets.

@gilgamez
Created June 14, 2016 11:40
Show Gist options
  • Save gilgamez/a37d96c078fadeb704bbe7730fa1d886 to your computer and use it in GitHub Desktop.
Save gilgamez/a37d96c078fadeb704bbe7730fa1d886 to your computer and use it in GitHub Desktop.
Promise reject if falsey
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