UNPKG

526 Btext/coffeescriptView Raw
1Points = require("lin").Points
2Stream = require("stream").Stream
3
4# This probably belongs to Points, if necessary at all...
5# It could also be more efficient. Therefore...
6# TODO:
7# Expect / pass a JSONStream to the Points constructor.
8# Don't stringify, because phase will parse it again.
9
10module.exports = (stream) ->
11 restream = new Stream
12 stream.on "data", (precious) ->
13 data = JSON.parse precious
14 points = new Points [], data: data
15 restream.emit "data", JSON.stringify(points.toJSON()) + "\n"
16 restream