Check local variables set with var === undefined.

Local variables always exist, so value check is
enough. This makes it easier to read code for me.
This commit is contained in:
anatoly techtonik 2012-07-05 13:01:52 +03:00
parent 2c51b08e49
commit 1150320e1c

View File

@ -38,14 +38,14 @@ var Graph = function() {
var Node = function(id, data) { var Node = function(id, data) {
this.id = id; this.id = id;
this.data = typeof(data) !== 'undefined' ? data : {}; this.data = (data !== undefined) ? data : {};
}; };
var Edge = function(id, source, target, data) { var Edge = function(id, source, target, data) {
this.id = id; this.id = id;
this.source = source; this.source = source;
this.target = target; this.target = target;
this.data = typeof(data) !== 'undefined' ? data : {}; this.data = (data !== undefined) ? data : {};
}; };
Graph.prototype.addNode = function(node) { Graph.prototype.addNode = function(node) {
@ -397,13 +397,14 @@ Layout.ForceDirected.prototype.start = function(render, done) {
t.updateVelocity(0.03); t.updateVelocity(0.03);
t.updatePosition(0.03); t.updatePosition(0.03);
if (typeof(render) !== 'undefined') if (render !== undefined) {
render(); render();
}
// stop simulation when energy of the system goes below a threshold // stop simulation when energy of the system goes below a threshold
if (t.totalEnergy() < 0.01) { if (t.totalEnergy() < 0.01) {
t._started = false; t._started = false;
if (typeof(done) !== 'undefined') { done(); } if (done !== undefined) { done(); }
} else { } else {
Layout.requestAnimationFrame(step); Layout.requestAnimationFrame(step);
} }