Skip to content

Instantly share code, notes, and snippets.

@jlongster
Last active April 26, 2016 12:32
Show Gist options
  • Save jlongster/57ad73756529a5dcc4de to your computer and use it in GitHub Desktop.
Save jlongster/57ad73756529a5dcc4de to your computer and use it in GitHub Desktop.
operator (<~) 49
{ $channel } => #{ yield csp.take($channel) }
operator (~>) 50 right
{ $value, $channel } => #{ yield csp.put($channel, $value) }
macro (<~alts) {
rule { } => {
yield csp.alts
}
}
// examples:
var ch = chan();
var x = <~ ch
// var x = yield csp.take(ch)
5 ~> ch
// yield csp.put(ch, 5)
(<~ foo()) ~> ch
// yield csp.put(ch, yield csp.take(foo()))
var r = <~alts([ch1, ch2])
// var r = yield csp.alts([ch1, ch2])
@karlmikko
Copy link

sweetjs?

@jlongster
Copy link
Author

Yep!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment