Skip to content

Instantly share code, notes, and snippets.

@jlmitch5
Created March 11, 2014 00:20
Show Gist options
  • Save jlmitch5/9477187 to your computer and use it in GitHub Desktop.
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)
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