Skip to content

Instantly share code, notes, and snippets.

@adamloving
Created December 13, 2014 03:56
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 adamloving/e70fc132bc98ddbcade8 to your computer and use it in GitHub Desktop.
Save adamloving/e70fc132bc98ddbcade8 to your computer and use it in GitHub Desktop.
my first streamline experiment
#!/usr/bin/env _coffee
console.log 'hello ...'
setTimeout _, 100
console.log '... world'
doSomething = (isError, cb) ->
process.nextTick ->
if isError
cb(new Error('error'), isError)
else
cb(null, isError)
doSomething true, (err, output) ->
console.log('callback expect error:', err, output)
doSomething false, (err, output) ->
console.log('callback expect null:', err, output)
try
result1 = doSomething true, _
catch e
console.log 'result1', result1 # undefined (never returned)
console.log 'CAUGHT ERROR', e.stack
result2 = doSomething false, _
console.log 'result2', result2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment