src/99worker-start.js
function alasql(sql,params,cb){

	params = params||[];

	// Avoid setting params if not needed even with callback
	if(typeof params === 'function'){
		scope = cb;
		cb = params;
		params = [];
	}

	if(typeof params !== 'object'){
			params = [params];
	}

    // Increase last request id
	var id = alasql.lastid++;
    // Save callback
	alasql.buffer[id] = cb;
    // Send a message to worker
	alasql.webworker.postMessage({id:id,sql:sql,params:params});
}
function alasql(sql,params,cb){

	params = params||[];

	// Avoid setting params if not needed even with callback
	if(typeof params === 'function'){
		scope = cb;
		cb = params;
		params = [];
	}

	if(typeof params !== 'object'){
			params = [params];
	}

    // Increase last request id
	var id = alasql.lastid++;
    // Save callback
	alasql.buffer[id] = cb;
    // Send a message to worker
	alasql.webworker.postMessage({id:id,sql:sql,params:params});
}
function alasql ( sql , params , cb ) { params = params || [ ] ; // Avoid setting params if not needed even with callback if ( typeof params === 'function' ) { scope = cb ; cb = params ; params = [ ] ; } if ( typeof params !== 'object' ) { params = [ params ] ; } // Increase last request id var id = alasql . lastid ++ ; // Save callback alasql . buffer [ id ] = cb ; // Send a message to worker alasql . webworker . postMessage ( { id : id , sql : sql , params : params } ) ; }
Main procedure for worker
@function
@param {string} sql SQL statement
@param {object} params List of parameters (can be omitted)
@param {callback} cb Callback function
@return {object} Query result
Main procedure for worker