https://github.com/mikeal/githubarchive
Streaming parsers for the github archive.
https://github.com/mikeal/githubarchive
Last synced: 2 months ago
JSON representation
Streaming parsers for the github archive.
- Host: GitHub
- URL: https://github.com/mikeal/githubarchive
- Owner: mikeal
- Created: 2012-10-24T21:36:44.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2017-07-11T21:51:29.000Z (almost 8 years ago)
- Last Synced: 2024-10-18T09:13:40.502Z (9 months ago)
- Language: JavaScript
- Size: 1.28 MB
- Stars: 12
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### githubarchive -- Streaming parsers for the github archive.
###### Install
$ npm install githubarchive
###### Usage
```javascript
var archive = require('githubarchive')
archive('http://data.githubarchive.org/2012-04-11-15.json.gz').languages(function (err, langs) {
if (err) throw err
console.log(langs) // a hash of the language count in that days activity
})
```Or, alternatively from a file already downloaded.
```javascript
var archive = require('githubarchive')
archive(path.join(__dirname, '2012-04-11-15.json.gz')).languages(function (err, langs) {
if (err) throw err
console.log(langs) // a hash of the language count in that days activity
})
```###### More parsing.
I need more parsers! Pull requests welcome for anything even moderately useful, you can look at the code for the languages parser to see how simple it is, the JSON parsing is already taken care of.
###### In depth usage
All parsers are streams and expect to have a JSONStream piped to them. If you want to handle the acquisition yourself it would look like this.
```javascript
request(url)
.pipe(zlib.createGunzip())
.pipe(jsonstream.parse())
.pipe(githubarchive.languages(function (e, langs) {
// do stuff
}))
```Or, alternatively from a file.
```javascript
fs.createFileStream(path)
.pipe(zlib.createGunzip())
.pipe(jsonstream.parse())
.pipe(githubarchive.languages(function (e, langs) {
// do stuff
}))
```