"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/are-we-there-yet/tracker-stream.js" (11 Apr 2017, 943 Bytes) of package /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 'use strict'
    2 var util = require('util')
    3 var stream = require('readable-stream')
    4 var delegate = require('delegates')
    5 var Tracker = require('./tracker.js')
    6 
    7 var TrackerStream = module.exports = function (name, size, options) {
    8   stream.Transform.call(this, options)
    9   this.tracker = new Tracker(name, size)
   10   this.name = name
   11   this.id = this.tracker.id
   12   this.tracker.on('change', delegateChange(this))
   13 }
   14 util.inherits(TrackerStream, stream.Transform)
   15 
   16 function delegateChange (trackerStream) {
   17   return function (name, completion, tracker) {
   18     trackerStream.emit('change', name, completion, trackerStream)
   19   }
   20 }
   21 
   22 TrackerStream.prototype._transform = function (data, encoding, cb) {
   23   this.tracker.completeWork(data.length ? data.length : 1)
   24   this.push(data)
   25   cb()
   26 }
   27 
   28 TrackerStream.prototype._flush = function (cb) {
   29   this.tracker.finish()
   30   cb()
   31 }
   32 
   33 delegate(TrackerStream.prototype, 'tracker')
   34   .method('completed')
   35   .method('addWork')