Permalink
Browse files

lint: replace uses of ++ and -- operators

  • Loading branch information...
1 parent f88d630 commit 7f7648dfd46561c9d9fdfde5c1d0369c1e33a4eb @davidchambers davidchambers committed Jun 8, 2015
Showing with 230 additions and 146 deletions.
  1. +1 −0 .jshintrc
  2. +1 −1 lib/sauce/ie8-shim.js
  3. +6 −2 src/addIndex.js
  4. +3 −2 src/aperture.js
  5. +4 −3 src/composeL.js
  6. +3 −2 src/cond.js
  7. +3 −2 src/countBy.js
  8. +15 −6 src/curryN.js
  9. +3 −2 src/difference.js
  10. +3 −2 src/differenceWith.js
  11. +3 −2 src/dropRepeatsWith.js
  12. +4 −2 src/dropWhile.js
  13. +3 −2 src/find.js
  14. +3 −2 src/findIndex.js
  15. +3 −2 src/findLast.js
  16. +3 −2 src/findLastIndex.js
  17. +3 −2 src/forEachIndexed.js
  18. +3 −2 src/fromPairs.js
  19. +3 −2 src/internal/_all.js
  20. +3 −2 src/internal/_any.js
  21. +3 −2 src/internal/_baseCopy.js
  22. +6 −4 src/internal/_concat.js
  23. +3 −2 src/internal/_containsWith.js
  24. +4 −3 src/internal/_createComposer.js
  25. +3 −2 src/internal/_createMaxMin.js
  26. +3 −2 src/internal/_createMaxMinBy.js
  27. +6 −4 src/internal/_equals.js
  28. +3 −2 src/internal/_extend.js
  29. +3 −2 src/internal/_filter.js
  30. +3 −2 src/internal/_filterIndexed.js
  31. +3 −2 src/internal/_forEach.js
  32. +1 −1 src/internal/_indexOf.js
  33. +6 −3 src/internal/_lastIndexOf.js
  34. +6 −4 src/internal/_makeFlat.js
  35. +3 −2 src/internal/_map.js
  36. +3 −2 src/internal/_reduce.js
  37. +3 −2 src/internal/_slice.js
  38. +3 −2 src/intersectionWith.js
  39. +3 −2 src/intersperse.js
  40. +3 −2 src/invert.js
  41. +3 −2 src/invertObj.js
  42. +3 −2 src/isSet.js
  43. +6 −4 src/keys.js
  44. +3 −2 src/mapAccum.js
  45. +3 −2 src/mapAccumRight.js
  46. +3 −2 src/mapIndexed.js
  47. +3 −2 src/pick.js
  48. +3 −2 src/pickAll.js
  49. +3 −2 src/props.js
  50. +3 −2 src/reduceIndexed.js
  51. +3 −2 src/reduceRight.js
  52. +3 −2 src/reduceRightIndexed.js
  53. +5 −4 src/scan.js
  54. +3 −2 src/set.js
  55. +4 −2 src/takeWhile.js
  56. +3 −2 src/uniqWith.js
  57. +3 −2 src/useWith.js
  58. +3 −2 src/values.js
  59. +6 −4 src/xprod.js
  60. +3 −2 src/zip.js
  61. +3 −2 src/zipObj.js
  62. +3 −2 src/zipWith.js
  63. +3 −2 test/nAry.js
  64. +6 −4 test/unapply.js
  65. +2 −1 test/unfold.js
View
@@ -6,6 +6,7 @@
"Symbol": true
},
"newcap": false,
+ "plusplus": true,
"predef": ["beforeEach", "console", "define", "describe", "it", "module", "process", "require"],
"undef": true,
"unused": true
@@ -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]);
}
View
@@ -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)));
});
View
@@ -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;
});
View
@@ -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;
};
View
@@ -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;
}
};
};
View
@@ -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;
});
View
@@ -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);
@@ -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);
});
View
@@ -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;
});
@@ -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;
});
@@ -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;
View
@@ -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);
}));
View
@@ -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;
}
}));
View
@@ -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;
}));
View
@@ -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;
}
}));
@@ -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;
}));
@@ -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;
View
@@ -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;
});
@@ -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;
};
@@ -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;
};
@@ -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;
@@ -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;
};
@@ -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,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);
};
@@ -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;
});
Oops, something went wrong.

0 comments on commit 7f7648d

Please sign in to comment.