lib/stream/s3UsageStream.js
function S3UsageStream (options) {
  options = options || {};
  // Important; make this an object stream.
  options.objectMode = true;

  this.delimiter = options.delimiter || '/';
  this.depth = options.depth || 0;
  this.outputFactor = options.outputFactor || 100;

  // The running totals.
  this.totals = {};
  this.sortedTotals = [];
  this.count = 0;

  S3UsageStream.super_.call(this, options);
}
function S3UsageStream (options) {
  options = options || {};
  // Important; make this an object stream.
  options.objectMode = true;

  this.delimiter = options.delimiter || '/';
  this.depth = options.depth || 0;
  this.outputFactor = options.outputFactor || 100;

  // The running totals.
  this.totals = {};
  this.sortedTotals = [];
  this.count = 0;

  S3UsageStream.super_.call(this, options);
}
--------------------------------------------------------------------------- Class constructor. --------------------------------------------------------------------------- 
@class An object stream for running totals of size and count of S3 objects.

Pipe in S3 object definitions from the S3ListObjectStream, pipe out running
total objects with counts and size grouped by bucket and key prefix:

[
{
path: 'bucket/folder1',
storageClass: {
STANDARD: {
// Number of objects counted so far.
count: 55,
// Total size of all objects counted so far in bytes.
size: 1232983
},
STANDARD_IA: {
count: 0,
size: 0
},
REDUCED_REDUNDANCY: {
count: 2,
size: 5638
},
GLACIER: {
count: 0,
size: 0
}
}
}
,
]

@param {Object} options Standard stream options, plus those noted.
@param {Object} [options.delimiter] How to split keys into folders. Defaults
to '/',
@param {Object} [options.depth] Depth of folders to group count and size.
Defaults to 0, or no folders, just buckets.
@param {Number} [options.outputFactor] At 1, send an update for every object.
At 10, only once every 10 objects. Defaults to 100. Updating is expensive
for very large buckets or depths.