mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-05 09:27:49 +00:00
Remove semicolons.
This commit is contained in:
@@ -1,67 +1,67 @@
|
||||
import Stack from './Stack.js';
|
||||
import arrayEach from './arrayEach.js';
|
||||
import assignValue from './assignValue.js';
|
||||
import baseAssign from './baseAssign.js';
|
||||
import baseAssignIn from './baseAssignIn.js';
|
||||
import baseCreate from './baseCreate.js';
|
||||
import cloneBuffer from './cloneBuffer.js';
|
||||
import copyArray from './copyArray.js';
|
||||
import cloneArrayBuffer from './cloneArrayBuffer.js';
|
||||
import cloneDataView from './cloneDataView.js';
|
||||
import cloneMap from './cloneMap.js';
|
||||
import cloneRegExp from './cloneRegExp.js';
|
||||
import cloneSet from './cloneSet.js';
|
||||
import cloneSymbol from './cloneSymbol.js';
|
||||
import cloneTypedArray from './cloneTypedArray.js';
|
||||
import copySymbols from './copySymbols.js';
|
||||
import copySymbolsIn from './copySymbolsIn.js';
|
||||
import getAllKeys from './getAllKeys.js';
|
||||
import getAllKeysIn from './getAllKeysIn.js';
|
||||
import getTag from './getTag.js';
|
||||
import initCloneArray from './initCloneArray.js';
|
||||
import initCloneByTag from './initCloneByTag.js';
|
||||
import initCloneObject from './initCloneObject.js';
|
||||
import isBuffer from '../isBuffer.js';
|
||||
import isObject from '../isObject.js';
|
||||
import isPrototype from './isPrototype.js';
|
||||
import keys from '../keys.js';
|
||||
import Stack from './Stack.js'
|
||||
import arrayEach from './arrayEach.js'
|
||||
import assignValue from './assignValue.js'
|
||||
import baseAssign from './baseAssign.js'
|
||||
import baseAssignIn from './baseAssignIn.js'
|
||||
import baseCreate from './baseCreate.js'
|
||||
import cloneBuffer from './cloneBuffer.js'
|
||||
import copyArray from './copyArray.js'
|
||||
import cloneArrayBuffer from './cloneArrayBuffer.js'
|
||||
import cloneDataView from './cloneDataView.js'
|
||||
import cloneMap from './cloneMap.js'
|
||||
import cloneRegExp from './cloneRegExp.js'
|
||||
import cloneSet from './cloneSet.js'
|
||||
import cloneSymbol from './cloneSymbol.js'
|
||||
import cloneTypedArray from './cloneTypedArray.js'
|
||||
import copySymbols from './copySymbols.js'
|
||||
import copySymbolsIn from './copySymbolsIn.js'
|
||||
import getAllKeys from './getAllKeys.js'
|
||||
import getAllKeysIn from './getAllKeysIn.js'
|
||||
import getTag from './getTag.js'
|
||||
import initCloneArray from './initCloneArray.js'
|
||||
import initCloneByTag from './initCloneByTag.js'
|
||||
import initCloneObject from './initCloneObject.js'
|
||||
import isBuffer from '../isBuffer.js'
|
||||
import isObject from '../isObject.js'
|
||||
import isPrototype from './isPrototype.js'
|
||||
import keys from '../keys.js'
|
||||
|
||||
/** Used to compose bitmasks for cloning. */
|
||||
const CLONE_DEEP_FLAG = 1;
|
||||
const CLONE_FLAT_FLAG = 2;
|
||||
const CLONE_SYMBOLS_FLAG = 4;
|
||||
const CLONE_DEEP_FLAG = 1
|
||||
const CLONE_FLAT_FLAG = 2
|
||||
const CLONE_SYMBOLS_FLAG = 4
|
||||
|
||||
/** `Object#toString` result references. */
|
||||
const argsTag = '[object Arguments]';
|
||||
const arrayTag = '[object Array]';
|
||||
const boolTag = '[object Boolean]';
|
||||
const dateTag = '[object Date]';
|
||||
const errorTag = '[object Error]';
|
||||
const funcTag = '[object Function]';
|
||||
const genTag = '[object GeneratorFunction]';
|
||||
const mapTag = '[object Map]';
|
||||
const numberTag = '[object Number]';
|
||||
const objectTag = '[object Object]';
|
||||
const regexpTag = '[object RegExp]';
|
||||
const setTag = '[object Set]';
|
||||
const stringTag = '[object String]';
|
||||
const symbolTag = '[object Symbol]';
|
||||
const weakMapTag = '[object WeakMap]';
|
||||
const argsTag = '[object Arguments]'
|
||||
const arrayTag = '[object Array]'
|
||||
const boolTag = '[object Boolean]'
|
||||
const dateTag = '[object Date]'
|
||||
const errorTag = '[object Error]'
|
||||
const funcTag = '[object Function]'
|
||||
const genTag = '[object GeneratorFunction]'
|
||||
const mapTag = '[object Map]'
|
||||
const numberTag = '[object Number]'
|
||||
const objectTag = '[object Object]'
|
||||
const regexpTag = '[object RegExp]'
|
||||
const setTag = '[object Set]'
|
||||
const stringTag = '[object String]'
|
||||
const symbolTag = '[object Symbol]'
|
||||
const weakMapTag = '[object WeakMap]'
|
||||
|
||||
const arrayBufferTag = '[object ArrayBuffer]';
|
||||
const dataViewTag = '[object DataView]';
|
||||
const float32Tag = '[object Float32Array]';
|
||||
const float64Tag = '[object Float64Array]';
|
||||
const int8Tag = '[object Int8Array]';
|
||||
const int16Tag = '[object Int16Array]';
|
||||
const int32Tag = '[object Int32Array]';
|
||||
const uint8Tag = '[object Uint8Array]';
|
||||
const uint8ClampedTag = '[object Uint8ClampedArray]';
|
||||
const uint16Tag = '[object Uint16Array]';
|
||||
const uint32Tag = '[object Uint32Array]';
|
||||
const arrayBufferTag = '[object ArrayBuffer]'
|
||||
const dataViewTag = '[object DataView]'
|
||||
const float32Tag = '[object Float32Array]'
|
||||
const float64Tag = '[object Float64Array]'
|
||||
const int8Tag = '[object Int8Array]'
|
||||
const int16Tag = '[object Int16Array]'
|
||||
const int32Tag = '[object Int32Array]'
|
||||
const uint8Tag = '[object Uint8Array]'
|
||||
const uint8ClampedTag = '[object Uint8ClampedArray]'
|
||||
const uint16Tag = '[object Uint16Array]'
|
||||
const uint32Tag = '[object Uint32Array]'
|
||||
|
||||
/** Used to identify `toStringTag` values supported by `clone`. */
|
||||
const cloneableTags = {};
|
||||
const cloneableTags = {}
|
||||
cloneableTags[argsTag] = cloneableTags[arrayTag] =
|
||||
cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] =
|
||||
cloneableTags[boolTag] = cloneableTags[dateTag] =
|
||||
@@ -72,12 +72,12 @@ cloneableTags[numberTag] = cloneableTags[objectTag] =
|
||||
cloneableTags[regexpTag] = cloneableTags[setTag] =
|
||||
cloneableTags[stringTag] = cloneableTags[symbolTag] =
|
||||
cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] =
|
||||
cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
|
||||
cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true
|
||||
cloneableTags[errorTag] = cloneableTags[funcTag] =
|
||||
cloneableTags[weakMapTag] = false;
|
||||
cloneableTags[weakMapTag] = false
|
||||
|
||||
/** Used to check objects for own properties. */
|
||||
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
const hasOwnProperty = Object.prototype.hasOwnProperty
|
||||
|
||||
/**
|
||||
* Initializes an object clone.
|
||||
@@ -89,7 +89,7 @@ const hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
function initCloneObject(object) {
|
||||
return (typeof object.constructor == 'function' && !isPrototype(object))
|
||||
? baseCreate(Object.getPrototypeOf(object))
|
||||
: {};
|
||||
: {}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,38 +106,38 @@ function initCloneObject(object) {
|
||||
* @returns {Object} Returns the initialized clone.
|
||||
*/
|
||||
function initCloneByTag(object, tag, cloneFunc, isDeep) {
|
||||
const Ctor = object.constructor;
|
||||
const Ctor = object.constructor
|
||||
switch (tag) {
|
||||
case arrayBufferTag:
|
||||
return cloneArrayBuffer(object);
|
||||
return cloneArrayBuffer(object)
|
||||
|
||||
case boolTag:
|
||||
case dateTag:
|
||||
return new Ctor(+object);
|
||||
return new Ctor(+object)
|
||||
|
||||
case dataViewTag:
|
||||
return cloneDataView(object, isDeep);
|
||||
return cloneDataView(object, isDeep)
|
||||
|
||||
case float32Tag: case float64Tag:
|
||||
case int8Tag: case int16Tag: case int32Tag:
|
||||
case uint8Tag: case uint8ClampedTag: case uint16Tag: case uint32Tag:
|
||||
return cloneTypedArray(object, isDeep);
|
||||
return cloneTypedArray(object, isDeep)
|
||||
|
||||
case mapTag:
|
||||
return cloneMap(object, isDeep, cloneFunc);
|
||||
return cloneMap(object, isDeep, cloneFunc)
|
||||
|
||||
case numberTag:
|
||||
case stringTag:
|
||||
return new Ctor(object);
|
||||
return new Ctor(object)
|
||||
|
||||
case regexpTag:
|
||||
return cloneRegExp(object);
|
||||
return cloneRegExp(object)
|
||||
|
||||
case setTag:
|
||||
return cloneSet(object, isDeep, cloneFunc);
|
||||
return cloneSet(object, isDeep, cloneFunc)
|
||||
|
||||
case symbolTag:
|
||||
return cloneSymbol(object);
|
||||
return cloneSymbol(object)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,15 +149,15 @@ function initCloneByTag(object, tag, cloneFunc, isDeep) {
|
||||
* @returns {Array} Returns the initialized clone.
|
||||
*/
|
||||
function initCloneArray(array) {
|
||||
const length = array.length;
|
||||
const result = array.constructor(length);
|
||||
const length = array.length
|
||||
const result = array.constructor(length)
|
||||
|
||||
// Add properties assigned by `RegExp#exec`.
|
||||
if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) {
|
||||
result.index = array.index;
|
||||
result.input = array.input;
|
||||
result.index = array.index
|
||||
result.input = array.input
|
||||
}
|
||||
return result;
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -177,69 +177,69 @@ function initCloneArray(array) {
|
||||
* @returns {*} Returns the cloned value.
|
||||
*/
|
||||
function baseClone(value, bitmask, customizer, key, object, stack) {
|
||||
let result;
|
||||
const isDeep = bitmask & CLONE_DEEP_FLAG;
|
||||
const isFlat = bitmask & CLONE_FLAT_FLAG;
|
||||
const isFull = bitmask & CLONE_SYMBOLS_FLAG;
|
||||
let result
|
||||
const isDeep = bitmask & CLONE_DEEP_FLAG
|
||||
const isFlat = bitmask & CLONE_FLAT_FLAG
|
||||
const isFull = bitmask & CLONE_SYMBOLS_FLAG
|
||||
|
||||
if (customizer) {
|
||||
result = object ? customizer(value, key, object, stack) : customizer(value);
|
||||
result = object ? customizer(value, key, object, stack) : customizer(value)
|
||||
}
|
||||
if (result !== undefined) {
|
||||
return result;
|
||||
return result
|
||||
}
|
||||
if (!isObject(value)) {
|
||||
return value;
|
||||
return value
|
||||
}
|
||||
const isArr = Array.isArray(value);
|
||||
const isArr = Array.isArray(value)
|
||||
if (isArr) {
|
||||
result = initCloneArray(value);
|
||||
result = initCloneArray(value)
|
||||
if (!isDeep) {
|
||||
return copyArray(value, result);
|
||||
return copyArray(value, result)
|
||||
}
|
||||
} else {
|
||||
const tag = getTag(value);
|
||||
const isFunc = tag == funcTag || tag == genTag;
|
||||
const tag = getTag(value)
|
||||
const isFunc = tag == funcTag || tag == genTag
|
||||
|
||||
if (isBuffer(value)) {
|
||||
return cloneBuffer(value, isDeep);
|
||||
return cloneBuffer(value, isDeep)
|
||||
}
|
||||
if (tag == objectTag || tag == argsTag || (isFunc && !object)) {
|
||||
result = (isFlat || isFunc) ? {} : initCloneObject(value);
|
||||
result = (isFlat || isFunc) ? {} : initCloneObject(value)
|
||||
if (!isDeep) {
|
||||
return isFlat
|
||||
? copySymbolsIn(value, baseAssignIn(result, value))
|
||||
: copySymbols(value, baseAssign(result, value));
|
||||
: copySymbols(value, baseAssign(result, value))
|
||||
}
|
||||
} else {
|
||||
if (!cloneableTags[tag]) {
|
||||
return object ? value : {};
|
||||
return object ? value : {}
|
||||
}
|
||||
result = initCloneByTag(value, tag, baseClone, isDeep);
|
||||
result = initCloneByTag(value, tag, baseClone, isDeep)
|
||||
}
|
||||
}
|
||||
// Check for circular references and return its corresponding clone.
|
||||
stack || (stack = new Stack);
|
||||
const stacked = stack.get(value);
|
||||
stack || (stack = new Stack)
|
||||
const stacked = stack.get(value)
|
||||
if (stacked) {
|
||||
return stacked;
|
||||
return stacked
|
||||
}
|
||||
stack.set(value, result);
|
||||
stack.set(value, result)
|
||||
|
||||
const keysFunc = isFull
|
||||
? (isFlat ? getAllKeysIn : getAllKeys)
|
||||
: (isFlat ? keysIn : keys);
|
||||
: (isFlat ? keysIn : keys)
|
||||
|
||||
const props = isArr ? undefined : keysFunc(value);
|
||||
const props = isArr ? undefined : keysFunc(value)
|
||||
arrayEach(props || value, (subValue, key) => {
|
||||
if (props) {
|
||||
key = subValue;
|
||||
subValue = value[key];
|
||||
key = subValue
|
||||
subValue = value[key]
|
||||
}
|
||||
// Recursively populate clone (susceptible to call stack limits).
|
||||
assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
|
||||
});
|
||||
return result;
|
||||
assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack))
|
||||
})
|
||||
return result
|
||||
}
|
||||
|
||||
export default baseClone;
|
||||
export default baseClone
|
||||
|
||||
Reference in New Issue
Block a user