Skip to content

Commit

Permalink
lint: replace uses of ++ and -- operators
Browse files Browse the repository at this point in the history
  • Loading branch information
davidchambers committed Jun 8, 2015
1 parent f88d630 commit 7f7648d
Show file tree
Hide file tree
Showing 65 changed files with 230 additions and 146 deletions.
1 change: 1 addition & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"Symbol": true
},
"newcap": false,
"plusplus": true,
"predef": ["beforeEach", "console", "define", "describe", "it", "module", "process", "require"],
"undef": true,
"unused": true
Expand Down
2 changes: 1 addition & 1 deletion lib/sauce/ie8-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if (typeof document.getElementsByClassName !== 'function') {
} else {
var rightClass = new RegExp('(^| )' + className + '( |$)');
seek = document.getElementsByTagName(tag);
for (i = 0; i < seek.length; i++) {
for (i = 0; i < seek.length; i += 1) {
if (rightClass.test((node = seek[i]).className)) {
result.push(seek[i]);
}
Expand Down
8 changes: 6 additions & 2 deletions src/addIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ var curryN = require('./curryN');
*/
module.exports = _curry1(function(fn) {
return curryN(fn.length, function() {
var idx = -1;
var idx = 0;
var origFn = arguments[0];
var list = arguments[arguments.length - 1];
var indexedFn = function() {return origFn.apply(this, _concat(arguments, [++idx, list]));};
var indexedFn = function() {
var result = origFn.apply(this, _concat(arguments, [idx, list]));
idx += 1;
return result;
};

return fn.apply(this, _prepend(indexedFn, _slice(arguments, 1)));
});
Expand Down
5 changes: 3 additions & 2 deletions src/aperture.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ var _slice = require('./internal/_slice');
* R.aperture(7, [1, 2, 3, 4, 5]); //=> []
*/
module.exports = _curry2(function aperture(n, list) {
var idx = -1;
var idx = 0;
var limit = list.length - (n - 1);
var acc = new Array(limit >= 0 ? limit : 0);
while (++idx < limit) {
while (idx < limit) {
acc[idx] = _slice(list, idx, idx + n);
idx += 1;
}
return acc;
});
7 changes: 4 additions & 3 deletions src/composeL.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ var _composeL = require('./internal/_composeL');
* secondOfXOfHeadLens.set(123, source); //=> [{x: [0, 123], y: [2, 3]}, {x: [4, 5], y: [6, 7]}]
*/
module.exports = function() {
var idx = arguments.length - 1;
var fn = arguments[idx];
while (--idx >= 0) {
var fn = arguments[arguments.length - 1];
var idx = arguments.length - 2;
while (idx >= 0) {
fn = _composeL(arguments[idx], fn);
idx -= 1;
}
return fn;
};
5 changes: 3 additions & 2 deletions src/cond.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@
module.exports = function cond() {
var pairs = arguments;
return function() {
var idx = -1;
while (++idx < pairs.length) {
var idx = 0;
while (idx < pairs.length) {
if (pairs[idx][0].apply(this, arguments)) {
return pairs[idx][1].apply(this, arguments);
}
idx += 1;
}
};
};
5 changes: 3 additions & 2 deletions src/countBy.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ var _has = require('./internal/_has');
module.exports = _curry2(function countBy(fn, list) {
var counts = {};
var len = list.length;
var idx = -1;
while (++idx < len) {
var idx = 0;
while (idx < len) {
var key = fn(list[idx]);
counts[key] = (_has(key, counts) ? counts[key] : 0) + 1;
idx += 1;
}
return counts;
});
21 changes: 15 additions & 6 deletions src/curryN.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ module.exports = _curry2(function curryN(length, fn) {
return arity(length, function() {
var n = arguments.length;
var shortfall = length - n;
var idx = n;
while (--idx >= 0) {
var idx = n - 1;
while (idx >= 0) {
if (arguments[idx] === __) {
shortfall += 1;
}
idx -= 1;
}
if (shortfall <= 0) {
return fn.apply(this, arguments);
Expand All @@ -64,14 +65,22 @@ module.exports = _curry2(function curryN(length, fn) {
return curryN(shortfall, function() {
var currentArgs = _slice(arguments);
var combinedArgs = [];
var idx = -1;
var idx = 0;
var currentArgsIdx = 0;
while (++idx < n) {
while (idx < n) {
var val = initialArgs[idx];
combinedArgs[idx] = (val === __ ? currentArgs[currentArgsIdx++] : val);
if (val === __) {
combinedArgs[idx] = currentArgs[currentArgsIdx];
currentArgsIdx += 1;
} else {
combinedArgs[idx] = val;
}
idx += 1;
}
while (currentArgsIdx < currentArgs.length) {
combinedArgs[idx++] = currentArgs[currentArgsIdx++];
combinedArgs[idx] = currentArgs[currentArgsIdx];
idx += 1;
currentArgsIdx += 1;
}
return fn.apply(this, combinedArgs);
});
Expand Down
5 changes: 3 additions & 2 deletions src/difference.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ var _curry2 = require('./internal/_curry2');
*/
module.exports = _curry2(function difference(first, second) {
var out = [];
var idx = -1;
var idx = 0;
var firstLen = first.length;
while (++idx < firstLen) {
while (idx < firstLen) {
if (!_contains(first[idx], second) && !_contains(first[idx], out)) {
out[out.length] = first[idx];
}
idx += 1;
}
return out;
});
5 changes: 3 additions & 2 deletions src/differenceWith.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ var containsWith = require('./containsWith');
*/
module.exports = _curry3(function differenceWith(pred, first, second) {
var out = [];
var idx = -1;
var idx = 0;
var firstLen = first.length;
var containsPred = containsWith(pred);
while (++idx < firstLen) {
while (idx < firstLen) {
if (!containsPred(first[idx], second) && !containsPred(first[idx], out)) {
out[out.length] = first[idx];
}
idx += 1;
}
return out;
});
5 changes: 3 additions & 2 deletions src/dropRepeatsWith.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ var last = require('./last');
*/
module.exports = _curry2(_dispatchable('dropRepeatsWith', _xdropRepeatsWith, function dropRepeatsWith(pred, list) {
var result = [];
var idx = 0;
var idx = 1;
var len = list.length;
if (len !== 0) {
result[0] = list[0];
while (++idx < len) {
while (idx < len) {
if (!pred(last(result), list[idx])) {
result[result.length] = list[idx];
}
idx += 1;
}
}
return result;
Expand Down
6 changes: 4 additions & 2 deletions src/dropWhile.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ var _xdropWhile = require('./internal/_xdropWhile');
* R.dropWhile(lteTwo, [1, 2, 3, 4, 3, 2, 1]); //=> [3, 4, 3, 2, 1]
*/
module.exports = _curry2(_dispatchable('dropWhile', _xdropWhile, function dropWhile(pred, list) {
var idx = -1, len = list.length;
while (++idx < len && pred(list[idx])) {}
var idx = 0, len = list.length;
while (idx < len && pred(list[idx])) {
idx += 1;
}
return _slice(list, idx);
}));
5 changes: 3 additions & 2 deletions src/find.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ var _xfind = require('./internal/_xfind');
* R.find(R.propEq('a', 4))(xs); //=> undefined
*/
module.exports = _curry2(_dispatchable('find', _xfind, function find(fn, list) {
var idx = -1;
var idx = 0;
var len = list.length;
while (++idx < len) {
while (idx < len) {
if (fn(list[idx])) {
return list[idx];
}
idx += 1;
}
}));
5 changes: 3 additions & 2 deletions src/findIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ var _xfindIndex = require('./internal/_xfindIndex');
* R.findIndex(R.propEq('a', 4))(xs); //=> -1
*/
module.exports = _curry2(_dispatchable('findIndex', _xfindIndex, function findIndex(fn, list) {
var idx = -1;
var idx = 0;
var len = list.length;
while (++idx < len) {
while (idx < len) {
if (fn(list[idx])) {
return idx;
}
idx += 1;
}
return -1;
}));
5 changes: 3 additions & 2 deletions src/findLast.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ var _xfindLast = require('./internal/_xfindLast');
* R.findLast(R.propEq('a', 4))(xs); //=> undefined
*/
module.exports = _curry2(_dispatchable('findLast', _xfindLast, function findLast(fn, list) {
var idx = list.length;
while (--idx >= 0) {
var idx = list.length - 1;
while (idx >= 0) {
if (fn(list[idx])) {
return list[idx];
}
idx -= 1;
}
}));
5 changes: 3 additions & 2 deletions src/findLastIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ var _xfindLastIndex = require('./internal/_xfindLastIndex');
* R.findLastIndex(R.propEq('a', 4))(xs); //=> -1
*/
module.exports = _curry2(_dispatchable('findLastIndex', _xfindLastIndex, function findLastIndex(fn, list) {
var idx = list.length;
while (--idx >= 0) {
var idx = list.length - 1;
while (idx >= 0) {
if (fn(list[idx])) {
return idx;
}
idx -= 1;
}
return -1;
}));
5 changes: 3 additions & 2 deletions src/forEachIndexed.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ var _curry2 = require('./internal/_curry2');
* R.forEachIndexed(plusFive, [1, 2, 3]); //=> [6, 7, 8]
*/
module.exports = _curry2(function forEachIndexed(fn, list) {
var idx = -1, len = list.length;
while (++idx < len) {
var idx = 0, len = list.length;
while (idx < len) {
fn(list[idx], idx, list);
idx += 1;
}
// i can't bear not to return *something*
return list;
Expand Down
5 changes: 3 additions & 2 deletions src/fromPairs.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ var _isArray = require('./internal/_isArray');
* R.fromPairs([['a', 1], ['b', 2], ['c', 3]]); //=> {a: 1, b: 2, c: 3}
*/
module.exports = _curry1(function fromPairs(pairs) {
var idx = -1, len = pairs.length, out = {};
while (++idx < len) {
var idx = 0, len = pairs.length, out = {};
while (idx < len) {
if (_isArray(pairs[idx]) && pairs[idx].length) {
out[pairs[idx][0]] = pairs[idx][1];
}
idx += 1;
}
return out;
});
5 changes: 3 additions & 2 deletions src/internal/_all.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
module.exports = function _all(fn, list) {
var idx = -1;
while (++idx < list.length) {
var idx = 0;
while (idx < list.length) {
if (!fn(list[idx])) {
return false;
}
idx += 1;
}
return true;
};
5 changes: 3 additions & 2 deletions src/internal/_any.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
module.exports = function _any(fn, list) {
var idx = -1;
while (++idx < list.length) {
var idx = 0;
while (idx < list.length) {
if (fn(list[idx])) {
return true;
}
idx += 1;
}
return false;
};
5 changes: 3 additions & 2 deletions src/internal/_baseCopy.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ var type = require('../type');
module.exports = function _baseCopy(value, refFrom, refTo) {
var copy = function copy(copiedValue) {
var len = refFrom.length;
var idx = -1;
while (++idx < len) {
var idx = 0;
while (idx < len) {
if (value === refFrom[idx]) {
return refTo[idx];
}
idx += 1;
}
refFrom[idx + 1] = value;
refTo[idx + 1] = copiedValue;
Expand Down
10 changes: 6 additions & 4 deletions src/internal/_concat.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ module.exports = function _concat(set1, set2) {
var len2 = set2.length;
var result = [];

idx = -1;
while (++idx < len1) {
idx = 0;
while (idx < len1) {
result[result.length] = set1[idx];
idx += 1;
}
idx = -1;
while (++idx < len2) {
idx = 0;
while (idx < len2) {
result[result.length] = set2[idx];
idx += 1;
}
return result;
};
5 changes: 3 additions & 2 deletions src/internal/_containsWith.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
module.exports = function _containsWith(pred, x, list) {
var idx = -1, len = list.length;
while (++idx < len) {
var idx = 0, len = list.length;
while (idx < len) {
if (pred(x, list[idx])) {
return true;
}
idx += 1;
}
return false;
};
7 changes: 4 additions & 3 deletions src/internal/_createComposer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ var arity = require('../arity');
*/
module.exports = function _createComposer(composeFunction) {
return function() {
var idx = arguments.length - 1;
var fn = arguments[idx];
var fn = arguments[arguments.length - 1];
var length = fn.length;
while (--idx >= 0) {
var idx = arguments.length - 2;
while (idx >= 0) {
fn = composeFunction(arguments[idx], fn);
idx -= 1;
}
return arity(length, fn);
};
Expand Down
5 changes: 3 additions & 2 deletions src/internal/_createMaxMin.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ var _curry1 = require('./_curry1');
*/
module.exports = function _createMaxMin(comparator, initialVal) {
return _curry1(function(list) {
var idx = -1, winner = initialVal, computed;
while (++idx < list.length) {
var idx = 0, winner = initialVal, computed;
while (idx < list.length) {
computed = +list[idx];
if (comparator(computed, winner)) {
winner = computed;
}
idx += 1;
}
return winner;
});
Expand Down
Loading

0 comments on commit 7f7648d

Please sign in to comment.