|
|
@ -1,5 +1,16 @@
|
|
|
|
'use strict'
|
|
|
|
'use strict'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function apply(cb, input) {
|
|
|
|
|
|
|
|
let json
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
json = JSON.parse(input)
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
process.stderr.write(e.toString() + '\n')
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
cb(json)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function stream(from, cb) {
|
|
|
|
function stream(from, cb) {
|
|
|
|
let buff = ''
|
|
|
|
let buff = ''
|
|
|
|
let lastChar = ''
|
|
|
|
let lastChar = ''
|
|
|
@ -15,13 +26,11 @@ function stream(from, cb) {
|
|
|
|
|
|
|
|
|
|
|
|
if (count > 0) {
|
|
|
|
if (count > 0) {
|
|
|
|
if (head !== '') {
|
|
|
|
if (head !== '') {
|
|
|
|
const json = JSON.parse(head)
|
|
|
|
apply(cb, head)
|
|
|
|
cb(json)
|
|
|
|
|
|
|
|
head = ''
|
|
|
|
head = ''
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const json = JSON.parse(input)
|
|
|
|
apply(cb, input)
|
|
|
|
cb(json)
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
head = input
|
|
|
|
head = input
|
|
|
|
}
|
|
|
|
}
|
|
|
|