-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from zeke/streaming
Streaming
- Loading branch information
Showing
5 changed files
with
99,163 additions
and
2,023 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,20 @@ | ||
#!/usr/bin/env node | ||
|
||
const fs = require('fs') | ||
const packages = require('./skimdb.json').rows | ||
const JSONStream = require('JSONStream') | ||
const es = require('event-stream') | ||
const compact = require('lodash').compact | ||
|
||
var names = packages.map(function (pkg) { | ||
return pkg.value.name; | ||
}) | ||
var names = [] | ||
|
||
fs.writeFileSync('./names.json', JSON.stringify(compact(names), null, 2)) | ||
fs.createReadStream('./skimdb.json') | ||
.pipe(JSONStream.parse('rows.*')) | ||
.pipe(es.mapSync(function (pkg) { | ||
names.push(pkg.value.name) | ||
process.stdout.write('.') | ||
return pkg | ||
})) | ||
.on('end', function(){ | ||
fs.writeFileSync('./names.json', JSON.stringify(compact(names), null, 2)) | ||
console.log('wrote names.json') | ||
}) |
Oops, something went wrong.