lib/paworker.js
function onFunction(data, op, iterStr, context) {
	var	iter,
		data;
		
	// Check task
	if(!op || !data || !iterStr || !context) {
		throw Error('Worker received invalid task');
	}
	
	// parse the serialized function
	// eval() may be evil but here we don't have much choice
	eval('var iter = ' + iterStr);

	switch(op) {
		case 'map':
			data = data.map(iter);
			break;
		case 'filter': 
			data = data.filter(iter);
			break;
		default:
			data = null;
			break;
	}
	
	process.send({
		result: data,
		context: context
	});
}
function onFunction(data, op, iterStr, context) {
	var	iter,
		data;
		
	// Check task
	if(!op || !data || !iterStr || !context) {
		throw Error('Worker received invalid task');
	}
	
	// parse the serialized function
	// eval() may be evil but here we don't have much choice
	eval('var iter = ' + iterStr);

	switch(op) {
		case 'map':
			data = data.map(iter);
			break;
		case 'filter': 
			data = data.filter(iter);
			break;
		default:
			data = null;
			break;
	}
	
	process.send({
		result: data,
		context: context
	});
}
function onFunction ( data , op , iterStr , context ) { var iter , data ; // Check task if ( ! op || ! data || ! iterStr || ! context ) { throw Error ( 'Worker received invalid task' ) ; } // parse the serialized function // eval() may be evil but here we don't have much choice eval ( 'var iter = ' + iterStr ) ; switch ( op ) { case 'map' : data = data . map ( iter ) ; break ; case 'filter' : data = data . filter ( iter ) ; break ; default : data = null ; break ; } process . send ( { result : data , context : context } ) ; }
Handle functional requests
Handle functional requests