mirror of https://gitee.com/antv-l7/antv-l7
29 lines
509 B
JavaScript
29 lines
509 B
JavaScript
var parse = require('./lib/index')
|
|
var through = require('through2').obj
|
|
|
|
module.exports = parseStream
|
|
|
|
function parseStream() {
|
|
var parser = parse()
|
|
var stream = through(write, flush)
|
|
|
|
stream.program = parser.program
|
|
stream.scope = parser.scope
|
|
|
|
return stream
|
|
|
|
function write(data, _, next) {
|
|
var nodes = parser(data)
|
|
|
|
for (var i = 0; i < nodes.length; i++) {
|
|
this.push(nodes[i])
|
|
}
|
|
|
|
next()
|
|
}
|
|
|
|
function flush() {
|
|
this.push(null)
|
|
}
|
|
}
|