Apply arrow function transform.

This commit is contained in:
John-David Dalton
2017-01-06 15:41:39 -08:00
parent d461c87979
commit 7167d7e09f
108 changed files with 172 additions and 271 deletions

View File

@@ -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);
}

View File

@@ -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];

View File

@@ -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;

View File

@@ -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;

View File

@@ -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)

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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);

View File

@@ -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;
};

View File

@@ -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;

View File

@@ -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;
});

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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() : {};

View File

@@ -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,

View File

@@ -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;
}

View File

@@ -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),

View File

@@ -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)

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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));
});
});
}

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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) {

View File

@@ -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;

View File

@@ -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);

View File

@@ -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;

View File

@@ -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);

View File

@@ -8,8 +8,6 @@ import noop from './noop.js';
* @param {Function} func The function to query.
* @returns {*} Returns the metadata for `func`.
*/
var getData = !metaMap ? noop : function(func) {
return metaMap.get(func);
};
var getData = !metaMap ? noop : func => metaMap.get(func);
export default getData;

View File

@@ -17,14 +17,12 @@ var nativeGetSymbols = Object.getOwnPropertySymbols;
* @param {Object} object The object to query.
* @returns {Array} Returns the array of symbols.
*/
var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
var getSymbols = !nativeGetSymbols ? stubArray : object => {
if (object == null) {
return [];
}
object = Object(object);
return arrayFilter(nativeGetSymbols(object), function(symbol) {
return propertyIsEnumerable.call(object, symbol);
});
return arrayFilter(nativeGetSymbols(object), symbol => propertyIsEnumerable.call(object, symbol));
};
export default getSymbols;

View File

@@ -13,7 +13,7 @@ var nativeGetSymbols = Object.getOwnPropertySymbols;
* @param {Object} object The object to query.
* @returns {Array} Returns the array of symbols.
*/
var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
var getSymbolsIn = !nativeGetSymbols ? stubArray : object => {
var result = [];
while (object) {
arrayPush(result, getSymbols(object));

View File

@@ -37,7 +37,7 @@ if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
(Promise && getTag(Promise.resolve()) != promiseTag) ||
(Set && getTag(new Set) != setTag) ||
(WeakMap && getTag(new WeakMap) != weakMapTag)) {
getTag = function(value) {
getTag = value => {
var result = baseGetTag(value),
Ctor = result == objectTag ? value.constructor : undefined,
ctorString = Ctor ? toSource(Ctor) : '';

View File

@@ -1,10 +1,10 @@
import coreJsData from './_coreJsData.js';
/** Used to detect methods masquerading as native. */
var maskSrcKey = (function() {
var maskSrcKey = ((() => {
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
return uid ? ('Symbol(src)_1.' + uid) : '';
}());
})());
/**
* Checks if `func` has its source masked.

View File

@@ -9,7 +9,7 @@ function mapToArray(map) {
var index = -1,
result = Array(map.size);
map.forEach(function(value, key) {
map.forEach((value, key) => {
result[++index] = [key, value];
});
return result;

View File

@@ -8,7 +8,7 @@
* @returns {Function} Returns the new spec function.
*/
function matchesStrictComparable(key, srcValue) {
return function(object) {
return object => {
if (object == null) {
return false;
}

View File

@@ -12,7 +12,7 @@ var MAX_MEMOIZE_SIZE = 500;
* @returns {Function} Returns the new memoized function.
*/
function memoizeCapped(func) {
var result = memoize(func, function(key) {
var result = memoize(func, key => {
if (cache.size === MAX_MEMOIZE_SIZE) {
cache.clear();
}

View File

@@ -13,10 +13,10 @@ var moduleExports = freeModule && freeModule.exports === freeExports;
var freeProcess = moduleExports && freeGlobal.process;
/** Used to access faster Node.js helpers. */
var nodeUtil = (function() {
var nodeUtil = ((() => {
try {
return freeProcess && freeProcess.binding && freeProcess.binding('util');
} catch (e) {}
}());
})());
export default nodeUtil;

View File

@@ -7,9 +7,7 @@
* @returns {Function} Returns the new function.
*/
function overArg(func, transform) {
return function(arg) {
return func(transform(arg));
};
return arg => func(transform(arg));
}
export default overArg;

View File

@@ -9,7 +9,7 @@ function setToArray(set) {
var index = -1,
result = Array(set.size);
set.forEach(function(value) {
set.forEach(value => {
result[++index] = value;
});
return result;

View File

@@ -14,12 +14,12 @@ var reEscapeChar = /\\(\\)?/g;
* @param {string} string The string to convert.
* @returns {Array} Returns the property path array.
*/
var stringToPath = memoizeCapped(function(string) {
var stringToPath = memoizeCapped(string => {
var result = [];
if (reLeadingDot.test(string)) {
result.push('');
}
string.replace(rePropName, function(match, number, quote, string) {
string.replace(rePropName, (match, number, quote, string) => {
result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
});
return result;

View File

@@ -34,7 +34,7 @@ var wrapFlags = [
* @returns {Array} Returns `details`.
*/
function updateWrapDetails(details, bitmask) {
arrayEach(wrapFlags, function(pair) {
arrayEach(wrapFlags, pair => {
var value = '_.' + pair[0];
if ((bitmask & pair[1]) && !arrayIncludes(details, value)) {
details.push(value);

4
add.js
View File

@@ -15,8 +15,6 @@ import createMathOperation from './_createMathOperation.js';
* _.add(6, 4);
* // => 10
*/
var add = createMathOperation(function(augend, addend) {
return augend + addend;
}, 0);
var add = createMathOperation((augend, addend) => augend + addend, 0);
export default add;

View File

@@ -33,7 +33,7 @@ import keysIn from './keysIn.js';
* _.assignIn({ 'a': 0 }, new Foo, new Bar);
* // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 }
*/
var assignIn = createAssigner(function(object, source) {
var assignIn = createAssigner((object, source) => {
copyObject(source, keysIn(source), object);
});

View File

@@ -31,7 +31,7 @@ import keysIn from './keysIn.js';
* defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
* // => { 'a': 1, 'b': 2 }
*/
var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
var assignInWith = createAssigner((object, source, srcIndex, customizer) => {
copyObject(source, keysIn(source), object, customizer);
});

View File

@@ -30,7 +30,7 @@ import keys from './keys.js';
* defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
* // => { 'a': 1, 'b': 2 }
*/
var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
var assignWith = createAssigner((object, source, srcIndex, customizer) => {
copyObject(source, keys(source), object, customizer);
});

View File

@@ -24,7 +24,7 @@ import isError from './isError.js';
* elements = [];
* }
*/
var attempt = baseRest(function(func, args) {
var attempt = baseRest((func, args) => {
try {
return apply(func, undefined, args);
} catch (e) {

View File

@@ -42,7 +42,7 @@ var WRAP_BIND_FLAG = 1,
* bound('hi');
* // => 'hi fred!'
*/
var bind = baseRest(function(func, thisArg, partials) {
var bind = baseRest((func, thisArg, partials) => {
var bitmask = WRAP_BIND_FLAG;
if (partials.length) {
var holders = replaceHolders(partials, getHolder(bind));

View File

@@ -30,8 +30,8 @@ import toKey from './_toKey.js';
* jQuery(element).on('click', view.click);
* // => Logs 'clicked docs' when clicked.
*/
var bindAll = flatRest(function(object, methodNames) {
arrayEach(methodNames, function(key) {
var bindAll = flatRest((object, methodNames) => {
arrayEach(methodNames, key => {
key = toKey(key);
baseAssignValue(object, key, bind(object[key], object));
});

View File

@@ -53,7 +53,7 @@ var WRAP_BIND_FLAG = 1,
* bound('hi');
* // => 'hiya fred!'
*/
var bindKey = baseRest(function(object, key, partials) {
var bindKey = baseRest((object, key, partials) => {
var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
if (partials.length) {
var holders = replaceHolders(partials, getHolder(bindKey));

View File

@@ -21,7 +21,7 @@ import createCompounder from './_createCompounder.js';
* _.camelCase('__FOO_BAR__');
* // => 'fooBar'
*/
var camelCase = createCompounder(function(result, word, index) {
var camelCase = createCompounder((result, word, index) => {
word = word.toLowerCase();
return result + (index ? capitalize(word) : word);
});

View File

@@ -39,7 +39,7 @@ function cond(pairs) {
var length = pairs == null ? 0 : pairs.length,
toIteratee = baseIteratee;
pairs = !length ? [] : arrayMap(pairs, function(pair) {
pairs = !length ? [] : arrayMap(pairs, pair => {
if (typeof pair[1] != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}

View File

@@ -18,9 +18,7 @@
* // => true
*/
function constant(value) {
return function() {
return value;
};
return () => value;
}
export default constant;

View File

@@ -29,7 +29,7 @@ var hasOwnProperty = objectProto.hasOwnProperty;
* _.countBy(['one', 'two', 'three'], 'length');
* // => { '3': 2, '5': 1 }
*/
var countBy = createAggregator(function(result, value, key) {
var countBy = createAggregator((result, value, key) => {
if (hasOwnProperty.call(result, key)) {
++result[key];
} else {

View File

@@ -24,7 +24,7 @@ import customDefaultsAssignIn from './_customDefaultsAssignIn.js';
* _.defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 });
* // => { 'a': 1, 'b': 2 }
*/
var defaults = baseRest(function(args) {
var defaults = baseRest(args => {
args.push(undefined, customDefaultsAssignIn);
return apply(assignInWith, undefined, args);
});

View File

@@ -22,7 +22,7 @@ import mergeWith from './mergeWith.js';
* _.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } });
* // => { 'a': { 'b': 2, 'c': 3 } }
*/
var defaultsDeep = baseRest(function(args) {
var defaultsDeep = baseRest(args => {
args.push(undefined, customDefaultsMerge);
return apply(mergeWith, undefined, args);
});

View File

@@ -19,8 +19,6 @@ import baseRest from './_baseRest.js';
* }, 'deferred');
* // => Logs 'deferred' after one millisecond.
*/
var defer = baseRest(function(func, args) {
return baseDelay(func, 1, args);
});
var defer = baseRest((func, args) => baseDelay(func, 1, args));
export default defer;

View File

@@ -21,8 +21,6 @@ import toNumber from './toNumber.js';
* }, 1000, 'later');
* // => Logs 'later' after one second.
*/
var delay = baseRest(function(func, wait, args) {
return baseDelay(func, toNumber(wait) || 0, args);
});
var delay = baseRest((func, wait, args) => baseDelay(func, toNumber(wait) || 0, args));
export default delay;

View File

@@ -24,10 +24,8 @@ import isArrayLikeObject from './isArrayLikeObject.js';
* _.difference([2, 1], [2, 3]);
* // => [1]
*/
var difference = baseRest(function(array, values) {
return isArrayLikeObject(array)
? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
: [];
});
var difference = baseRest((array, values) => isArrayLikeObject(array)
? baseDifference(array, baseFlatten(values, 1, isArrayLikeObject, true))
: []);
export default difference;

View File

@@ -31,7 +31,7 @@ import last from './last.js';
* _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
* // => [{ 'x': 2 }]
*/
var differenceBy = baseRest(function(array, values) {
var differenceBy = baseRest((array, values) => {
var iteratee = last(values);
if (isArrayLikeObject(iteratee)) {
iteratee = undefined;

View File

@@ -27,7 +27,7 @@ import last from './last.js';
* _.differenceWith(objects, [{ 'x': 1, 'y': 2 }], _.isEqual);
* // => [{ 'x': 2, 'y': 1 }]
*/
var differenceWith = baseRest(function(array, values) {
var differenceWith = baseRest((array, values) => {
var comparator = last(values);
if (isArrayLikeObject(comparator)) {
comparator = undefined;

View File

@@ -15,8 +15,6 @@ import createMathOperation from './_createMathOperation.js';
* _.divide(6, 4);
* // => 1.5
*/
var divide = createMathOperation(function(dividend, divisor) {
return dividend / divisor;
}, 1);
var divide = createMathOperation((dividend, divisor) => dividend / divisor, 1);
export default divide;

View File

@@ -30,7 +30,7 @@ var hasOwnProperty = objectProto.hasOwnProperty;
* _.groupBy(['one', 'two', 'three'], 'length');
* // => { '3': ['one', 'two'], '5': ['three'] }
*/
var groupBy = createAggregator(function(result, value, key) {
var groupBy = createAggregator((result, value, key) => {
if (hasOwnProperty.call(result, key)) {
result[key].push(value);
} else {

4
gte.js
View File

@@ -23,8 +23,6 @@ import createRelationalOperation from './_createRelationalOperation.js';
* _.gte(1, 3);
* // => false
*/
var gte = createRelationalOperation(function(value, other) {
return value >= other;
});
var gte = createRelationalOperation((value, other) => value >= other);
export default gte;

View File

@@ -20,7 +20,7 @@ import castArrayLikeObject from './_castArrayLikeObject.js';
* _.intersection([2, 1], [2, 3]);
* // => [2]
*/
var intersection = baseRest(function(arrays) {
var intersection = baseRest(arrays => {
var mapped = arrayMap(arrays, castArrayLikeObject);
return (mapped.length && mapped[0] === arrays[0])
? baseIntersection(mapped)

View File

@@ -28,7 +28,7 @@ import last from './last.js';
* _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
* // => [{ 'x': 1 }]
*/
var intersectionBy = baseRest(function(arrays) {
var intersectionBy = baseRest(arrays => {
var iteratee = last(arrays),
mapped = arrayMap(arrays, castArrayLikeObject);

View File

@@ -25,7 +25,7 @@ import last from './last.js';
* _.intersectionWith(objects, others, _.isEqual);
* // => [{ 'x': 1, 'y': 2 }]
*/
var intersectionWith = baseRest(function(arrays) {
var intersectionWith = baseRest(arrays => {
var comparator = last(arrays),
mapped = arrayMap(arrays, castArrayLikeObject);

View File

@@ -20,7 +20,7 @@ import identity from './identity.js';
* _.invert(object);
* // => { '1': 'c', '2': 'b' }
*/
var invert = createInverter(function(result, value, key) {
var invert = createInverter((result, value, key) => {
result[value] = key;
}, constant(identity));

View File

@@ -33,7 +33,7 @@ var hasOwnProperty = objectProto.hasOwnProperty;
* });
* // => { 'group1': ['a', 'c'], 'group2': ['b'] }
*/
var invertBy = createInverter(function(result, value, key) {
var invertBy = createInverter((result, value, key) => {
if (hasOwnProperty.call(result, value)) {
result[value].push(key);
} else {

View File

@@ -27,12 +27,12 @@ import isArrayLike from './isArrayLike.js';
* _.invokeMap([123, 456], String.prototype.split, '');
* // => [['1', '2', '3'], ['4', '5', '6']]
*/
var invokeMap = baseRest(function(collection, path, args) {
var invokeMap = baseRest((collection, path, args) => {
var index = -1,
isFunc = typeof path == 'function',
result = isArrayLike(collection) ? Array(collection.length) : [];
baseEach(collection, function(value) {
baseEach(collection, value => {
result[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
});
return result;

View File

@@ -28,9 +28,7 @@ var propertyIsEnumerable = objectProto.propertyIsEnumerable;
* _.isArguments([1, 2, 3]);
* // => false
*/
var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
!propertyIsEnumerable.call(value, 'callee');
};
var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : value => isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
!propertyIsEnumerable.call(value, 'callee');
export default isArguments;

View File

@@ -21,8 +21,6 @@ import createCompounder from './_createCompounder.js';
* _.kebabCase('__FOO_BAR__');
* // => 'foo-bar'
*/
var kebabCase = createCompounder(function(result, word, index) {
return result + (index ? '-' : '') + word.toLowerCase();
});
var kebabCase = createCompounder((result, word, index) => result + (index ? '-' : '') + word.toLowerCase());
export default kebabCase;

View File

@@ -29,7 +29,7 @@ import createAggregator from './_createAggregator.js';
* _.keyBy(array, 'dir');
* // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
*/
var keyBy = createAggregator(function(result, value, key) {
var keyBy = createAggregator((result, value, key) => {
baseAssignValue(result, key, value);
});

View File

@@ -72,22 +72,20 @@ var nativeMax = Math.max,
nativeMin = Math.min;
// wrap `_.mixin` so it works when provided only one argument
var mixin = (function(func) {
return function(object, source, options) {
if (options == null) {
var isObj = isObject(source),
props = isObj && keys(source),
methodNames = props && props.length && baseFunctions(source, props);
var mixin = ((func => function(object, source, options) {
if (options == null) {
var isObj = isObject(source),
props = isObj && keys(source),
methodNames = props && props.length && baseFunctions(source, props);
if (!(methodNames ? methodNames.length : isObj)) {
options = source;
source = object;
object = this;
}
if (!(methodNames ? methodNames.length : isObj)) {
options = source;
source = object;
object = this;
}
return func(object, source, options);
};
}(_mixin));
}
return func(object, source, options);
})(_mixin));
// Add methods that return wrapped values in chain sequences.
lodash.after = func.after;
@@ -403,15 +401,15 @@ lodash.each = collection.forEach;
lodash.eachRight = collection.forEachRight;
lodash.first = array.head;
mixin(lodash, (function() {
mixin(lodash, ((() => {
var source = {};
baseForOwn(lodash, function(func, methodName) {
baseForOwn(lodash, (func, methodName) => {
if (!hasOwnProperty.call(lodash.prototype, methodName)) {
source[methodName] = func;
}
});
return source;
}()), { 'chain': false });
})()), { 'chain': false });
/**
* The semantic version number.
@@ -424,12 +422,12 @@ lodash.VERSION = VERSION;
(lodash.templateSettings = string.templateSettings).imports._ = lodash;
// Assign default placeholders.
arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], function(methodName) {
arrayEach(['bind', 'bindKey', 'curry', 'curryRight', 'partial', 'partialRight'], methodName => {
lodash[methodName].placeholder = lodash;
});
// Add `LazyWrapper` methods for `_.drop` and `_.take` variants.
arrayEach(['drop', 'take'], function(methodName, index) {
arrayEach(['drop', 'take'], (methodName, index) => {
LazyWrapper.prototype[methodName] = function(n) {
n = n === undefined ? 1 : nativeMax(toInteger(n), 0);
@@ -454,7 +452,7 @@ arrayEach(['drop', 'take'], function(methodName, index) {
});
// Add `LazyWrapper` methods that accept an `iteratee` value.
arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
arrayEach(['filter', 'map', 'takeWhile'], (methodName, index) => {
var type = index + 1,
isFilter = type == LAZY_FILTER_FLAG || type == LAZY_WHILE_FLAG;
@@ -470,7 +468,7 @@ arrayEach(['filter', 'map', 'takeWhile'], function(methodName, index) {
});
// Add `LazyWrapper` methods for `_.head` and `_.last`.
arrayEach(['head', 'last'], function(methodName, index) {
arrayEach(['head', 'last'], (methodName, index) => {
var takeName = 'take' + (index ? 'Right' : '');
LazyWrapper.prototype[methodName] = function() {
@@ -479,7 +477,7 @@ arrayEach(['head', 'last'], function(methodName, index) {
});
// Add `LazyWrapper` methods for `_.initial` and `_.tail`.
arrayEach(['initial', 'tail'], function(methodName, index) {
arrayEach(['initial', 'tail'], (methodName, index) => {
var dropName = 'drop' + (index ? '' : 'Right');
LazyWrapper.prototype[methodName] = function() {
@@ -503,9 +501,7 @@ LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
if (typeof path == 'function') {
return new LazyWrapper(this);
}
return this.map(function(value) {
return baseInvoke(value, path, args);
});
return this.map(value => baseInvoke(value, path, args));
});
LazyWrapper.prototype.reject = function(predicate) {
@@ -540,7 +536,7 @@ LazyWrapper.prototype.toArray = function() {
};
// Add `LazyWrapper` methods to `lodash.prototype`.
baseForOwn(LazyWrapper.prototype, function(func, methodName) {
baseForOwn(LazyWrapper.prototype, (func, methodName) => {
var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName),
isTaker = /^(?:head|last)$/.test(methodName),
lodashFunc = lodash[isTaker ? ('take' + (methodName == 'last' ? 'Right' : '')) : methodName],
@@ -556,7 +552,7 @@ baseForOwn(LazyWrapper.prototype, function(func, methodName) {
iteratee = args[0],
useLazy = isLazy || isArray(value);
var interceptor = function(value) {
var interceptor = value => {
var result = lodashFunc.apply(lodash, arrayPush([value], args));
return (isTaker && chainAll) ? result[0] : result;
};
@@ -585,7 +581,7 @@ baseForOwn(LazyWrapper.prototype, function(func, methodName) {
});
// Add `Array` methods to `lodash.prototype`.
arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {
arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], methodName => {
var func = arrayProto[methodName],
chainName = /^(?:push|sort|unshift)$/.test(methodName) ? 'tap' : 'thru',
retUnwrapped = /^(?:pop|shift)$/.test(methodName);
@@ -596,14 +592,12 @@ arrayEach(['pop', 'push', 'shift', 'sort', 'splice', 'unshift'], function(method
var value = this.value();
return func.apply(isArray(value) ? value : [], args);
}
return this[chainName](function(value) {
return func.apply(isArray(value) ? value : [], args);
});
return this[chainName](value => func.apply(isArray(value) ? value : [], args));
};
});
// Map minified method names to their real names.
baseForOwn(LazyWrapper.prototype, function(func, methodName) {
baseForOwn(LazyWrapper.prototype, (func, methodName) => {
var lodashFunc = lodash[methodName];
if (lodashFunc) {
var key = (lodashFunc.name + ''),

View File

@@ -20,8 +20,6 @@ import createCompounder from './_createCompounder.js';
* _.lowerCase('__FOO_BAR__');
* // => 'foo bar'
*/
var lowerCase = createCompounder(function(result, word, index) {
return result + (index ? ' ' : '') + word.toLowerCase();
});
var lowerCase = createCompounder((result, word, index) => result + (index ? ' ' : '') + word.toLowerCase());
export default lowerCase;

4
lte.js
View File

@@ -23,8 +23,6 @@ import createRelationalOperation from './_createRelationalOperation.js';
* _.lte(3, 1);
* // => false
*/
var lte = createRelationalOperation(function(value, other) {
return value <= other;
});
var lte = createRelationalOperation((value, other) => value <= other);
export default lte;

View File

@@ -27,7 +27,7 @@ function mapKeys(object, iteratee) {
var result = {};
iteratee = baseIteratee(iteratee, 3);
baseForOwn(object, function(value, key, object) {
baseForOwn(object, (value, key, object) => {
baseAssignValue(result, iteratee(value, key, object), value);
});
return result;

View File

@@ -34,7 +34,7 @@ function mapValues(object, iteratee) {
var result = {};
iteratee = baseIteratee(iteratee, 3);
baseForOwn(object, function(value, key, object) {
baseForOwn(object, (value, key, object) => {
baseAssignValue(result, key, iteratee(value, key, object));
});
return result;

View File

@@ -32,7 +32,7 @@ import createAssigner from './_createAssigner.js';
* _.merge(object, other);
* // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
*/
var merge = createAssigner(function(object, source, srcIndex) {
var merge = createAssigner((object, source, srcIndex) => {
baseMerge(object, source, srcIndex);
});

View File

@@ -32,7 +32,7 @@ import createAssigner from './_createAssigner.js';
* _.mergeWith(object, other, customizer);
* // => { 'a': [1, 3], 'b': [2, 4] }
*/
var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
var mergeWith = createAssigner((object, source, srcIndex, customizer) => {
baseMerge(object, source, srcIndex, customizer);
});

View File

@@ -25,10 +25,6 @@ import baseRest from './_baseRest.js';
* _.map(objects, _.method(['a', 'b']));
* // => [2, 1]
*/
var method = baseRest(function(path, args) {
return function(object) {
return baseInvoke(object, path, args);
};
});
var method = baseRest((path, args) => object => baseInvoke(object, path, args));
export default method;

View File

@@ -24,10 +24,6 @@ import baseRest from './_baseRest.js';
* _.map([['a', '2'], ['c', '0']], _.methodOf(object));
* // => [2, 0]
*/
var methodOf = baseRest(function(object, args) {
return function(path) {
return baseInvoke(object, path, args);
};
});
var methodOf = baseRest((object, args) => path => baseInvoke(object, path, args));
export default methodOf;

View File

@@ -15,8 +15,6 @@ import createMathOperation from './_createMathOperation.js';
* _.multiply(6, 4);
* // => 24
*/
var multiply = createMathOperation(function(multiplier, multiplicand) {
return multiplier * multiplicand;
}, 1);
var multiply = createMathOperation((multiplier, multiplicand) => multiplier * multiplicand, 1);
export default multiply;

4
now.js
View File

@@ -16,8 +16,6 @@ import root from './_root.js';
* }, _.now());
* // => Logs the number of milliseconds it took for the deferred invocation.
*/
var now = function() {
return root.Date.now();
};
var now = () => root.Date.now();
export default now;

View File

@@ -24,9 +24,7 @@ import toInteger from './toInteger.js';
*/
function nthArg(n) {
n = toInteger(n);
return baseRest(function(args) {
return baseNth(args, n);
});
return baseRest(args => baseNth(args, n));
}
export default nthArg;

View File

@@ -41,7 +41,7 @@ var nativeMin = Math.min;
* func(10, 5);
* // => [100, 10]
*/
var overArgs = castRest(function(func, transforms) {
var overArgs = castRest((func, transforms) => {
transforms = (transforms.length == 1 && isArray(transforms[0]))
? arrayMap(transforms[0], baseUnary(baseIteratee))
: arrayMap(baseFlatten(transforms, 1), baseUnary(baseIteratee));

View File

@@ -18,8 +18,6 @@ import flatRest from './_flatRest.js';
* _.pick(object, ['a', 'c']);
* // => { 'a': 1, 'c': 3 }
*/
var pick = flatRest(function(object, paths) {
return object == null ? {} : basePick(object, paths);
});
var pick = flatRest((object, paths) => object == null ? {} : basePick(object, paths));
export default pick;

View File

@@ -25,13 +25,9 @@ function pickBy(object, predicate) {
if (object == null) {
return {};
}
var props = arrayMap(getAllKeysIn(object), function(prop) {
return [prop];
});
var props = arrayMap(getAllKeysIn(object), prop => [prop]);
predicate = baseIteratee(predicate);
return basePickBy(object, props, function(value, path) {
return predicate(value, path[0]);
});
return basePickBy(object, props, (value, path) => predicate(value, path[0]));
}
export default pickBy;

View File

@@ -22,9 +22,7 @@ import baseGet from './_baseGet.js';
* // => [2, 0]
*/
function propertyOf(object) {
return function(path) {
return object == null ? undefined : baseGet(object, path);
};
return path => object == null ? undefined : baseGet(object, path);
}
export default propertyOf;

View File

@@ -29,13 +29,11 @@ import isIndex from './_isIndex.js';
* console.log(pulled);
* // => ['b', 'd']
*/
var pullAt = flatRest(function(array, indexes) {
var pullAt = flatRest((array, indexes) => {
var length = array == null ? 0 : array.length,
result = baseAt(array, indexes);
basePullAt(array, arrayMap(indexes, function(index) {
return isIndex(index, length) ? +index : index;
}).sort(compareAscending));
basePullAt(array, arrayMap(indexes, index => isIndex(index, length) ? +index : index).sort(compareAscending));
return result;
});

View File

@@ -26,8 +26,6 @@ var WRAP_REARG_FLAG = 256;
* rearged('b', 'c', 'a')
* // => ['a', 'b', 'c']
*/
var rearg = flatRest(function(func, indexes) {
return createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes);
});
var rearg = flatRest((func, indexes) => createWrap(func, WRAP_REARG_FLAG, undefined, undefined, undefined, indexes));
export default rearg;

View File

@@ -21,8 +21,8 @@ import createCompounder from './_createCompounder.js';
* _.snakeCase('--FOO-BAR--');
* // => 'foo_bar'
*/
var snakeCase = createCompounder(function(result, word, index) {
return result + (index ? '_' : '') + word.toLowerCase();
});
const snakeCase = createCompounder((result, word, index) =>
result + (index ? '_' : '') + word.toLowerCase()
);
export default snakeCase;

View File

@@ -22,8 +22,6 @@ import upperFirst from './upperFirst.js';
* _.startCase('__FOO_BAR__');
* // => 'FOO BAR'
*/
var startCase = createCompounder(function(result, word, index) {
return result + (index ? ' ' : '') + upperFirst(word);
});
var startCase = createCompounder((result, word, index) => result + (index ? ' ' : '') + upperFirst(word));
export default startCase;

Some files were not shown because too many files have changed in this diff Show More