ln-stream
for each line processor
attach proc
for a line
and defer
the post-processor
lnstream =
wc-like program
lnstream = require 'ln-stream' lines = 0words = 0chars = 0 # processer for each line = lines += 1 words += linesplit ' ' length chars += linelength # after the all lines = consolelog "%d %d %d"lineswordschars lnstream './README.md'procdefer # => 36 120 504
simple multi-process (pseudo)
To realize true multi-process, you can use the functions in child_process
.
seq 1000 1003 > list
= setTimeout -> consolelog ididlnstream './list'proc-> 0
[bash] $ time coffee test.coffee
1000
1001
1002
1003
real 0m1.197s
user 0m0.113s
sys 0m0.036s