Sha256: 06f111ba913b0155677cff3d993e5689b82e2c23ee563e8e4ee7a0fe390f4648
Contents?: true
Size: 669 Bytes
Versions: 7
Compression:
Stored size: 669 Bytes
Contents
var through = require('through2') var split = require('split2') var EOL = require('os').EOL 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) } function serialize (opts) { return through.obj(function(obj, enc, cb) { cb(null, JSON.stringify(obj) + EOL) }) }
Version data entries
7 entries across 7 versions & 1 rubygems