commando.html5/node_modules/bunker/example/tiny.js

19 lines
420 B
JavaScript

var bunker = require('bunker');
var b = bunker('var x = 0; for (var i = 0; i < 30; i++) { x++ }');
var counts = {};
b.on('node', function (node) {
if (!counts[node.id]) {
counts[node.id] = { times : 0, node : node };
}
counts[node.id].times ++;
});
b.run();
Object.keys(counts).forEach(function (key) {
var count = counts[key];
console.log(count.times + ' : ' + count.node.source());
});