Created
June 9, 2015 11:38
-
-
Save nervetattoo/3ffa9666235de756d519 to your computer and use it in GitHub Desktop.
Naming things?
This file contains hidden or 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
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