src/core.js
function _clone(src) {
  if (!src) {
    return src;
  }

  if (typeof src.clone === 'function') {
    return src.clone();
  } else if (_isPlainObject(src) || _isArray(src)) {
    let ret = new (src.constructor);

    Object.getOwnPropertyNames(src).forEach(function(key) {
      if (typeof src[key] !== 'function') {
        ret[key] = _clone(src[key]);
      }
    });

    return ret;
  } else {
    return JSON.parse(JSON.stringify(src));
  }
}
function _clone(src) {
  if (!src) {
    return src;
  }

  if (typeof src.clone === 'function') {
    return src.clone();
  } else if (_isPlainObject(src) || _isArray(src)) {
    let ret = new (src.constructor);

    Object.getOwnPropertyNames(src).forEach(function(key) {
      if (typeof src[key] !== 'function') {
        ret[key] = _clone(src[key]);
      }
    });

    return ret;
  } else {
    return JSON.parse(JSON.stringify(src));
  }
}
function _clone ( src ) { if ( ! src ) { return src ; } if ( typeof src . clone === 'function' ) { return src . clone ( ) ; } else if ( _isPlainObject ( src ) || _isArray ( src ) ) { let ret = new ( src . constructor ) ; Object . getOwnPropertyNames ( src ) . forEach ( function ( key ) { if ( typeof src [ key ] !== 'function' ) { ret [ key ] = _clone ( src [ key ] ) ; } } ) ; return ret ; } else { return JSON . parse ( JSON . stringify ( src ) ) ; } }
clone given item
clone given item