MCPcopy
hub / github.com/tdewolff/minify / clone

Function clone

_benchmarks/sample_echarts.js:204–241  ·  view source on GitHub ↗
(source)

Source from the content-addressed store, hash-verified

202 }
203 }
204 function clone(source) {
205 if (source == null || typeof source !== 'object') {
206 return source;
207 }
208 var result = source;
209 var typeStr = objToString.call(source);
210 if (typeStr === '[object Array]') {
211 if (!isPrimitive(source)) {
212 result = [];
213 for (var i = 0, len = source.length; i < len; i++) {
214 result[i] = clone(source[i]);
215 }
216 }
217 }
218 else if (TYPED_ARRAY[typeStr]) {
219 if (!isPrimitive(source)) {
220 var Ctor = source.constructor;
221 if (Ctor.from) {
222 result = Ctor.from(source);
223 }
224 else {
225 result = new Ctor(source.length);
226 for (var i = 0, len = source.length; i < len; i++) {
227 result[i] = clone(source[i]);
228 }
229 }
230 }
231 }
232 else if (!BUILTIN_OBJECT[typeStr] && !isPrimitive(source) && !isDom(source)) {
233 result = {};
234 for (var key in source) {
235 if (source.hasOwnProperty(key)) {
236 result[key] = clone(source[key]);
237 }
238 }
239 }
240 return result;
241 }
242 function merge(target, source, overwrite) {
243 if (!isObject(source) || !isObject(target)) {
244 return overwrite ? clone(source) : target;

Callers 15

mergeFunction · 0.70
sample_echarts.jsFile · 0.70
createLocaleObjectFunction · 0.70
mergeThemeFunction · 0.70
createSourceFunction · 0.70
cloneSourceShallowFunction · 0.70
cloneAllDimensionInfoFunction · 0.70
applySingleDataTransformFunction · 0.70
EChartsFunction · 0.70
completeDimensionsFunction · 0.70
makeAxisPointerModelFunction · 0.70

Calls 2

isDomFunction · 0.85
isPrimitiveFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…