Skip to content

Instantly share code, notes, and snippets.

@ufocoder
Created October 31, 2018 12:06
Show Gist options
  • Select an option

  • Save ufocoder/904a3504d55caf0e3fb8dc5a970fd11f to your computer and use it in GitHub Desktop.

Select an option

Save ufocoder/904a3504d55caf0e3fb8dc5a970fd11f to your computer and use it in GitHub Desktop.
function runAsPromised (task, ...params) {
return new Promise((resolve, reject) =>
task(...params, higherOrderNodeCallback(resolve, reject))
);
}
runAsPromised(readFile, filePath)
.then(convertToContent)
.then(JSON.stringify)
.then(closeWithContent(res, 200, jsonHeaders))
.catch(closeWithStatus(res, 404));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment