You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
node-cdx/index.coffee

19 lines
478 B
CoffeeScript

10 years ago
fs = require "fs"
CDXRecordCollection = require "./lib/CDXRecordCollection"
JSONStream = require "JSONStream"
stream = require "stream"
adhocStream = require "adhoc-stream"
methods =
parseFile: (file) ->
collection = new CDXRecordCollection()
fs.createReadStream file
.pipe collection.stream
.pipe adhocStream.transformSync objectMode: true, (obj) ->
@push obj.data
.pipe JSONStream.stringify(false)
.pipe process.stdout
methods.parseFile "./sample.cdx"