Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streaming #1

Merged
merged 8 commits into from
Apr 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# all-the-package-names
# all-the-package-names

A perpetually out-of-date list of all the 166,000+ public package names on npm
A perpetually out-of-date list of all the 263663+ public package names on npm

## Installation

Download node at [nodejs.org](http://nodejs.org) and install it, if you haven't already.

```sh
npm install all-the-package-names --save
```
Expand All @@ -22,12 +20,12 @@ names.indexOf('crazy-new-package-name') > -1
// => false

names.length
// => 143086
// => 206271

names.filter(name => name.includes('banana'))
// => [ 'banana', 'banana-banana', 'banana-split', ...]

// note: example uses iojs with --harmony_arrow_functions enabled
// note: example uses node4+ for arrow functions
```

## License
Expand Down
19 changes: 14 additions & 5 deletions extract.js
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')
})
Loading