Sha256: e550b2d2ee5720b7b140a73b625d1cef6550152b1edbd7264488c3bd54611b6f

Contents?: true

Size: 963 Bytes

Versions: 74

Compression:

Stored size: 963 Bytes

Contents

'use strict'
var util = require('util')
var stream = require('readable-stream')
var delegate = require('delegates')
var Tracker = require('./tracker.js')

var TrackerStream = module.exports = function (name, size, options) {
  stream.Transform.call(this, options)
  this.tracker = new Tracker(name, size)
  this.name = name
  this.id = this.tracker.id
  this.tracker.on('change', delegateChange(this))
}
util.inherits(TrackerStream, stream.Transform)

function delegateChange (trackerStream) {
  return function (name, completion, tracker) {
    trackerStream.emit('change', name, completion, trackerStream)
  }
}

TrackerStream.prototype._transform = function (data, encoding, cb) {
  this.tracker.completeWork(data.length ? data.length : 1)
  this.push(data)
  cb()
}

TrackerStream.prototype._flush = function (cb) {
  this.tracker.finish()
  cb()
}

delegate(TrackerStream.prototype, 'tracker')
  .method('completed')
  .method('addWork')
  .method('finish')

Version data entries

74 entries across 61 versions & 12 rubygems

Version Path
immosquare-cleaner-0.1.51 node_modules/are-we-there-yet/lib/tracker-stream.js
immosquare-cleaner-0.1.50 node_modules/are-we-there-yet/lib/tracker-stream.js
immosquare-cleaner-0.1.49 node_modules/are-we-there-yet/lib/tracker-stream.js
immosquare-cleaner-0.1.48 node_modules/are-we-there-yet/lib/tracker-stream.js
immosquare-cleaner-0.1.47 node_modules/are-we-there-yet/lib/tracker-stream.js
immosquare-cleaner-0.1.46 node_modules/are-we-there-yet/lib/tracker-stream.js
immosquare-cleaner-0.1.45 node_modules/are-we-there-yet/lib/tracker-stream.js
immosquare-cleaner-0.1.44 node_modules/are-we-there-yet/lib/tracker-stream.js
immosquare-cleaner-0.1.43 node_modules/are-we-there-yet/lib/tracker-stream.js
immosquare-cleaner-0.1.42 node_modules/are-we-there-yet/lib/tracker-stream.js
immosquare-cleaner-0.1.41 node_modules/are-we-there-yet/lib/tracker-stream.js
immosquare-cleaner-0.1.40 node_modules/are-we-there-yet/lib/tracker-stream.js
immosquare-cleaner-0.1.39 node_modules/are-we-there-yet/lib/tracker-stream.js
immosquare-cleaner-0.1.38 node_modules/are-we-there-yet/lib/tracker-stream.js
optimacms-0.1.61 spec/dummy/node_modules/are-we-there-yet/tracker-stream.js
immosquare-cleaner-0.1.32 node_modules/are-we-there-yet/lib/tracker-stream.js
immosquare-cleaner-0.1.31 node_modules/are-we-there-yet/lib/tracker-stream.js
immosquare-cleaner-0.1.30 node_modules/are-we-there-yet/lib/tracker-stream.js
immosquare-cleaner-0.1.29 node_modules/are-we-there-yet/lib/tracker-stream.js
immosquare-cleaner-0.1.28 node_modules/are-we-there-yet/lib/tracker-stream.js