Skip to content

Instantly share code, notes, and snippets.

@nervetattoo
Created June 9, 2015 11:38
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 nervetattoo/3ffa9666235de756d519 to your computer and use it in GitHub Desktop.
Save nervetattoo/3ffa9666235de756d519 to your computer and use it in GitHub Desktop.
Naming things?
function promiseGate(test) {
return function promiseGateResolver(value) {
return test(value).then(function(passedTest) {
if (!passedTest) throw new Error(test.name + ' failed');
return value;
})
}
};
function checkLength(file) {
return file.length < 100;
}
read(filename)
.then(promiseGate(checkLength))
.then(function(file) {
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment