Commit b6f092c5 authored by Χάρης Παπαδόπουλος's avatar Χάρης Παπαδόπουλος
Browse files

smart table installed. Two examples working

parent 26def32d

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.
{
"_args": [
[
{
"raw": "are-we-there-yet@~1.1.2",
"scope": null,
"escapedName": "are-we-there-yet",
"name": "are-we-there-yet",
"rawSpec": "~1.1.2",
"spec": ">=1.1.2 <1.2.0",
"type": "range"
},
"/home/haris/devel/eepal/node_modules/node-gyp/node_modules/npmlog"
]
],
"_from": "are-we-there-yet@>=1.1.2 <1.2.0",
"_id": "are-we-there-yet@1.1.2",
"_inCache": true,
"_location": "/are-we-there-yet",
"_nodeVersion": "4.2.2",
"_npmOperationalInternal": {
"host": "packages-13-west.internal.npmjs.com",
"tmp": "tmp/are-we-there-yet-1.1.2.tgz_1458084397358_0.15847722673788667"
},
"_npmUser": {
"name": "iarna",
"email": "me@re-becca.org"
},
"_npmVersion": "3.8.1",
"_phantomChildren": {
"buffer-shims": "1.0.0",
"core-util-is": "1.0.2",
"inherits": "2.0.3",
"process-nextick-args": "1.0.7",
"string_decoder": "0.10.31",
"util-deprecate": "1.0.2"
},
"_requested": {
"raw": "are-we-there-yet@~1.1.2",
"scope": null,
"escapedName": "are-we-there-yet",
"name": "are-we-there-yet",
"rawSpec": "~1.1.2",
"spec": ">=1.1.2 <1.2.0",
"type": "range"
},
"_requiredBy": [
"/node-gyp/npmlog",
"/npmlog"
],
"_resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.2.tgz",
"_shasum": "80e470e95a084794fe1899262c5667c6e88de1b3",
"_shrinkwrap": null,
"_spec": "are-we-there-yet@~1.1.2",
"_where": "/home/haris/devel/eepal/node_modules/node-gyp/node_modules/npmlog",
"author": {
"name": "Rebecca Turner",
"url": "http://re-becca.org"
},
"bugs": {
"url": "https://github.com/iarna/are-we-there-yet/issues"
},
"dependencies": {
"delegates": "^1.0.0",
"readable-stream": "^2.0.0 || ^1.1.13"
},
"description": "Keep track of the overall completion of many dispirate processes",
"devDependencies": {
"standard": "^6.0.8",
"tap": "^5.7.0"
},
"directories": {},
"dist": {
"shasum": "80e470e95a084794fe1899262c5667c6e88de1b3",
"tarball": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.2.tgz"
},
"gitHead": "dd5706e2204cb681e78031d0ffe156ed4cc75823",
"homepage": "https://github.com/iarna/are-we-there-yet",
"license": "ISC",
"main": "index.js",
"maintainers": [
{
"name": "iarna",
"email": "me@re-becca.org"
}
],
"name": "are-we-there-yet",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/iarna/are-we-there-yet.git"
},
"scripts": {
"test": "standard && tap test/*.js"
},
"version": "1.1.2"
}
'use strict'
var util = require('util')
module.exports = function (obj, event, next) {
var timeout = setTimeout(gotTimeout, 10)
obj.once(event, gotResult)
function gotTimeout () {
obj.removeListener(event, gotResult)
next(new Error('Timeout listening for ' + event))
}
var result = []
function gotResult () {
result = Array.prototype.slice.call(arguments)
clearTimeout(timeout)
timeout = setTimeout(gotNoMoreResults, 10)
obj.once(event, gotTooManyResults)
}
function gotNoMoreResults () {
obj.removeListener(event, gotTooManyResults)
var args = [null].concat(result)
next.apply(null, args)
}
function gotTooManyResults () {
var secondResult = Array.prototype.slice.call(arguments)
clearTimeout(timeout)
next(new Error('Got too many results, first ' + util.inspect(result) + ' and then ' + util.inspect(secondResult)))
}
}
'use strict'
var test = require('tap').test
var Tracker = require('../index.js').Tracker
var testEvent = require('./lib/test-event.js')
var name = 'test'
test('initialization', function (t) {
var simple = new Tracker(name)
t.is(simple.completed(), 0, 'Nothing todo is 0 completion')
t.done()
})
var track
var todo = 100
test('completion', function (t) {
track = new Tracker(name, todo)
t.is(track.completed(), 0, 'Nothing done is 0 completion')
testEvent(track, 'change', afterCompleteWork)
track.completeWork(todo)
t.is(track.completed(), 1, 'completeWork: 100% completed')
function afterCompleteWork (er, onChangeName) {
t.is(er, null, 'completeWork: on change event fired')
t.is(onChangeName, name, 'completeWork: on change emits the correct name')
t.done()
}
})
test('add more work', function (t) {
testEvent(track, 'change', afterAddWork)
track.addWork(todo)
t.is(track.completed(), 0.5, 'addWork: 50% completed')
function afterAddWork (er, onChangeName) {
t.is(er, null, 'addWork: on change event fired')
t.is(onChangeName, name, 'addWork: on change emits the correct name')
t.done()
}
})
test('complete more work', function (t) {
track.completeWork(200)
t.is(track.completed(), 1, 'completeWork: Over completion is still only 100% complete')
t.done()
})
test('finish is always 100%', function (t) {
var finishtest = new Tracker(name, todo)
finishtest.completeWork(50)
finishtest.finish()
t.is(finishtest.completed(), 1, 'finish: Explicitly finishing moves to 100%')
t.done()
})
'use strict'
var test = require('tap').test
var TrackerGroup = require('../index.js').TrackerGroup
var testEvent = require('./lib/test-event.js')
test('TrackerGroup', function (t) {
var name = 'test'
var track = new TrackerGroup(name)
t.is(track.completed(), 0, 'Nothing todo is 0 completion')
testEvent(track, 'change', afterFinishEmpty)
track.finish()
var a, b
function afterFinishEmpty (er, onChangeName, completion) {
t.is(er, null, 'finishEmpty: on change event fired')
t.is(onChangeName, name, 'finishEmpty: on change emits the correct name')
t.is(completion, 1, 'finishEmpty: passed through completion was correct')
t.is(track.completed(), 1, 'finishEmpty: Finishing an empty group actually finishes it')
track = new TrackerGroup(name)
a = track.newItem('a', 10, 1)
b = track.newItem('b', 10, 1)
t.is(track.completed(), 0, 'Initially empty')
testEvent(track, 'change', afterCompleteWork)
a.completeWork(5)
}
function afterCompleteWork (er, onChangeName, completion) {
t.is(er, null, 'on change event fired')
t.is(onChangeName, 'a', 'on change emits the correct name')
t.is(completion, 0.25, 'Complete half of one is a quarter overall')
t.is(track.completed(), 0.25, 'Complete half of one is a quarter overall')
testEvent(track, 'change', afterFinishAll)
track.finish()
}
function afterFinishAll (er, onChangeName, completion) {
t.is(er, null, 'finishAll: on change event fired')
t.is(onChangeName, name, 'finishAll: on change emits the correct name')
t.is(completion, 1, 'Finishing everything ')
t.is(track.completed(), 1, 'Finishing everything ')
track = new TrackerGroup(name)
a = track.newItem('a', 10, 2)
b = track.newItem('b', 10, 1)
t.is(track.completed(), 0, 'weighted: Initially empty')
testEvent(track, 'change', afterWeightedCompleteWork)
a.completeWork(5)
}
function afterWeightedCompleteWork (er, onChangeName, completion) {
t.is(er, null, 'weighted: on change event fired')
t.is(onChangeName, 'a', 'weighted: on change emits the correct name')
t.is(Math.floor(completion * 100), 33, 'weighted: Complete half of double weighted')
t.is(Math.floor(track.completed() * 100), 33, 'weighted: Complete half of double weighted')
testEvent(track, 'change', afterWeightedFinishAll)
track.finish()
}
function afterWeightedFinishAll (er, onChangeName, completion) {
t.is(er, null, 'weightedFinishAll: on change event fired')
t.is(onChangeName, name, 'weightedFinishAll: on change emits the correct name')
t.is(completion, 1, 'weightedFinishaAll: Finishing everything ')
t.is(track.completed(), 1, 'weightedFinishaAll: Finishing everything ')
track = new TrackerGroup(name)
a = track.newGroup('a', 10)
b = track.newGroup('b', 10)
var a1 = a.newItem('a.1', 10)
a1.completeWork(5)
t.is(track.completed(), 0.25, 'nested: Initially quarter done')
testEvent(track, 'change', afterNestedComplete)
b.finish()
}
function afterNestedComplete (er, onChangeName, completion) {
t.is(er, null, 'nestedComplete: on change event fired')
t.is(onChangeName, 'b', 'nestedComplete: on change emits the correct name')
t.is(completion, 0.75, 'nestedComplete: Finishing everything ')
t.is(track.completed(), 0.75, 'nestedComplete: Finishing everything ')
t.end()
}
})
test('cycles', function (t) {
var track = new TrackerGroup('top')
testCycle(track, track)
var layer1 = track.newGroup('layer1')
testCycle(layer1, track)
t.end()
function testCycle (addTo, toAdd) {
try {
addTo.addUnit(toAdd)
t.fail(toAdd.name)
} catch (ex) {
console.log(ex)
t.pass(toAdd.name)
}
}
})
'use strict'
var test = require('tap').test
var util = require('util')
var stream = require('readable-stream')
var TrackerStream = require('../index.js').TrackerStream
var testEvent = require('./lib/test-event.js')
var Sink = function () {
stream.Writable.apply(this, arguments)
}
util.inherits(Sink, stream.Writable)
Sink.prototype._write = function (data, encoding, cb) {
cb()
}
test('TrackerStream', function (t) {
t.plan(9)
var name = 'test'
var track = new TrackerStream(name)
t.is(track.completed(), 0, 'Nothing todo is 0 completion')
var todo = 10
track = new TrackerStream(name, todo)
t.is(track.completed(), 0, 'Nothing done is 0 completion')
track.pipe(new Sink())
testEvent(track, 'change', afterCompleteWork)
track.write('0123456789')
function afterCompleteWork (er, onChangeName) {
t.is(er, null, 'write: on change event fired')
t.is(onChangeName, name, 'write: on change emits the correct name')
t.is(track.completed(), 1, 'write: 100% completed')
testEvent(track, 'change', afterAddWork)
track.addWork(10)
}
function afterAddWork (er, onChangeName) {
t.is(er, null, 'addWork: on change event fired')
t.is(track.completed(), 0.5, 'addWork: 50% completed')
testEvent(track, 'change', afterAllWork)
track.write('ABCDEFGHIJKLMNOPQRST')
}
function afterAllWork (er) {
t.is(er, null, 'allWork: on change event fired')
t.is(track.completed(), 1, 'allWork: 100% completed')
}
})
'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)
'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
}
'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')
'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)
}
'use strict';
module.exports = function (arr, predicate, ctx) {
if (typeof Array.prototype.findIndex === 'function') {
return arr.findIndex(predicate, ctx);
}
if (typeof predicate !== 'function') {
throw new TypeError('predicate must be a function');
}
var list = Object(arr);
var len = list.length;
if (len === 0) {
return -1;
}
for (var i = 0; i < len; i++) {
if (predicate.call(ctx, list[i], i, list)) {
return i;
}
}
return -1;
};
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.