function merge(toAdd) {
    var _p = this._private;
    var cy = _p.cy;

    if (!toAdd) {
      return this;
    }

    if (toAdd && string(toAdd)) {
      var selector = toAdd;
      toAdd = cy.mutableElements().filter(selector);
    }

    var map = _p.map;

    for (var i = 0; i < toAdd.length; i++) {
      var toAddEle = toAdd[i];
      var id = toAddEle._private.data.id;
      var add = !map.has(id);

      if (add) {
        var index = this.length++;
        this[index] = toAddEle;
        map.set(id, {
          ele: toAddEle,
          index: index
        });
      } else {
        // replace
        var _index = map.get(id).index;
        this[_index] = toAddEle;
        map.set(id, {
          ele: toAddEle,
          index: _index
        });
      }
    }

    return this; // chaining
  }
function merge(toAdd) {
    var _p = this._private;
    var cy = _p.cy;

    if (!toAdd) {
      return this;
    }

    if (toAdd && string(toAdd)) {
      var selector = toAdd;
      toAdd = cy.mutableElements().filter(selector);
    }

    var map = _p.map;

    for (var i = 0; i < toAdd.length; i++) {
      var toAddEle = toAdd[i];
      var id = toAddEle._private.data.id;
      var add = !map.has(id);

      if (add) {
        var index = this.length++;
        this[index] = toAddEle;
        map.set(id, {
          ele: toAddEle,
          index: index
        });
      } else {
        // replace
        var _index = map.get(id).index;
        this[_index] = toAddEle;
        map.set(id, {
          ele: toAddEle,
          index: _index
        });
      }
    }

    return this; // chaining
  }
function merge ( toAdd ) { var _p = this . _private ; var cy = _p . cy ; if ( ! toAdd ) { return this ; } if ( toAdd && string ( toAdd ) ) { var selector = toAdd ; toAdd = cy . mutableElements ( ) . filter ( selector ) ; } var map = _p . map ; for ( var i = 0 ; i < toAdd . length ; i ++ ) { var toAddEle = toAdd [ i ] ; var id = toAddEle . _private . data . id ; var add = ! map . has ( id ) ; if ( add ) { var index = this . length ++ ; this [ index ] = toAddEle ; map . set ( id , { ele : toAddEle , index : index } ) ; } else { // replace var _index = map . get ( id ) . index ; this [ _index ] = toAddEle ; map . set ( id , { ele : toAddEle , index : _index } ) ; } } return this ; // chaining }
in place merge on calling collection
in place merge on calling collection
Merge the elements in this array into another array