mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-03 16:47:49 +00:00
Remove more creator modules.
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
import isIterateeCall from './.internal/isIterateeCall.js';
|
||||
|
||||
/**
|
||||
* Creates a function like `assign`.
|
||||
*
|
||||
* @private
|
||||
* @param {Function} assigner The function to assign values.
|
||||
* @returns {Function} Returns the new assigner function.
|
||||
*/
|
||||
function createAssigner(assigner) {
|
||||
return (object, ...sources) => {
|
||||
let index = -1;
|
||||
let length = sources.length;
|
||||
let customizer = length > 1 ? sources[length - 1] : undefined;
|
||||
const guard = length > 2 ? sources[2] : undefined;
|
||||
|
||||
customizer = (assigner.length > 3 && typeof customizer == 'function')
|
||||
? (length--, customizer)
|
||||
: undefined;
|
||||
|
||||
if (guard && isIterateeCall(sources[0], sources[1], guard)) {
|
||||
customizer = length < 3 ? undefined : customizer;
|
||||
length = 1;
|
||||
}
|
||||
object = Object(object);
|
||||
while (++index < length) {
|
||||
const source = sources[index];
|
||||
if (source) {
|
||||
assigner(object, source, index, customizer);
|
||||
}
|
||||
}
|
||||
return object;
|
||||
};
|
||||
}
|
||||
|
||||
export default createAssigner;
|
||||
@@ -1,32 +0,0 @@
|
||||
import isArrayLike from './isArrayLike.js';
|
||||
|
||||
/**
|
||||
* Creates a `baseEach` or `baseEachRight` function.
|
||||
*
|
||||
* @private
|
||||
* @param {Function} eachFunc The function to iterate over a collection.
|
||||
* @param {boolean} [fromRight] Specify iterating from right to left.
|
||||
* @returns {Function} Returns the new base function.
|
||||
*/
|
||||
function createBaseEach(eachFunc, fromRight) {
|
||||
return (collection, iteratee) => {
|
||||
if (collection == null) {
|
||||
return collection;
|
||||
}
|
||||
if (!isArrayLike(collection)) {
|
||||
return eachFunc(collection, iteratee);
|
||||
}
|
||||
const length = collection.length;
|
||||
const iterable = Object(collection);
|
||||
let index = fromRight ? length : -1;
|
||||
|
||||
while ((fromRight ? index-- : ++index < length)) {
|
||||
if (iteratee(iterable[index], index, iterable) === false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return collection;
|
||||
};
|
||||
}
|
||||
|
||||
export default createBaseEach;
|
||||
@@ -1,26 +0,0 @@
|
||||
/**
|
||||
* Creates a base function for methods like `forIn` and `forOwn`.
|
||||
*
|
||||
* @private
|
||||
* @param {boolean} [fromRight] Specify iterating from right to left.
|
||||
* @returns {Function} Returns the new base function.
|
||||
*/
|
||||
function createBaseFor(fromRight) {
|
||||
return (object, iteratee, keysFunc) => {
|
||||
const iterable = Object(object);
|
||||
const props = keysFunc(object);
|
||||
|
||||
let index = -1;
|
||||
let length = props.length;
|
||||
|
||||
while (length--) {
|
||||
const key = props[fromRight ? length : ++index];
|
||||
if (iteratee(iterable[key], key, iterable) === false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return object;
|
||||
};
|
||||
}
|
||||
|
||||
export default createBaseFor;
|
||||
@@ -1,24 +0,0 @@
|
||||
import isArrayLike from './isArrayLike.js';
|
||||
import keys from './keys.js';
|
||||
|
||||
/**
|
||||
* Creates a `find` or `findLast` function.
|
||||
*
|
||||
* @private
|
||||
* @param {Function} findIndexFunc The function to find the collection index.
|
||||
* @returns {Function} Returns the new find function.
|
||||
*/
|
||||
function createFind(findIndexFunc) {
|
||||
return (collection, predicate, fromIndex) => {
|
||||
let iteratee;
|
||||
const iterable = Object(collection);
|
||||
if (!isArrayLike(collection)) {
|
||||
collection = keys(collection);
|
||||
predicate = key => iteratee(iterable[key], key, iterable);
|
||||
}
|
||||
const index = findIndexFunc(collection, predicate, fromIndex);
|
||||
return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
|
||||
};
|
||||
}
|
||||
|
||||
export default createFind;
|
||||
Reference in New Issue
Block a user