MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / clone

Function clone

libs/echarts/echarts.simple.js:309–349  ·  view source on GitHub ↗

* Those data types can be cloned: * Plain object, Array, TypedArray, number, string, null, undefined. * Those data types will be assgined using the orginal data: * BUILTIN_OBJECT * Instance of user defined class will be cloned to a plain object, without * properties in prototype. * Oth

(source)

Source from the content-addressed store, hash-verified

307 * @return {*} new
308 */
309function clone(source) {
310 if (source == null || typeof source !== 'object') {
311 return source;
312 }
313
314 var result = source;
315 var typeStr = objToString.call(source);
316
317 if (typeStr === '[object Array]') {
318 if (!isPrimitive(source)) {
319 result = [];
320 for (var i = 0, len = source.length; i < len; i++) {
321 result[i] = clone(source[i]);
322 }
323 }
324 }
325 else if (TYPED_ARRAY[typeStr]) {
326 if (!isPrimitive(source)) {
327 var Ctor = source.constructor;
328 if (source.constructor.from) {
329 result = Ctor.from(source);
330 }
331 else {
332 result = new Ctor(source.length);
333 for (var i = 0, len = source.length; i < len; i++) {
334 result[i] = clone(source[i]);
335 }
336 }
337 }
338 }
339 else if (!BUILTIN_OBJECT[typeStr] && !isPrimitive(source) && !isDom(source)) {
340 result = {};
341 for (var key in source) {
342 if (source.hasOwnProperty(key)) {
343 result[key] = clone(source[key]);
344 }
345 }
346 }
347
348 return result;
349}
350
351/**
352 * @memberOf module:zrender/core/util

Callers 6

mergeFunction · 0.70
echarts.simple.jsFile · 0.70
mergeThemeFunction · 0.70
EChartsFunction · 0.70
transferPropertiesFunction · 0.70
completeDimensionsFunction · 0.70

Calls 2

isPrimitiveFunction · 0.70
isDomFunction · 0.70

Tested by

no test coverage detected