私はCoffeeScriptを使った実際の例を持っています:
childproc = require "child_process"
couchdb = childproc.spawn "couchdb"
couchdb.stdout.setEncoding "utf8"
buffer = ""
couchdb.stdout.on "data", (data) ->
lines = (buffer + data).split(/\r?\n/)
buffer = lines.pop()
lines.forEach (line, index) ->
console.log line
couchdb.stdout.on "end", ->
if buffer.length > 0
console.log buffer
buffer = ""
console.log 'process ended'
CS、Iced CS、および JS のより完全な例については、私の要点を参照してください。
EDIT
Javascriptでの出力は次のとおりです。
var buffer, childproc, couchdb;
childproc = require("child_process");
couchdb = childproc.spawn("couchdb");
couchdb.stdout.setEncoding("utf8");
buffer = "";
couchdb.stdout.on("data", function(data) {
var lines;
lines = (buffer + data).split(/\r?\n/);
buffer = lines.pop();
return lines.forEach(function(line, index) {
return console.log(line);
});
});
couchdb.stdout.on("end", function() {
if (buffer.length > 0) {
console.log(buffer);
buffer = "";
}
return console.log('process ended');
});