Created
December 16, 2013 14:28
-
-
Save cuipengfei/7987787 to your computer and use it in GitHub Desktop.
promise it wont hurt throw an error
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
| 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