Skip to content

Instantly share code, notes, and snippets.

@cuipengfei
Created December 16, 2013 14:28
Show Gist options
  • Select an option

  • Save cuipengfei/7987787 to your computer and use it in GitHub Desktop.

Select an option

Save cuipengfei/7987787 to your computer and use it in GitHub Desktop.
promise it wont hurt throw an error
var q = require('q');
function parsePromised() {
var defer = q.defer();
try {
var obj = JSON.parse(process.argv[2])
defer.resolve(obj)
} catch (e) {
defer.reject(e)
}
return defer.promise
}
parsePromised().then(null, console.log)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment