Budibase is an open-source low-code platform for creating internal apps in minutes. Supports PostgreSQL, MySQL, MSSQL, MongoDB, Rest API, Docker, K8s 🚀
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

31 lines
723 B

var through = require('through2')
var split = require('split2')
var EOL = require('os').EOL
var stringify = require('json-stringify-safe')
module.exports = parse
module.exports.serialize = module.exports.stringify = serialize
module.exports.parse = parse
function parse (opts) {
opts = opts || {}
opts.strict = opts.strict !== false
function parseRow (row) {
try {
if (row) return JSON.parse(row)
} catch (e) {
if (opts.strict) {
this.emit('error', new Error('Could not parse row ' + row.slice(0, 50) + '...'))
}
}
}
return split(parseRow, opts)
}
function serialize (opts) {
return through.obj(opts, function(obj, enc, cb) {
cb(null, stringify(obj) + EOL)
})
}