broccoli-viz
Advanced tools
Comparing version 1.0.0 to 1.0.1
35
dot.js
@@ -1,2 +0,2 @@ | ||
// usage: DUMP_BROCCOLI_TREES=true broccoli serve | ||
// usage: DUMP_BROCCOLI_TREES=true broccoli serve | ||
// results: ./broccoli-tree.json | ||
@@ -7,25 +7,28 @@ // converting to dot: node $BROCCOLI_PATH/scripts/graph broccoli-trees.json > graph.dot | ||
function formatTime(time) { | ||
return Math.floor(time / 1e6) +'ms' | ||
return Math.floor(time / 1e6) +'ms'; | ||
} | ||
module.exports = dot; | ||
function dot(nodes) { | ||
module.exports = function dot(nodes) { | ||
var out = 'digraph G {'; | ||
out += 'ratio = "auto"' | ||
out += 'ratio = "auto"'; | ||
nodes.forEach(function(node) { | ||
out += node.id | ||
if (node.description) { | ||
out += ' [shape=box, label=" ' + node.id + ' ' + ' (' + formatTime(node.selfTime) + ') \n' + (node.description || '') + '" ]' | ||
nodes.map(function(node) { | ||
return node.toJSON(); | ||
}).forEach(function(node) { | ||
out += node.id; | ||
var annotation = node.annotation || node.description; | ||
if (annotation) { | ||
annotation = annotation.replace('(', '\n('); | ||
out += ' [shape=box, label=" ' + node.id + ' ' + ' (' + formatTime(node.selfTime) + ') \n' + annotation + '" ]'; | ||
} else { | ||
out += ' [shape=circle, style="dotted", label=" ' + node.id + ' (' + formatTime(node.selfTime) + ') " ]' | ||
out += ' [shape=circle, style="dotted", label=" ' + node.id + ' (' + formatTime(node.selfTime) + ') " ]'; | ||
} | ||
out += '\n' | ||
node.subtrees.forEach(function(t) { | ||
out += ' ' + node.id + ' -> ' + t + ' \n' | ||
}) | ||
out += '\n'; | ||
node.subtrees.forEach(function(child) { | ||
out += ' ' + child + ' -> ' + node.id + ' \n'; | ||
}); | ||
}); | ||
out + '}'; | ||
out += '}'; | ||
return out; | ||
} | ||
}; |
@@ -22,2 +22,2 @@ 'use strict'; | ||
return result.values; | ||
} | ||
}; |
{ | ||
"name": "broccoli-viz", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
14
set.js
@@ -10,7 +10,7 @@ module.exports = Set; | ||
return this.map[obj.id] !== undefined; | ||
} | ||
}; | ||
Set.prototype.add = function(obj) { | ||
if (this.map[obj.id] !== true) { | ||
this.values.push(obj) | ||
this.values.push(obj); | ||
this.map[obj.id] = true; | ||
@@ -20,7 +20,7 @@ } | ||
return this; | ||
} | ||
}; | ||
Set.prototype.delete = function(obj) { | ||
if (this.map[obj.id] !== false) { | ||
this.values.push(obj) | ||
this.values.push(obj); | ||
this.map[obj.id] = true; | ||
@@ -30,3 +30,3 @@ } | ||
return this; | ||
} | ||
}; | ||
@@ -40,4 +40,2 @@ Set.prototype.forEach = function(_cb, binding) { | ||
} | ||
} | ||
}; |
35
test.js
@@ -5,2 +5,9 @@ var flatten = require('./flatten'); | ||
function toJSON() { return this; } | ||
function node(n) { | ||
n.toJSON = toJSON; | ||
return n; | ||
} | ||
describe('flatten', function() { | ||
@@ -18,6 +25,6 @@ it('works with one root', function(){ | ||
it('works with 2 levels', function(){ | ||
var a = { id: 'a', subtrees: [] }; | ||
var b = { id: 'b', subtrees: [] } | ||
var c = { id: 'c', subtrees: [a, b] }; | ||
it('works with 2 levels', function() { | ||
var a = node({ id: 'a', subtrees: [] }); | ||
var b = node({ id: 'b', subtrees: [] }); | ||
var c = node({ id: 'c', subtrees: [a, b] }); | ||
@@ -30,8 +37,8 @@ var result = flatten(c); | ||
it('works with messy tree and 4 levels', function(){ | ||
var a = { id: 'a', subtrees: [] }; | ||
var b = { id: 'b', subtrees: [] } | ||
var c = { id: 'c', subtrees: [a, b] }; | ||
var d = { id: 'd', subtrees: [c] }; | ||
var e = { id: 'e', subtrees: [d, b] }; | ||
it('works with messy tree and 4 levels', function() { | ||
var a = node({ id: 'a', subtrees: [] }); | ||
var b = node({ id: 'b', subtrees: [] }); | ||
var c = node({ id: 'c', subtrees: [a, b] }); | ||
var d = node({ id: 'd', subtrees: [c] }); | ||
var e = node({ id: 'e', subtrees: [d, b] }); | ||
@@ -47,11 +54,11 @@ var result = flatten(e); | ||
it('works with one root', function(){ | ||
var node = { | ||
var a = node({ | ||
id: 'a', | ||
subtrees: [] | ||
}; | ||
}); | ||
var result = dot(flatten(node)); | ||
var result = dot(flatten(a)); | ||
assert.equal(result, 'digraph G {ratio = \"auto\"a [shape=circle, style=\"dotted\", label=\" a (NaNms) \" ]\n'); | ||
assert.equal(result, 'digraph G {ratio = \"auto\"a [shape=circle, style=\"dotted\", label=\" a (NaNms) \" ]\n}'); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4420
126