import Stack from './_Stack.js';import arrayEach from './_arrayEach.js';import assignValue from './_assignValue.js';import baseAssign from './_baseAssign.js';import cloneBuffer from './_cloneBuffer.js';import copyArray from './_copyArray.js';import copySymbols from './_copySymbols.js';import getAllKeys from './_getAllKeys.js';import getTag from './_getTag.js';import initCloneArray from './_initCloneArray.js';import initCloneByTag from './_initCloneByTag.js';import initCloneObject from './_initCloneObject.js';import isArray from './isArray.js';import isBuffer from './isBuffer.js';import isObject from './isObject.js';import keys from './keys.js';
var argsTag = '[object Arguments]', arrayTag = '[object Array]', boolTag = '[object Boolean]', dateTag = '[object Date]', errorTag = '[object Error]', funcTag = '[object Function]', genTag = '[object GeneratorFunction]', mapTag = '[object Map]', numberTag = '[object Number]', objectTag = '[object Object]', regexpTag = '[object RegExp]', setTag = '[object Set]', stringTag = '[object String]', symbolTag = '[object Symbol]', weakMapTag = '[object WeakMap]';
var arrayBufferTag = '[object ArrayBuffer]', dataViewTag = '[object DataView]', float32Tag = '[object Float32Array]', float64Tag = '[object Float64Array]', int8Tag = '[object Int8Array]', int16Tag = '[object Int16Array]', int32Tag = '[object Int32Array]', uint8Tag = '[object Uint8Array]', uint8ClampedTag = '[object Uint8ClampedArray]', uint16Tag = '[object Uint16Array]', uint32Tag = '[object Uint32Array]';
var cloneableTags = {};cloneableTags[argsTag] = cloneableTags[arrayTag] =cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =cloneableTags[boolTag] = cloneableTags[dateTag] =cloneableTags[float32Tag] = cloneableTags[float64Tag] =cloneableTags[int8Tag] = cloneableTags[int16Tag] =cloneableTags[int32Tag] = cloneableTags[mapTag] =cloneableTags[numberTag] = cloneableTags[objectTag] =cloneableTags[regexpTag] = cloneableTags[setTag] =cloneableTags[stringTag] = cloneableTags[symbolTag] =cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;cloneableTags[errorTag] = cloneableTags[funcTag] =cloneableTags[weakMapTag] = false;
function baseClone(value, isDeep, isFull, customizer, key, object, stack) { var result; if (customizer) { result = object ? customizer(value, key, object, stack) : customizer(value); } if (result !== undefined) { return result; } if (!isObject(value)) { return value; } var isArr = isArray(value); if (isArr) { result = initCloneArray(value); if (!isDeep) { return copyArray(value, result); } } else { var tag = getTag(value), isFunc = tag == funcTag || tag == genTag;
if (isBuffer(value)) { return cloneBuffer(value, isDeep); } if (tag == objectTag || tag == argsTag || (isFunc && !object)) { result = initCloneObject(isFunc ? {} : value); if (!isDeep) { return copySymbols(value, baseAssign(result, value)); } } else { if (!cloneableTags[tag]) { return object ? value : {}; } result = initCloneByTag(value, tag, baseClone, isDeep); } } stack || (stack = new Stack); var stacked = stack.get(value); if (stacked) { return stacked; } stack.set(value, result);
var props = isArr ? undefined : (isFull ? getAllKeys : keys)(value); arrayEach(props || value, function(subValue, key) { if (props) { key = subValue; subValue = value[key]; } assignValue(result, key, baseClone(subValue, isDeep, isFull, customizer, key, value, stack)); }); return result;}
export default baseClone;