Comparing version 0.14.4 to 0.14.5
0.14.5 / 2016-06-26 | ||
=================== | ||
* adding more timer-based debug logs | ||
0.14.4 / 2016-06-19 | ||
@@ -3,0 +8,0 @@ =================== |
@@ -5,2 +5,3 @@ 'use strict' | ||
let bytes = require('bytes') | ||
let debug = require('debug')('mako-tree') | ||
@@ -11,2 +12,3 @@ let defaults = require('defaults') | ||
let Graph = require('graph.js/dist/graph.js') | ||
let pretty = require('pretty-time') | ||
let relative = require('relative') | ||
@@ -79,2 +81,3 @@ let toposort = require('graph-toposort') | ||
findFile (file) { | ||
let timer = time() | ||
let path = typeof file === 'string' ? file : file.path | ||
@@ -85,7 +88,7 @@ debug('searching for file with path %s', relative(path)) | ||
if (file.hasPath(path)) { | ||
debug('match found: %s', relative(file.path)) | ||
debug('match found: %s (took %s)', relative(file.path), timer()) | ||
return file | ||
} | ||
} | ||
debug('file not found') | ||
debug('file not found (took %s)', timer()) | ||
} | ||
@@ -104,7 +107,11 @@ | ||
let config = defaults(options, { topological: false }) | ||
let timer = time() | ||
debug('getting %d files: %j', this.size(), config) | ||
return config.topological | ||
let files = config.topological | ||
? toposort(this.graph).map(id => this.getFile(id)) | ||
: Array.from(this.graph.vertices()).map(v => v[1]) | ||
debug('finished getting %d files (took %s)', files.length, timer()) | ||
return files | ||
} | ||
@@ -184,2 +191,3 @@ | ||
dependenciesOf (node, options) { | ||
let timer = time() | ||
let config = defaults(options, { recursive: false }) | ||
@@ -193,3 +201,3 @@ let file = this.getFile(id(node)) | ||
debug('%d dependencies found', deps.length) | ||
debug('%d dependencies found (took %s)', deps.length, timer()) | ||
return deps.map(v => v[1]) | ||
@@ -251,2 +259,3 @@ } | ||
dependantsOf (node, options) { | ||
let timer = time() | ||
let config = defaults(options, { recursive: false }) | ||
@@ -260,3 +269,3 @@ let file = this.getFile(id(node)) | ||
debug('%d dependants found', deps.length) | ||
debug('%d dependants found (took %s)', deps.length, timer()) | ||
return deps.map(v => v[1]) | ||
@@ -281,5 +290,6 @@ } | ||
debug('cloning tree') | ||
let timer = time() | ||
let tree = new Tree() | ||
tree.graph = this.graph.clone(file => file.clone(tree), value => value) | ||
debug('done cloning tree') | ||
debug('cloned tree (took %s)', timer()) | ||
return tree | ||
@@ -294,2 +304,3 @@ } | ||
prune (anchors) { | ||
let timer = time() | ||
let initialSize = this.size() | ||
@@ -311,3 +322,3 @@ let files = anchors.map(file => this.getFile(id(file))) | ||
debug('%d files pruned from tree (new size: %d)', initialSize, this.size()) | ||
debug('%d files pruned from tree (took %s)', initialSize, timer()) | ||
} | ||
@@ -319,5 +330,7 @@ | ||
removeCycles () { | ||
debug('removing cycles from tree') | ||
let timer = time() | ||
let graph = this.graph | ||
debug('removing cycles from tree') | ||
Array.from(graph.cycles()).forEach(cycle => { | ||
let cycles = Array.from(graph.cycles()) | ||
cycles.forEach(cycle => { | ||
let files = cycle.map(file => this.getFile(file)) | ||
@@ -334,2 +347,3 @@ debug('cycle detected:') | ||
}) | ||
debug('removed %d cycles (took %s)', cycles.length, timer()) | ||
} | ||
@@ -344,3 +358,5 @@ | ||
toJSON () { | ||
return { | ||
debug('convert to json') | ||
let timer = time() | ||
let o = { | ||
root: this.root, | ||
@@ -350,2 +366,4 @@ files: this.getFiles(), | ||
} | ||
debug('converted to json (took %s)', timer()) | ||
return o | ||
} | ||
@@ -361,4 +379,7 @@ | ||
toString (space) { | ||
debug('stringify tree') | ||
return JSON.stringify(this, null, space) | ||
debug('convert to string') | ||
let timer = time() | ||
let str = JSON.stringify(this, null, space) | ||
debug('converted to %s string (took %s)', bytes(str.length), timer()) | ||
return str | ||
} | ||
@@ -374,3 +395,4 @@ | ||
static fromString (input) { | ||
debug('creating from string') | ||
debug('convert from string') | ||
let timer = time() | ||
let parsed = JSON.parse(input, reviver) | ||
@@ -390,3 +412,3 @@ let tree = new Tree(parsed.root) | ||
debug('done creating tree from string') | ||
debug('converted from %s string (took %s)', bytes(input.length), timer()) | ||
return tree | ||
@@ -427,1 +449,11 @@ } | ||
} | ||
/** | ||
* Start a timer that we can use for logging timing information. | ||
* | ||
* @return {Function} | ||
*/ | ||
function time () { | ||
let start = process.hrtime() | ||
return () => pretty(process.hrtime(start)) | ||
} |
{ | ||
"name": "mako-tree", | ||
"version": "0.14.4", | ||
"version": "0.14.5", | ||
"main": "./lib/tree", | ||
@@ -13,2 +13,3 @@ "description": "The build tree structure used internally by mako", | ||
"babel-polyfill-safe": "^1.0.1", | ||
"bytes": "^2.4.0", | ||
"clone": "^1.0.2", | ||
@@ -20,2 +21,3 @@ "debug": "^2.2.0", | ||
"graph.js": "^1.20.1", | ||
"pretty-time": "^0.2.0", | ||
"regex-iso-date": "^1.0.0", | ||
@@ -22,0 +24,0 @@ "relative": "^3.0.2", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
63370
1487
0
13
+ Addedbytes@^2.4.0
+ Addedpretty-time@^0.2.0
+ Addedbytes@2.5.0(transitive)
+ Addedis-buffer@1.1.6(transitive)
+ Addedis-number@2.1.0(transitive)
+ Addedkind-of@3.2.2(transitive)
+ Addednanoseconds@0.1.0(transitive)
+ Addedpretty-time@0.2.0(transitive)