code: function _merge_array(opts, a, b) {
  	debug.assert(opts).is('object');
  
  	var ids_mapped = {};
  
  	var tmp = [].concat(a);
  
  	ARRAY(a).forEach(function(v) {
  		if(v && v.$id) {
  			ids_mapped[v.$id] = true;
  			return;
  		}
  	});
  
  	ARRAY(b).forEach(function(v) {
  		var id = v && v.$id;
  
  		if(id && ids_mapped.hasOwnProperty(id)) {
  			return;
  		}
  
  		if( tmp.indexOf(v) >= 0 ) {
  			return;
  		}
  
  		if(id) {
  			ids_mapped[id] = true;
  		}
  
  		tmp.push(v);
  	});
  
  	if(opts.cache && opts.cache._has_cursors) {
  		ARRAY(tmp).forEach(function(v, i) {
  
  			var parent;
  			var key;
  
  			key = a.indexOf(v);
  			if(key >= 0) {
  				parent = a;
  			} else {
  				key = b.indexOf(v);
  				if(key >= 0) {
  					parent = b;
  				}
  			}
  
  			if(!(parent && (key >= 0))) {
  				return;
  			}
  
  			//debug.log('Searching cursor...');
  			var f = opts.cache.findCursor(parent, key);
  			if(f) {
  				//debug.log('Expanding cursor...');
  				opts.cache.addToCursor(f, tmp, i);
  			}
  		});
  	}
  
  	return tmp;
  }
docs: Merge two arrays