"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/are-we-there-yet/tracker.js" (11 Apr 2017, 826 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 TrackerBase = require('./tracker-base.js')
    4 
    5 var Tracker = module.exports = function (name, todo) {
    6   TrackerBase.call(this, name)
    7   this.workDone = 0
    8   this.workTodo = todo || 0
    9 }
   10 util.inherits(Tracker, TrackerBase)
   11 
   12 Tracker.prototype.completed = function () {
   13   return this.workTodo === 0 ? 0 : this.workDone / this.workTodo
   14 }
   15 
   16 Tracker.prototype.addWork = function (work) {
   17   this.workTodo += work
   18   this.emit('change', this.name, this.completed(), this)
   19 }
   20 
   21 Tracker.prototype.completeWork = function (work) {
   22   this.workDone += work
   23   if (this.workDone > this.workTodo) this.workDone = this.workTodo
   24   this.emit('change', this.name, this.completed(), this)
   25 }
   26 
   27 Tracker.prototype.finish = function () {
   28   this.workTodo = this.workDone = 1
   29   this.emit('change', this.name, 1, this)
   30 }