@postman/csv-parse
Version:
CSV parsing implementing the Node.js `stream.Transform` API
21 lines (19 loc) • 515 B
JavaScript
const parse = require('../lib')
const assert = require('assert')
// Create the parser
const parser = parse({
delimiter: ':'
}, function(err, records){
assert.deepEqual(
records,
[
[ 'root','x','0','0','root','/root','/bin/bash' ],
[ 'someone','x','1022','1022','','/home/someone','/bin/bash' ]
]
)
})
// Write data to the stream
parser.write("root:x:0:0:root:/root:/bin/bash\n")
parser.write("someone:x:1022:1022::/home/someone:/bin/bash\n")
// Close the readable stream
parser.end()