mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-03 08:37:49 +00:00
Move internal modules to “internal” folder.
This commit is contained in:
22
.internal/cloneMap.js
Normal file
22
.internal/cloneMap.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import addMapEntry from './.internal/addMapEntry.js';
|
||||
import arrayReduce from './.internal/arrayReduce.js';
|
||||
import mapToArray from './.internal/mapToArray.js';
|
||||
|
||||
/** Used to compose bitmasks for cloning. */
|
||||
const CLONE_DEEP_FLAG = 1;
|
||||
|
||||
/**
|
||||
* Creates a clone of `map`.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} map The map to clone.
|
||||
* @param {Function} cloneFunc The function to clone values.
|
||||
* @param {boolean} [isDeep] Specify a deep clone.
|
||||
* @returns {Object} Returns the cloned map.
|
||||
*/
|
||||
function cloneMap(map, isDeep, cloneFunc) {
|
||||
const array = isDeep ? cloneFunc(mapToArray(map), CLONE_DEEP_FLAG) : mapToArray(map);
|
||||
return arrayReduce(array, addMapEntry, new map.constructor);
|
||||
}
|
||||
|
||||
export default cloneMap;
|
||||
Reference in New Issue
Block a user