ldjson-keys
v0.0.0
Published
Pipe LDJSON in, get all of the keys found out
Downloads
2
Maintainers
Readme
#ldjson-keys
Pipe LDJSON in, get all of the keys found out.
This is useful in conjunction with maxogden/csv-write-stream
that reads CSV columns from first row/object only.
##Run
Install with npm.
$ npm install ldjson-to-csv -g
By default you get new-line delimited output:
$ echo '{"col1":1}\n{"col2":2}' | ldjson-to-csv
# col1
# col2
##Source
_ = require 'highland'
ndjson = require 'ndjson'
{ EOL } = require 'os'
module.exports = ->
keys = {}
through = (obj) ->
_ (push, next) ->
for k of obj when k not of keys
keys[k] = null
push null, k + EOL
push null, _.nil
_.pipeline.apply _, [
do _
do ndjson.parse
_.map through
_.parallel 50
]