summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/are-we-there-yet
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/are-we-there-yet')
-rw-r--r--deps/npm/node_modules/are-we-there-yet/CHANGES.md31
-rw-r--r--deps/npm/node_modules/are-we-there-yet/LICENSE5
-rw-r--r--deps/npm/node_modules/are-we-there-yet/README.md195
-rw-r--r--deps/npm/node_modules/are-we-there-yet/index.js4
-rw-r--r--deps/npm/node_modules/are-we-there-yet/package.json63
-rw-r--r--deps/npm/node_modules/are-we-there-yet/tracker-base.js11
-rw-r--r--deps/npm/node_modules/are-we-there-yet/tracker-group.js107
-rw-r--r--deps/npm/node_modules/are-we-there-yet/tracker-stream.js35
-rw-r--r--deps/npm/node_modules/are-we-there-yet/tracker.js30
9 files changed, 481 insertions, 0 deletions
diff --git a/deps/npm/node_modules/are-we-there-yet/CHANGES.md b/deps/npm/node_modules/are-we-there-yet/CHANGES.md
new file mode 100644
index 0000000000..46ad078520
--- /dev/null
+++ b/deps/npm/node_modules/are-we-there-yet/CHANGES.md
@@ -0,0 +1,31 @@
+Hi, figured we could actually use a changelog now:
+
+## 1.1.4 2017-04-21
+
+* Fix typo in package.json
+
+## 1.1.3 2017-04-21
+
+* Improve documentation and limit files included in the distribution.
+
+## 1.1.2 2016-03-15
+
+* Add tracker group cycle detection and tests for it
+
+## 1.1.1 2016-01-29
+
+* Fix a typo in stream completion tracker
+
+## 1.1.0 2016-01-29
+
+* Rewrote completion percent computation to be low impact– no more walking a
+ tree of completion groups every time we need this info. Previously, with
+ medium sized tree of completion groups, even a relatively modest number of
+ calls to the top level `completed()` method would result in absurd numbers
+ of calls overall as it walked down the tree. We now, instead, keep track as
+ we bubble up changes, so the computation is limited to when data changes and
+ to the depth of that one branch, instead of _every_ node. (Plus, we were already
+ incurring _this_ cost, since we already bubbled out changes.)
+* Moved different tracker types out to their own files.
+* Made tests test for TOO MANY events too.
+* Standarized the source code formatting
diff --git a/deps/npm/node_modules/are-we-there-yet/LICENSE b/deps/npm/node_modules/are-we-there-yet/LICENSE
new file mode 100644
index 0000000000..af4588069d
--- /dev/null
+++ b/deps/npm/node_modules/are-we-there-yet/LICENSE
@@ -0,0 +1,5 @@
+Copyright (c) 2015, Rebecca Turner
+
+Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/deps/npm/node_modules/are-we-there-yet/README.md b/deps/npm/node_modules/are-we-there-yet/README.md
new file mode 100644
index 0000000000..a927eae6be
--- /dev/null
+++ b/deps/npm/node_modules/are-we-there-yet/README.md
@@ -0,0 +1,195 @@
+are-we-there-yet
+----------------
+
+Track complex hiearchies of asynchronous task completion statuses. This is
+intended to give you a way of recording and reporting the progress of the big
+recursive fan-out and gather type workflows that are so common in async.
+
+What you do with this completion data is up to you, but the most common use case is to
+feed it to one of the many progress bar modules.
+
+Most progress bar modules include a rudamentary version of this, but my
+needs were more complex.
+
+Usage
+=====
+
+```javascript
+var TrackerGroup = require("are-we-there-yet").TrackerGroup
+
+var top = new TrackerGroup("program")
+
+var single = top.newItem("one thing", 100)
+single.completeWork(20)
+
+console.log(top.completed()) // 0.2
+
+fs.stat("file", function(er, stat) {
+ if (er) throw er
+ var stream = top.newStream("file", stat.size)
+ console.log(top.completed()) // now 0.1 as single is 50% of the job and is 20% complete
+ // and 50% * 20% == 10%
+ fs.createReadStream("file").pipe(stream).on("data", function (chunk) {
+ // do stuff with chunk
+ })
+ top.on("change", function (name) {
+ // called each time a chunk is read from "file"
+ // top.completed() will start at 0.1 and fill up to 0.6 as the file is read
+ })
+})
+```
+
+Shared Methods
+==============
+
+* var completed = tracker.completed()
+
+Implemented in: `Tracker`, `TrackerGroup`, `TrackerStream`
+
+Returns the ratio of completed work to work to be done. Range of 0 to 1.
+
+* tracker.finish()
+
+Implemented in: `Tracker`, `TrackerGroup`
+
+Marks the tracker as completed. With a TrackerGroup this marks all of its
+components as completed.
+
+Marks all of the components of this tracker as finished, which in turn means
+that `tracker.completed()` for this will now be 1.
+
+This will result in one or more `change` events being emitted.
+
+Events
+======
+
+All tracker objects emit `change` events with the following arguments:
+
+```
+function (name, completed, tracker)
+```
+
+`name` is the name of the tracker that originally emitted the event,
+or if it didn't have one, the first containing tracker group that had one.
+
+`completed` is the percent complete (as returned by `tracker.completed()` method).
+
+`tracker` is the tracker object that you are listening for events on.
+
+TrackerGroup
+============
+
+* var tracker = new TrackerGroup(**name**)
+
+ * **name** *(optional)* - The name of this tracker group, used in change
+ notifications if the component updating didn't have a name. Defaults to undefined.
+
+Creates a new empty tracker aggregation group. These are trackers whose
+completion status is determined by the completion status of other trackers.
+
+* tracker.addUnit(**otherTracker**, **weight**)
+
+ * **otherTracker** - Any of the other are-we-there-yet tracker objects
+ * **weight** *(optional)* - The weight to give the tracker, defaults to 1.
+
+Adds the **otherTracker** to this aggregation group. The weight determines
+how long you expect this tracker to take to complete in proportion to other
+units. So for instance, if you add one tracker with a weight of 1 and
+another with a weight of 2, you're saying the second will take twice as long
+to complete as the first. As such, the first will account for 33% of the
+completion of this tracker and the second will account for the other 67%.
+
+Returns **otherTracker**.
+
+* var subGroup = tracker.newGroup(**name**, **weight**)
+
+The above is exactly equivalent to:
+
+```javascript
+ var subGroup = tracker.addUnit(new TrackerGroup(name), weight)
+```
+
+* var subItem = tracker.newItem(**name**, **todo**, **weight**)
+
+The above is exactly equivalent to:
+
+```javascript
+ var subItem = tracker.addUnit(new Tracker(name, todo), weight)
+```
+
+* var subStream = tracker.newStream(**name**, **todo**, **weight**)
+
+The above is exactly equivalent to:
+
+```javascript
+ var subStream = tracker.addUnit(new TrackerStream(name, todo), weight)
+```
+
+* console.log( tracker.debug() )
+
+Returns a tree showing the completion of this tracker group and all of its
+children, including recursively entering all of the children.
+
+Tracker
+=======
+
+* var tracker = new Tracker(**name**, **todo**)
+
+ * **name** *(optional)* The name of this counter to report in change
+ events. Defaults to undefined.
+ * **todo** *(optional)* The amount of work todo (a number). Defaults to 0.
+
+Ordinarily these are constructed as a part of a tracker group (via
+`newItem`).
+
+* var completed = tracker.completed()
+
+Returns the ratio of completed work to work to be done. Range of 0 to 1. If
+total work to be done is 0 then it will return 0.
+
+* tracker.addWork(**todo**)
+
+ * **todo** A number to add to the amount of work to be done.
+
+Increases the amount of work to be done, thus decreasing the completion
+percentage. Triggers a `change` event.
+
+* tracker.completeWork(**completed**)
+
+ * **completed** A number to add to the work complete
+
+Increase the amount of work complete, thus increasing the completion percentage.
+Will never increase the work completed past the amount of work todo. That is,
+percentages > 100% are not allowed. Triggers a `change` event.
+
+* tracker.finish()
+
+Marks this tracker as finished, tracker.completed() will now be 1. Triggers
+a `change` event.
+
+TrackerStream
+=============
+
+* var tracker = new TrackerStream(**name**, **size**, **options**)
+
+ * **name** *(optional)* The name of this counter to report in change
+ events. Defaults to undefined.
+ * **size** *(optional)* The number of bytes being sent through this stream.
+ * **options** *(optional)* A hash of stream options
+
+The tracker stream object is a pass through stream that updates an internal
+tracker object each time a block passes through. It's intended to track
+downloads, file extraction and other related activities. You use it by piping
+your data source into it and then using it as your data source.
+
+If your data has a length attribute then that's used as the amount of work
+completed when the chunk is passed through. If it does not (eg, object
+streams) then each chunk counts as completing 1 unit of work, so your size
+should be the total number of objects being streamed.
+
+* tracker.addWork(**todo**)
+
+ * **todo** Increase the expected overall size by **todo** bytes.
+
+Increases the amount of work to be done, thus decreasing the completion
+percentage. Triggers a `change` event.
diff --git a/deps/npm/node_modules/are-we-there-yet/index.js b/deps/npm/node_modules/are-we-there-yet/index.js
new file mode 100644
index 0000000000..57d8743fda
--- /dev/null
+++ b/deps/npm/node_modules/are-we-there-yet/index.js
@@ -0,0 +1,4 @@
+'use strict'
+exports.TrackerGroup = require('./tracker-group.js')
+exports.Tracker = require('./tracker.js')
+exports.TrackerStream = require('./tracker-stream.js')
diff --git a/deps/npm/node_modules/are-we-there-yet/package.json b/deps/npm/node_modules/are-we-there-yet/package.json
new file mode 100644
index 0000000000..29c0faceab
--- /dev/null
+++ b/deps/npm/node_modules/are-we-there-yet/package.json
@@ -0,0 +1,63 @@
+{
+ "_from": "are-we-there-yet@~1.1.2",
+ "_id": "are-we-there-yet@1.1.4",
+ "_inBundle": false,
+ "_integrity": "sha1-u13KOCu5TwXhUZQ3PRb9O6HKEQ0=",
+ "_location": "/are-we-there-yet",
+ "_phantomChildren": {},
+ "_requested": {
+ "type": "range",
+ "registry": true,
+ "raw": "are-we-there-yet@~1.1.2",
+ "name": "are-we-there-yet",
+ "escapedName": "are-we-there-yet",
+ "rawSpec": "~1.1.2",
+ "saveSpec": null,
+ "fetchSpec": "~1.1.2"
+ },
+ "_requiredBy": [
+ "/npmlog"
+ ],
+ "_resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.4.tgz",
+ "_shasum": "bb5dca382bb94f05e15194373d16fd3ba1ca110d",
+ "_spec": "are-we-there-yet@~1.1.2",
+ "_where": "/Users/rebecca/code/npm/node_modules/npmlog",
+ "author": {
+ "name": "Rebecca Turner",
+ "url": "http://re-becca.org"
+ },
+ "bugs": {
+ "url": "https://github.com/iarna/are-we-there-yet/issues"
+ },
+ "bundleDependencies": false,
+ "dependencies": {
+ "delegates": "^1.0.0",
+ "readable-stream": "^2.0.6"
+ },
+ "deprecated": false,
+ "description": "Keep track of the overall completion of many disparate processes",
+ "devDependencies": {
+ "standard": "^6.0.8",
+ "tap": "^5.7.0"
+ },
+ "files": [
+ "index.js",
+ "tracker-base.js",
+ "tracker-group.js",
+ "tracker-stream.js",
+ "tracker.js",
+ "CHANGES.md"
+ ],
+ "homepage": "https://github.com/iarna/are-we-there-yet",
+ "license": "ISC",
+ "main": "index.js",
+ "name": "are-we-there-yet",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/iarna/are-we-there-yet.git"
+ },
+ "scripts": {
+ "test": "standard && tap test/*.js"
+ },
+ "version": "1.1.4"
+}
diff --git a/deps/npm/node_modules/are-we-there-yet/tracker-base.js b/deps/npm/node_modules/are-we-there-yet/tracker-base.js
new file mode 100644
index 0000000000..6f43687557
--- /dev/null
+++ b/deps/npm/node_modules/are-we-there-yet/tracker-base.js
@@ -0,0 +1,11 @@
+'use strict'
+var EventEmitter = require('events').EventEmitter
+var util = require('util')
+
+var trackerId = 0
+var TrackerBase = module.exports = function (name) {
+ EventEmitter.call(this)
+ this.id = ++trackerId
+ this.name = name
+}
+util.inherits(TrackerBase, EventEmitter)
diff --git a/deps/npm/node_modules/are-we-there-yet/tracker-group.js b/deps/npm/node_modules/are-we-there-yet/tracker-group.js
new file mode 100644
index 0000000000..9759e1226d
--- /dev/null
+++ b/deps/npm/node_modules/are-we-there-yet/tracker-group.js
@@ -0,0 +1,107 @@
+'use strict'
+var util = require('util')
+var TrackerBase = require('./tracker-base.js')
+var Tracker = require('./tracker.js')
+var TrackerStream = require('./tracker-stream.js')
+
+var TrackerGroup = module.exports = function (name) {
+ TrackerBase.call(this, name)
+ this.parentGroup = null
+ this.trackers = []
+ this.completion = {}
+ this.weight = {}
+ this.totalWeight = 0
+ this.finished = false
+ this.bubbleChange = bubbleChange(this)
+}
+util.inherits(TrackerGroup, TrackerBase)
+
+function bubbleChange (trackerGroup) {
+ return function (name, completed, tracker) {
+ trackerGroup.completion[tracker.id] = completed
+ if (trackerGroup.finished) return
+ trackerGroup.emit('change', name || trackerGroup.name, trackerGroup.completed(), trackerGroup)
+ }
+}
+
+TrackerGroup.prototype.nameInTree = function () {
+ var names = []
+ var from = this
+ while (from) {
+ names.unshift(from.name)
+ from = from.parentGroup
+ }
+ return names.join('/')
+}
+
+TrackerGroup.prototype.addUnit = function (unit, weight) {
+ if (unit.addUnit) {
+ var toTest = this
+ while (toTest) {
+ if (unit === toTest) {
+ throw new Error(
+ 'Attempted to add tracker group ' +
+ unit.name + ' to tree that already includes it ' +
+ this.nameInTree(this))
+ }
+ toTest = toTest.parentGroup
+ }
+ unit.parentGroup = this
+ }
+ this.weight[unit.id] = weight || 1
+ this.totalWeight += this.weight[unit.id]
+ this.trackers.push(unit)
+ this.completion[unit.id] = unit.completed()
+ unit.on('change', this.bubbleChange)
+ if (!this.finished) this.emit('change', unit.name, this.completion[unit.id], unit)
+ return unit
+}
+
+TrackerGroup.prototype.completed = function () {
+ if (this.trackers.length === 0) return 0
+ var valPerWeight = 1 / this.totalWeight
+ var completed = 0
+ for (var ii = 0; ii < this.trackers.length; ii++) {
+ var trackerId = this.trackers[ii].id
+ completed += valPerWeight * this.weight[trackerId] * this.completion[trackerId]
+ }
+ return completed
+}
+
+TrackerGroup.prototype.newGroup = function (name, weight) {
+ return this.addUnit(new TrackerGroup(name), weight)
+}
+
+TrackerGroup.prototype.newItem = function (name, todo, weight) {
+ return this.addUnit(new Tracker(name, todo), weight)
+}
+
+TrackerGroup.prototype.newStream = function (name, todo, weight) {
+ return this.addUnit(new TrackerStream(name, todo), weight)
+}
+
+TrackerGroup.prototype.finish = function () {
+ this.finished = true
+ if (!this.trackers.length) this.addUnit(new Tracker(), 1, true)
+ for (var ii = 0; ii < this.trackers.length; ii++) {
+ var tracker = this.trackers[ii]
+ tracker.finish()
+ tracker.removeListener('change', this.bubbleChange)
+ }
+ this.emit('change', this.name, 1, this)
+}
+
+var buffer = ' '
+TrackerGroup.prototype.debug = function (depth) {
+ depth = depth || 0
+ var indent = depth ? buffer.substr(0, depth) : ''
+ var output = indent + (this.name || 'top') + ': ' + this.completed() + '\n'
+ this.trackers.forEach(function (tracker) {
+ if (tracker instanceof TrackerGroup) {
+ output += tracker.debug(depth + 1)
+ } else {
+ output += indent + ' ' + tracker.name + ': ' + tracker.completed() + '\n'
+ }
+ })
+ return output
+}
diff --git a/deps/npm/node_modules/are-we-there-yet/tracker-stream.js b/deps/npm/node_modules/are-we-there-yet/tracker-stream.js
new file mode 100644
index 0000000000..fb9598ed4e
--- /dev/null
+++ b/deps/npm/node_modules/are-we-there-yet/tracker-stream.js
@@ -0,0 +1,35 @@
+'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')
diff --git a/deps/npm/node_modules/are-we-there-yet/tracker.js b/deps/npm/node_modules/are-we-there-yet/tracker.js
new file mode 100644
index 0000000000..68c2339b45
--- /dev/null
+++ b/deps/npm/node_modules/are-we-there-yet/tracker.js
@@ -0,0 +1,30 @@
+'use strict'
+var util = require('util')
+var TrackerBase = require('./tracker-base.js')
+
+var Tracker = module.exports = function (name, todo) {
+ TrackerBase.call(this, name)
+ this.workDone = 0
+ this.workTodo = todo || 0
+}
+util.inherits(Tracker, TrackerBase)
+
+Tracker.prototype.completed = function () {
+ return this.workTodo === 0 ? 0 : this.workDone / this.workTodo
+}
+
+Tracker.prototype.addWork = function (work) {
+ this.workTodo += work
+ this.emit('change', this.name, this.completed(), this)
+}
+
+Tracker.prototype.completeWork = function (work) {
+ this.workDone += work
+ if (this.workDone > this.workTodo) this.workDone = this.workTodo
+ this.emit('change', this.name, this.completed(), this)
+}
+
+Tracker.prototype.finish = function () {
+ this.workTodo = this.workDone = 1
+ this.emit('change', this.name, 1, this)
+}