Skip to content

Commit

Permalink
Apply arrow function transform.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Jan 6, 2017
1 parent d461c87 commit 7167d7e
Show file tree
Hide file tree
Showing 108 changed files with 173 additions and 272 deletions.
7 changes: 3 additions & 4 deletions _arrayLikeKeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@ function arrayLikeKeys(value, inherited) {
if ((inherited || hasOwnProperty.call(value, key)) &&
!(skipIndexes && (
// Safari 9 has enumerable `arguments.length` in strict mode.
key == 'length' ||
(key == 'length' ||
// Node.js 0.10 has enumerable non-index properties on buffers.
(isBuff && (key == 'offset' || key == 'parent')) ||
// PhantomJS 2 has enumerable non-index properties on typed arrays.
(isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
// Skip index properties.
isIndex(key, length)
(isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) || // Skip index properties.
isIndex(key, length))
))) {
result.push(key);
}
Expand Down
2 changes: 1 addition & 1 deletion _baseClone.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ function baseClone(value, bitmask, customizer, key, object, stack) {
: (isFlat ? keysIn : keys);

var props = isArr ? undefined : keysFunc(value);
arrayEach(props || value, function(subValue, key) {
arrayEach(props || value, (subValue, key) => {
if (props) {
key = subValue;
subValue = value[key];
Expand Down
2 changes: 1 addition & 1 deletion _baseInverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import baseForOwn from './_baseForOwn.js';
* @returns {Function} Returns `accumulator`.
*/
function baseInverter(object, setter, iteratee, accumulator) {
baseForOwn(object, function(value, key, object) {
baseForOwn(object, (value, key, object) => {
setter(accumulator, iteratee(value), key, object);
});
return accumulator;
Expand Down
4 changes: 1 addition & 3 deletions _baseMatches.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ function baseMatches(source) {
if (matchData.length == 1 && matchData[0][2]) {
return matchesStrictComparable(matchData[0][0], matchData[0][1]);
}
return function(object) {
return object === source || baseIsMatch(object, source, matchData);
};
return object => object === source || baseIsMatch(object, source, matchData);
}

export default baseMatches;
2 changes: 1 addition & 1 deletion _baseMatchesProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function baseMatchesProperty(path, srcValue) {
if (isKey(path) && isStrictComparable(srcValue)) {
return matchesStrictComparable(toKey(path), srcValue);
}
return function(object) {
return object => {
var objValue = get(object, path);
return (objValue === undefined && objValue === srcValue)
? hasIn(object, path)
Expand Down
10 changes: 3 additions & 7 deletions _baseOrderBy.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,12 @@ function baseOrderBy(collection, iteratees, orders) {
var index = -1;
iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(baseIteratee));

var result = baseMap(collection, function(value, key, collection) {
var criteria = arrayMap(iteratees, function(iteratee) {
return iteratee(value);
});
var result = baseMap(collection, (value, key, collection) => {
var criteria = arrayMap(iteratees, iteratee => iteratee(value));
return { 'criteria': criteria, 'index': ++index, 'value': value };
});

return baseSortBy(result, function(object, other) {
return compareMultiple(object, other, orders);
});
return baseSortBy(result, (object, other) => compareMultiple(object, other, orders));
}

export default baseOrderBy;
4 changes: 1 addition & 3 deletions _basePick.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import hasIn from './hasIn.js';
* @returns {Object} Returns the new object.
*/
function basePick(object, paths) {
return basePickBy(object, paths, function(value, path) {
return hasIn(object, path);
});
return basePickBy(object, paths, (value, path) => hasIn(object, path));
}

export default basePick;
4 changes: 1 addition & 3 deletions _baseProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
* @returns {Function} Returns the new accessor function.
*/
function baseProperty(key) {
return function(object) {
return object == null ? undefined : object[key];
};
return object => object == null ? undefined : object[key];
}

export default baseProperty;
4 changes: 1 addition & 3 deletions _basePropertyDeep.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import baseGet from './_baseGet.js';
* @returns {Function} Returns the new accessor function.
*/
function basePropertyDeep(path) {
return function(object) {
return baseGet(object, path);
};
return object => baseGet(object, path);
}

export default basePropertyDeep;
4 changes: 1 addition & 3 deletions _basePropertyOf.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
* @returns {Function} Returns the new accessor function.
*/
function basePropertyOf(object) {
return function(key) {
return object == null ? undefined : object[key];
};
return key => object == null ? undefined : object[key];
}

export default basePropertyOf;
2 changes: 1 addition & 1 deletion _baseReduce.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* @returns {*} Returns the accumulated value.
*/
function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
eachFunc(collection, function(value, index, collection) {
eachFunc(collection, (value, index, collection) => {
accumulator = initAccum
? (initAccum = false, value)
: iteratee(accumulator, value, index, collection);
Expand Down
2 changes: 1 addition & 1 deletion _baseSetData.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import metaMap from './_metaMap.js';
* @param {*} data The metadata.
* @returns {Function} Returns `func`.
*/
var baseSetData = !metaMap ? identity : function(func, data) {
var baseSetData = !metaMap ? identity : (func, data) => {
metaMap.set(func, data);
return func;
};
Expand Down
14 changes: 6 additions & 8 deletions _baseSetToString.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ import identity from './identity.js';
* @param {Function} string The `toString` result.
* @returns {Function} Returns `func`.
*/
var baseSetToString = !defineProperty ? identity : function(func, string) {
return defineProperty(func, 'toString', {
'configurable': true,
'enumerable': false,
'value': constant(string),
'writable': true
});
};
var baseSetToString = !defineProperty ? identity : (func, string) => defineProperty(func, 'toString', {
'configurable': true,
'enumerable': false,
'value': constant(string),
'writable': true
});

export default baseSetToString;
2 changes: 1 addition & 1 deletion _baseSome.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import baseEach from './_baseEach.js';
function baseSome(collection, predicate) {
var result;

baseEach(collection, function(value, index, collection) {
baseEach(collection, (value, index, collection) => {
result = predicate(value, index, collection);
return !result;
});
Expand Down
4 changes: 1 addition & 3 deletions _baseToPairs.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ import arrayMap from './_arrayMap.js';
* @returns {Object} Returns the key-value pairs.
*/
function baseToPairs(object, props) {
return arrayMap(props, function(key) {
return [key, object[key]];
});
return arrayMap(props, key => [key, object[key]]);
}

export default baseToPairs;
4 changes: 1 addition & 3 deletions _baseUnary.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
* @returns {Function} Returns the new capped function.
*/
function baseUnary(func) {
return function(value) {
return func(value);
};
return value => func(value);
}

export default baseUnary;
4 changes: 1 addition & 3 deletions _baseValues.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ import arrayMap from './_arrayMap.js';
* @returns {Object} Returns the array of property values.
*/
function baseValues(object, props) {
return arrayMap(props, function(key) {
return object[key];
});
return arrayMap(props, key => object[key]);
}

export default baseValues;
4 changes: 1 addition & 3 deletions _baseWrapperValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ function baseWrapperValue(value, actions) {
if (result instanceof LazyWrapper) {
result = result.value();
}
return arrayReduce(actions, function(result, action) {
return action.func.apply(action.thisArg, arrayPush([result], action.args));
}, result);
return arrayReduce(actions, (result, action) => action.func.apply(action.thisArg, arrayPush([result], action.args)), result);
}

export default baseWrapperValue;
2 changes: 1 addition & 1 deletion _createAggregator.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import isArray from './isArray.js';
* @returns {Function} Returns the new aggregator function.
*/
function createAggregator(setter, initializer) {
return function(collection, iteratee) {
return (collection, iteratee) => {
var func = isArray(collection) ? arrayAggregator : baseAggregator,
accumulator = initializer ? initializer() : {};

Expand Down
2 changes: 1 addition & 1 deletion _createAssigner.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import isIterateeCall from './_isIterateeCall.js';
* @returns {Function} Returns the new assigner function.
*/
function createAssigner(assigner) {
return baseRest(function(object, sources) {
return baseRest((object, sources) => {
var index = -1,
length = sources.length,
customizer = length > 1 ? sources[length - 1] : undefined,
Expand Down
2 changes: 1 addition & 1 deletion _createBaseEach.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import isArrayLike from './isArrayLike.js';
* @returns {Function} Returns the new base function.
*/
function createBaseEach(eachFunc, fromRight) {
return function(collection, iteratee) {
return (collection, iteratee) => {
if (collection == null) {
return collection;
}
Expand Down
2 changes: 1 addition & 1 deletion _createBaseFor.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @returns {Function} Returns the new base function.
*/
function createBaseFor(fromRight) {
return function(object, iteratee, keysFunc) {
return (object, iteratee, keysFunc) => {
var index = -1,
iterable = Object(object),
props = keysFunc(object),
Expand Down
2 changes: 1 addition & 1 deletion _createCaseFirst.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import toString from './toString.js';
* @returns {Function} Returns the new case function.
*/
function createCaseFirst(methodName) {
return function(string) {
return string => {
string = toString(string);

var strSymbols = hasUnicode(string)
Expand Down
4 changes: 1 addition & 3 deletions _createCompounder.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ var reApos = RegExp(rsApos, 'g');
* @returns {Function} Returns the new compounder function.
*/
function createCompounder(callback) {
return function(string) {
return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
};
return string => arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
}

export default createCompounder;
4 changes: 2 additions & 2 deletions _createFind.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import keys from './keys.js';
* @returns {Function} Returns the new find function.
*/
function createFind(findIndexFunc) {
return function(collection, predicate, fromIndex) {
return (collection, predicate, fromIndex) => {
var iterable = Object(collection);
if (!isArrayLike(collection)) {
var iteratee = baseIteratee(predicate, 3);
collection = keys(collection);
predicate = function(key) { return iteratee(iterable[key], key, iterable); };
predicate = key => iteratee(iterable[key], key, iterable);
}
var index = findIndexFunc(collection, predicate, fromIndex);
return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
Expand Down
2 changes: 1 addition & 1 deletion _createFlow.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var WRAP_CURRY_FLAG = 8,
* @returns {Function} Returns the new flow function.
*/
function createFlow(fromRight) {
return flatRest(function(funcs) {
return flatRest(funcs => {
var length = funcs.length,
index = length,
prereq = LodashWrapper.prototype.thru;
Expand Down
4 changes: 1 addition & 3 deletions _createInverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import baseInverter from './_baseInverter.js';
* @returns {Function} Returns the new inverter function.
*/
function createInverter(setter, toIteratee) {
return function(object, iteratee) {
return baseInverter(object, setter, toIteratee(iteratee), {});
};
return (object, iteratee) => baseInverter(object, setter, toIteratee(iteratee), {});
}

export default createInverter;
2 changes: 1 addition & 1 deletion _createMathOperation.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import baseToString from './_baseToString.js';
* @returns {Function} Returns the new mathematical operation function.
*/
function createMathOperation(operator, defaultValue) {
return function(value, other) {
return (value, other) => {
var result;
if (value === undefined && other === undefined) {
return defaultValue;
Expand Down
6 changes: 2 additions & 4 deletions _createOver.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@ import flatRest from './_flatRest.js';
* @returns {Function} Returns the new over function.
*/
function createOver(arrayFunc) {
return flatRest(function(iteratees) {
return flatRest(iteratees => {
iteratees = arrayMap(iteratees, baseUnary(baseIteratee));
return baseRest(function(args) {
var thisArg = this;
return arrayFunc(iteratees, function(iteratee) {
return apply(iteratee, thisArg, args);
});
return arrayFunc(iteratees, iteratee => apply(iteratee, thisArg, args));
});
});
}
Expand Down
2 changes: 1 addition & 1 deletion _createRange.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import toFinite from './toFinite.js';
* @returns {Function} Returns the new range function.
*/
function createRange(fromRight) {
return function(start, end, step) {
return (start, end, step) => {
if (step && typeof step != 'number' && isIterateeCall(start, end, step)) {
end = step = undefined;
}
Expand Down
2 changes: 1 addition & 1 deletion _createRelationalOperation.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import toNumber from './toNumber.js';
* @returns {Function} Returns the new relational operation function.
*/
function createRelationalOperation(operator) {
return function(value, other) {
return (value, other) => {
if (!(typeof value == 'string' && typeof other == 'string')) {
value = toNumber(value);
other = toNumber(other);
Expand Down
2 changes: 1 addition & 1 deletion _createRound.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var nativeMin = Math.min;
*/
function createRound(methodName) {
var func = Math[methodName];
return function(number, precision) {
return (number, precision) => {
number = toNumber(number);
precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
if (precision) {
Expand Down
4 changes: 1 addition & 3 deletions _createSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ var INFINITY = 1 / 0;
* @param {Array} values The values to add to the set.
* @returns {Object} Returns the new set.
*/
var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
return new Set(values);
};
var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : values => new Set(values);

export default createSet;
2 changes: 1 addition & 1 deletion _createToPairs.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var mapTag = '[object Map]',
* @returns {Function} Returns the new pairs function.
*/
function createToPairs(keysFunc) {
return function(object) {
return object => {
var tag = getTag(object);
if (tag == mapTag) {
return mapToArray(object);
Expand Down
4 changes: 2 additions & 2 deletions _defineProperty.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import getNative from './_getNative.js';

var defineProperty = (function() {
var defineProperty = ((() => {
try {
var func = getNative(Object, 'defineProperty');
func({}, '', {});
return func;
} catch (e) {}
}());
})());

export default defineProperty;
2 changes: 1 addition & 1 deletion _equalArrays.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
}
// Recursively compare arrays (susceptible to call stack limits).
if (seen) {
if (!arraySome(other, function(othValue, othIndex) {
if (!arraySome(other, (othValue, othIndex) => {
if (!cacheHas(seen, othIndex) &&
(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
return seen.push(othIndex);
Expand Down
Loading

0 comments on commit 7167d7e

Please sign in to comment.