server/variables/sync/union.js
function compute(paramValues){
	//++unions
	//console.log(JSON.stringify(_.map(paramValues, function(v){return v.length;})))
	
	var a = paramValues[0]
	
	while(!a){
		if(paramValues.length === 0) return []
		a = paramValues.shift()
	}
	
	if(!a) return []
	if(paramValues.length === 0) return a
	
	var results = [].concat(a)
	var ma = {}

	for(var i=0;i<a.length;++i){
		ma[a[i]] = true
	}

	for(var i=1;i<paramValues.length;++i){
		var b = paramValues[i]
		if(b === undefined) continue

		for(var j=0;j<b.length;++j){
			var bv = b[j]
			if(!ma[bv]){
				results.push(bv)
				ma[bv] = true
			}
		}
	}

	//console.log('union ', paramValues, results)
	//console.log('union of ' + JSON.stringify(_.map(paramValues, function(p){return p.length})) + ' -> ' + results.length)
	return results
}
function compute(paramValues){
	//++unions
	//console.log(JSON.stringify(_.map(paramValues, function(v){return v.length;})))
	
	var a = paramValues[0]
	
	while(!a){
		if(paramValues.length === 0) return []
		a = paramValues.shift()
	}
	
	if(!a) return []
	if(paramValues.length === 0) return a
	
	var results = [].concat(a)
	var ma = {}

	for(var i=0;i<a.length;++i){
		ma[a[i]] = true
	}

	for(var i=1;i<paramValues.length;++i){
		var b = paramValues[i]
		if(b === undefined) continue

		for(var j=0;j<b.length;++j){
			var bv = b[j]
			if(!ma[bv]){
				results.push(bv)
				ma[bv] = true
			}
		}
	}

	//console.log('union ', paramValues, results)
	//console.log('union of ' + JSON.stringify(_.map(paramValues, function(p){return p.length})) + ' -> ' + results.length)
	return results
}
/*var unions = 0
setInterval(function(){
console.log('unions: ' + unions)
},1000)