UNPKG
csp
Version:
latest (0.0.1-alpha1)
0.0.1-alpha1
Communicating sequential processes for node. Go style concurrency with channels.
olahol/node-csp
csp
/
examples
/
interleave.js
19 lines
(15 loc)
•
266 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
var
csp =
require
(
".."
);
var
chan1 =
new
csp.
Chan
(); csp.
spawn
(
function
* () {
var
i =
0
;
for
(;;) {
yield
chan1.
put
(i);
console
.
log
(
"->"
, i); i +=
1
; } }); csp.
spawn
(
function
* () {
for
(;;) {
console
.
log
(
"<-"
,
yield
chan1.
take
()); } });