MCPcopy Create free account
hub / github.com/RubyLouvre/anu / initCloneByTag

Function initCloneByTag

test/babel.js:53200–53234  ·  view source on GitHub ↗

* Initializes an object clone based on its `toStringTag`. * * **Note:** This function only supports cloning values with tags of * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. * * @private * @param {Object} object The object to clone. * @param {string} tag The `toStringT

(object, tag, cloneFunc, isDeep)

Source from the content-addressed store, hash-verified

53198 * @returns {Object} Returns the initialized clone.
53199 */
53200 function initCloneByTag(object, tag, cloneFunc, isDeep) {
53201 var Ctor = object.constructor;
53202 switch (tag) {
53203 case arrayBufferTag:
53204 return cloneArrayBuffer(object);
53205
53206 case boolTag:
53207 case dateTag:
53208 return new Ctor(+object);
53209
53210 case dataViewTag:
53211 return cloneDataView(object, isDeep);
53212
53213 case float32Tag:case float64Tag:
53214 case int8Tag:case int16Tag:case int32Tag:
53215 case uint8Tag:case uint8ClampedTag:case uint16Tag:case uint32Tag:
53216 return cloneTypedArray(object, isDeep);
53217
53218 case mapTag:
53219 return cloneMap(object, isDeep, cloneFunc);
53220
53221 case numberTag:
53222 case stringTag:
53223 return new Ctor(object);
53224
53225 case regexpTag:
53226 return cloneRegExp(object);
53227
53228 case setTag:
53229 return cloneSet(object, isDeep, cloneFunc);
53230
53231 case symbolTag:
53232 return cloneSymbol(object);
53233 }
53234 }
53235
53236 module.exports = initCloneByTag;
53237

Callers 1

baseCloneFunction · 0.85

Calls 7

cloneArrayBufferFunction · 0.85
cloneDataViewFunction · 0.85
cloneTypedArrayFunction · 0.85
cloneMapFunction · 0.85
cloneRegExpFunction · 0.85
cloneSetFunction · 0.85
cloneSymbolFunction · 0.85

Tested by

no test coverage detected