Created
March 11, 2014 00:20
-
-
Save jlmitch5/9477187 to your computer and use it in GitHub Desktop.
a duplexing stream country counter (honestly I have no idea what this does)
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
var duplexer = require('duplexer'); | |
var through = require('through'); | |
module.exports = function (counter) { | |
var counts = {} | |
return duplexer(through(function write (row) { | |
counts[row.country] = (counts[row.country] || 0) + 1 | |
}, function end () { | |
counter.setCounts(counts) | |
}), counter) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment