Created
June 30, 2013 20:09
-
-
Save calvinmetcalf/5896658 to your computer and use it in GitHub Desktop.
worker that does two things
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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