"read" in Node.js REPL -
is there function in node.js reads characters stream until reads complete javascript expression , returns expression? "read" part of read-eval-print loop?
i want read json objects stream , process them come in. don't need interactive parts of repl in use case.
{"r": 0.0, "e": -0.2, "t": 0.98} // callback happens here content of object {"r": 0.2, "e": 0.0, "t": 1.0} // callback happens here content of object // etc
a complete javascript expression not valid json serialization, e.g. { foo: 'bar' } valid js expression, invalid json (json requires double-quoted object keys , string literals). if know json objects end on newline boundary, can accumulate lines in variable, trying json.parse() until succeed (an unsuccessful json.parse() throw syntaxerror), not allow detect errors in input (you'll accumulate lines forever). if provide more details , how expect receive, there might other, more suitable approaches.
Comments
Post a Comment