Returns a deep copy of the given value such that entities are not passed
by reference.

@method deepCopy
@static
@param {Mixed} obj - The object or value to copy
@return {Mixed}
434176
function deepCopy(obj) {
	var res;
	var i;
	var key;
	if (isTerminal(obj)) {
		res = obj;
	} else if (Array.isArray(obj)) {
		res = Array(obj.length);
		for (i = 0; i < obj.length; i++) {
			res[i] = deepCopy(obj[i]);
		}
	} else {
		res = {};
		for (key in obj) {
			res[key] = deepCopy(obj[key]);
		}
	}
	return res;
}
163022
function(deep) {
      var newObj = {},
          i;

      if (obj === null || !wysihtml5.lang.object(obj).isPlainObject()) {
        return obj;
      }

      for (i in obj) {
        if(obj.hasOwnProperty(i)) {
          if (deep) {
            newObj[i] = wysihtml5.lang.object(obj[i]).clone(deep);
          } else {
            newObj[i] = obj[i];
          }
        }
      }
      return newObj;
    }
1044687
def deep_dup(obj)
      if obj.class == Hash
        new_obj = obj.dup
        new_obj.each do |key, value|
          new_obj[deep_dup(key)] = deep_dup(value)
        end
        new_obj
      elsif obj.class == Array
        arr = []
        obj.each do |item|
          arr << deep_dup(item)
        end
        arr
      elsif obj.class == String
        obj.dup
      else
        obj
      end
    end
1202352
def _shallow_copy(self, obj=None, obj_type=None, **kwargs):
        
        if obj is None:
            obj = self._selected_obj.copy()
        if obj_type is None:
            obj_type = self._constructor
        if isinstance(obj, obj_type):
            obj = obj.obj
        for attr in self._attributes:
            if attr not in kwargs:
                kwargs[attr] = getattr(self, attr)
        return obj_type(obj, **kwargs)
888609
function clone(object) {
  if (object === null || typeof object != "object") {
    return object;
  }
  const copy = object.constructor();
  for (const attr in object) {
    if (Object.prototype.hasOwnProperty.call(object, attr)) {
      copy[attr] = object[attr];
    }
  }

  return copy;
}
1225037
def deepcopy(value):
    

    if not isinstance(value, (dict, list, tuple)):
        return value

    if isinstance(value, dict):
        copy = {}
        for k, v in value.items():
            copy[k] = deepcopy(v)

    if isinstance(value, tuple):
        copy = list(range(len(value)))

        for k in get_keys(list(value)):
            copy[k] = deepcopy(value[k])

        copy = tuple(copy)

    if isinstance(value, list):
        copy = list(range(len(value)))

        for k in get_keys(value):
            copy[k] = deepcopy(value[k])

    return copy
1281680
function _cloneObject(object) {
    if (object == null || typeof object != 'object' || typeof object.nodeType != 'undefined') {
        return object;
    }
    var temp = {};
    for (var key in object) {
        if (typeof jQuery != 'undefined' && object[key] instanceof jQuery) {
            temp[key] = object[key];
        } else {
            temp[key] = _cloneObject(object[key]);
        }
    }
    return temp;
}
1282866
protected static function deepCopy($obj)
    {
        if (is_array($obj)) {
            $copy = [];
            foreach ($obj as $k => $v) {
                $copy[$k] = self::deepCopy($v);
            }
            return $copy;
        } elseif ($obj instanceof StripeObject) {
            return $obj::constructFrom(
                self::deepCopy($obj->_values),
                clone $obj->_opts
            );
        } else {
            return $obj;
        }
    }
1358584
function shallowCopyObject (obj) {
  var ret = {};
  for (var i in obj) {
    ret[i] = obj[i];
  }
  return ret;
}
1223174
function (obj) {
        return _.cloneDeepWith(obj, function (value) {
            // falls back to default deepclone if object does not have explicit toJSON().
            if (value && _.isFunction(value.toJSON)) {
                return value.toJSON();
            }
        });
    }
979682
function deepCopy(destination, source) {
    Object.keys(source).forEach(function (property) {
        if (destination[property] && isObject(destination[property])) {
            deepCopy(destination[property], source[property]);
        } else {
            destination[property] = source[property];
        }
    });
}
827879
public static Object deepCopy(Object src) throws InstantiationException, IllegalAccessException
	{
		Class<?> clazz = src.getClass();

		// Just check if the object is mutable.
		// We assume the object that is final is likely immutable. 
		// It's true for String, Integer and other data types.
		if(Modifier.isFinal(clazz.getModifiers()))
		{
          return src; 
		}

		Object dst = clazz.newInstance();
		if(src instanceof Calendar)
		{
			((Calendar)dst).setTimeInMillis(((Calendar)src).getTimeInMillis());
			return dst;
		}
		
		Field[] fields = clazz.getFields();
		for(int i=0; i<fields.length; i++)
		{
			Object fObj = fields[i].get(src);
			if(fObj == null)
			{
				continue;
			}
			Class<?> fRealType = fObj.getClass();
			if((!fRealType.isPrimitive()) 
			  || (!fRealType.isEnum())
			  || fRealType.getPackage() != JAVA_LANG_PKG)
			{
				if(fRealType.isArray())
				{
					Object[] items = (Object[]) fObj;
					fObj = Array.newInstance(fRealType.getComponentType(), items.length);
					for(int j=0; j<items.length; j++)
					{
						Array.set(fObj, j, deepCopy(items[j]));
					}
				}
				else
				{
					fObj = deepCopy(fObj);
				}
			}
			fields[i].set(dst, fObj);
		}
		
		return dst;
	}
193443
function clone(object, deep) {
		if (!object) { return object; }
		var clone = object.prototype
						? Object.create(object.prototype.constructor) : {};

		for(var key in object) {
			if (!object.hasOwnProperty(key)) { continue; }
			clone[key] = deep ? clone(object[key], deep) : object[key];
		}
		return clone;
	}
126223
function omit(obj) {
  var copy = {};
  var keys = Array.prototype.concat.apply(Array.prototype, Array.prototype.slice.call(arguments, 1));
  for (var key in obj) {
    if (indexOf(keys, key) == -1) copy[key] = obj[key];
  }
  return copy;
}
381513
function ( obj, shallow ) {
		var clone;

		if ( shallow === true ) {
			return json.decode( json.encode( obj ) );
		}
		else if ( !obj || regex.primitive.test( typeof obj ) || ( obj instanceof RegExp ) ) {
			return obj;
		}
		else if ( obj instanceof Array ) {
			return obj.slice();
		}
		else if ( !server && !client.ie && obj instanceof Document ) {
			return xml.decode( xml.encode( obj ) );
		}
		else if ( typeof obj.__proto__ !== "undefined" ) {
			return utility.extend( obj.__proto__, obj );
		}
		else if ( obj instanceof Object ) {
			// If JSON encoding fails due to recursion, the original Object is returned because it's assumed this is for decoration
			clone = json.encode( obj, true );

			if ( clone !== undefined ) {
				clone = json.decode( clone );

				// Decorating Functions that would be lost with JSON encoding/decoding
				utility.iterate( obj, function ( v, k ) {
					if ( typeof v === "function" ) {
						clone[k] = v;
					}
				});
			}
			else {
				clone = obj;
			}

			return clone;
		}
		else {
			return obj;
		}
	}
586354
def deepcopy(obj):
    
    if isinstance(obj, JavaObject):
        wrapped = True
        jobject = obj.jobject
    else:
        wrapped = False
        jobject = obj
    try:
        serialized = javabridge.make_instance("weka/core/SerializedObject", "(Ljava/lang/Object;)V", jobject)
        jcopy = javabridge.call(serialized, "getObject", "()Ljava/lang/Object;")
        if wrapped:
            jcopy = obj.__class__(jobject=jcopy)
        return jcopy
    except JavaException as e:
        print("Failed to create copy of " + classes.get_classname(obj) + ": " + str(e))
        return None
641063
function _copy(val) {
    const type = $type(val);

    if (type == 'object') {
        val = _extend({}, val, true);
    } else if (type == 'array') {
        val = val.slice(0);
    }

    return val;
}