Skip to content

Instantly share code, notes, and snippets.

@calvinmetcalf
Created June 30, 2013 20:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save calvinmetcalf/5896658 to your computer and use it in GitHub Desktop.
Save calvinmetcalf/5896658 to your computer and use it in GitHub Desktop.
worker that does two things
var worker = cw({
ajax:function(url,callback){
var ajax = new XMLHttpRequest();
ajax.onreadystatechange = function(resp){
if(ajax.readyState === 4 && ajax.status === 200) {
calback(JSON.stringify(ajax.response));
}
}
ajax.open('GET',url,true);
ajax.send();
},
findC:function(array){
return array.filter(function(a){
return Array.isArray(a) && a.length === 2;
}).map(function(a){
//x*x is much faster then Math.pow(a,2);
return Math.sqrt(a[0]*a[0]+a[1]*a[1]);
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment