Skip to content

Commit

Permalink
globally replace let with var
Browse files Browse the repository at this point in the history
  • Loading branch information
sghall committed Jul 23, 2017
1 parent cef63d8 commit ced5dc4
Show file tree
Hide file tree
Showing 17 changed files with 49 additions and 48 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ module.exports = {
},
rules: {
'indent': ['error', 2],
'no-var': 'error',
'prefer-const': 'error',
'linebreak-style': ['error', 'unix'],
'quotes': ['error', 'single'],
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.eslintcache
.DS_Store
node_modules
dist
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"build:lib": "rollup --config rollup.config.prd.js",
"build:min": "uglifyjs dist/subunit.js -ecma 5 -c -m -o dist/subunit.min.js",
"build:copy-files": "babel-node ./scripts/copy-files.js",
"start": "rm -rf dist && mkdir dist && rollup -c rollup.config.dev.js --watch"
"start": "rm -rf dist && mkdir dist && rollup -c rollup.config.dev.js --watch",
"lint": "eslint src --quiet --cache && echo \"eslint: no lint errors\""
},
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion src/Transition.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import size from 'd3-selection/src/selection/size';
import empty from 'd3-selection/src/selection/empty';
import each from 'd3-selection/src/selection/each';

let id = 0;
var id = 0;

export function Transition(groups, parents, name, id) {
this._groups = groups;
Expand Down
2 changes: 1 addition & 1 deletion src/selection/append.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function append(name) {
}

function selectionCreator(name) {
let Func;
var Func;

if (typeof name === 'function') {
Func = name; // SEND ANY CONSTRUCTOR
Expand Down
2 changes: 1 addition & 1 deletion src/selection/attr.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function selectionAttr(name, value) {
if (name === 'tags' || name === 'class') {
const arr = value.split(' ');

for (let i = 0; i < arr.length; i++) {
for (var i = 0; i < arr.length; i++) {
this.__tags__.push(arr[i]);
}
} else if (name === 'position' || name === 'scale') {
Expand Down
16 changes: 8 additions & 8 deletions src/selection/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ function bindIndex(parent, group, enter, update, exit, data) {
const groupLength = group.length;
const dataLength = data.length;

let i = 0;
let node;
var i = 0;
var node;

for (; i < dataLength; ++i) {
if ((node = group[i])) {
Expand All @@ -33,9 +33,9 @@ function bindKey(parent, group, enter, update, exit, data, key) {
const dataLength = data.length;
const keyValues = new Array(groupLength);

let i;
let node;
let keyValue;
var i;
var node;
var keyValue;

for (i = 0; i < groupLength; ++i) {
if ((node = group[i])) {
Expand Down Expand Up @@ -70,7 +70,7 @@ export default function(value, key) {
if (!value) {
const data = new Array(this.size());

let j = -1;
var j = -1;

this.each(function(d) { data[++j] = d; });

Expand All @@ -88,7 +88,7 @@ export default function(value, key) {
const update = new Array(m);
const exit = new Array(m);

for (let j = 0; j < m; ++j) {
for (j = 0; j < m; ++j) {
const parent = parents[j];
const group = groups[j];
const groupLength = group.length;
Expand All @@ -102,7 +102,7 @@ export default function(value, key) {

bind(parent, group, enterGroup, updateGroup, exitGroup, data, key);

for (let i0 = 0, i1 = 0, previous, next; i0 < dataLength; ++i0) {
for (var i0 = 0, i1 = 0, previous, next; i0 < dataLength; ++i0) {
if ((previous = enterGroup[i0])) {
if (i0 >= i1) i1 = i0 + 1;
while (!(next = updateGroup[i1]) && ++i1 < dataLength);
Expand Down
4 changes: 2 additions & 2 deletions src/selection/each.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ export default function each(callback) {
}

export function selectionEach(groups, callback) {
for (let j = 0, m = groups.length; j < m; j++) {
for (let group = groups[j], i = 0, n = group.length, node; i < n; i++) {
for (var j = 0, m = groups.length; j < m; j++) {
for (var group = groups[j], i = 0, n = group.length, node; i < n; i++) {
if ((node = group[i])) {
callback(node, i, j);
}
Expand Down
10 changes: 5 additions & 5 deletions src/selection/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ import { search } from '../utils/utils';
export default function filter(fun) {
const subgroups = [];

let subgroup;
let group;
let node;
var subgroup;
var group;
var node;

if (typeof fun !== 'function') {
fun = selectionFilter(fun);
}

for (let j = 0, m = this.length; j < m; j++) {
for (var j = 0, m = this.length; j < m; j++) {
subgroups.push(subgroup = []);
subgroup.parentNode = (group = this[j]).parentNode;

for (let i = 0, n = group.length; i < n; i++) {
for (var i = 0, n = group.length; i < n; i++) {
if ((node = group[i]) && fun.call(node, node.__data__, i, j)) {
subgroup.push(node);
}
Expand Down
4 changes: 2 additions & 2 deletions src/selection/merge.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function(selection) {
const m = Math.min(m0, m1);
const merges = new Array(m0);

let j = 0;
var j = 0;

for (; j < m; ++j) {

Expand All @@ -18,7 +18,7 @@ export default function(selection) {
const n = group0.length;
const merge = merges[j] = new Array(n);

for (let node, i = 0; i < n; ++i) {
for (var node, i = 0; i < n; ++i) {
if ((node = group0[i] || group1[i])) {
merge[i] = node;
}
Expand Down
4 changes: 2 additions & 2 deletions src/selection/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export default function select(selector) {
const m = groups.length;
const subgroups = new Array(m);

for (let j = 0; j < m; ++j) {
for (let group = groups[j], n = group.length, subgroup = subgroups[j] = new Array(n), node, subnode, i = 0; i < n; ++i) {
for (var j = 0; j < m; ++j) {
for (var group = groups[j], n = group.length, subgroup = subgroups[j] = new Array(n), node, subnode, i = 0; i < n; ++i) {
if ((node = group[i]) && (subnode = selector.call(node, node.__data__, i, group))) {
if ('__data__' in node) subnode.__data__ = node.__data__;
subgroup[i] = subnode;
Expand Down
4 changes: 2 additions & 2 deletions src/selection/selectAll.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export default function selectAll(select) {

if (typeof select !== 'function') select = selectionSelectorAll(select);

for (let groups = this._groups, m = groups.length, j = 0; j < m; ++j) {
for (let group = groups[j], n = group.length, node, i = 0; i < n; ++i) {
for (var groups = this._groups, m = groups.length, j = 0; j < m; ++j) {
for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) {
if ((node = group[i])) {
subgroups.push(select.call(node, node.__data__, i, group));
parents.push(node);
Expand Down
4 changes: 2 additions & 2 deletions src/selection/sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ export default function(compare) {
const m = groups.length;
const sortgroups = new Array(m);

for (let j = 0; j < m; ++j) {
for (var j = 0; j < m; ++j) {
const group = groups[j];
const n = group.length;
const sortgroup = sortgroups[j] = new Array(n);

for (let node, i = 0; i < n; ++i) {
for (var node, i = 0; i < n; ++i) {
if ((node = group[i])) {
sortgroup[i] = node;
}
Expand Down
6 changes: 3 additions & 3 deletions src/selection/tagged.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default function tagged(name, value) {
const node = this.node();
const n = (name = selectionTags(name)).length;

let i = -1;
var i = -1;

if ((value = node.__tags__.length)) {
while (++i < n) {
Expand Down Expand Up @@ -41,7 +41,7 @@ function selectionTagged(name, value) {
const n = name.length;

function taggedConstant() {
let i = -1;
var i = -1;

while (++i < n) {
name[i](this, value);
Expand All @@ -51,7 +51,7 @@ function selectionTagged(name, value) {
function taggedFunction() {
const x = value.apply(this, arguments);

let i = -1;
var i = -1;

while (++i < n) {
name[i](this, x);
Expand Down
10 changes: 5 additions & 5 deletions src/selection/transition.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const defaultTiming = {
};

function inherit(node, id) {
let timing;
var timing;

while (!(timing = node.__transition) || !(timing = timing[id])) {
if (!(node = node.parentNode)) {
Expand All @@ -24,8 +24,8 @@ function inherit(node, id) {
}

export default function(name) {
let id;
let timing;
var id;
var timing;

if (name instanceof Transition) {
id = name._id, name = name._name;
Expand All @@ -36,8 +36,8 @@ export default function(name) {
const groups = this._groups;
const m = groups.length;

for (let j = 0; j < m; ++j) {
for (let group = groups[j], n = group.length, node, i = 0; i < n; ++i) {
for (var j = 0; j < m; ++j) {
for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) {
if ((node = group[i])) {
schedule(node, name, id, i, group, timing || inherit(node, id));
}
Expand Down
12 changes: 6 additions & 6 deletions src/transition/tween.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { get, set } from 'd3-transition/src/transition/schedule';

function tweenFunction(id, name, value) {
let tween0;
let tween1;
var tween0;
var tween1;

if (typeof value !== 'function') throw new Error;

Expand All @@ -11,9 +11,9 @@ function tweenFunction(id, name, value) {
const tween = schedule.tween;

if (tween !== tween0) {
let i;
let t;
let n;
var i;
var t;
var n;

tween1 = (tween0 = tween).slice();

Expand All @@ -38,7 +38,7 @@ export default function(name, value) {
if (arguments.length < 2) {
const tween = get(this.node(), id).tween;

for (let i = 0, n = tween.length, t; i < n; ++i) {
for (var i = 0, n = tween.length, t; i < n; ++i) {
if ((t = tween[i]).name === name) {
return t.value;
}
Expand Down
12 changes: 6 additions & 6 deletions src/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ export function search(node, selector) {
return;
}

for (let i = 0; i < tagsArray.length; i++) {
for (var i = 0; i < tagsArray.length; i++) {
if (node.__tags__.indexOf(tagsArray[i]) < 0) {
return;
}
}
} else {
const keys = Object.keys(selector);

for (let i = 0; i < keys.length; i++) {
if (node[keys[i]] !== selector[keys[i]]) {
for (var j = 0; j < keys.length; j++) {
if (node[keys[j]] !== selector[keys[j]]) {
return;
}
}
Expand All @@ -52,19 +52,19 @@ function toObject(val) {
}

export function assign(target, source) {
let pendingException;
var pendingException;

const to = toObject(target);

if (!source) {
throw new Error('No source(s) provided to assign.');
}

for (let s = 1; s < arguments.length; s++) {
for (var s = 1; s < arguments.length; s++) {
const fromObj = arguments[s];
const objKeys = Object.keys(Object(fromObj));

for (let i = 0; i < objKeys.length; i++) {
for (var i = 0; i < objKeys.length; i++) {
try {
to[objKeys[i]] = fromObj[objKeys[i]];
} catch (err) {
Expand Down

0 comments on commit ced5dc4

Please sign in to comment.