- Parallel.js is a JavaScript library for Multi Core Processing.
- The library can be found form the below link:-
http://adambom.github.io/parallel.js/
- In this Demo “We will explore the parrallel js library.It has many utility method.But We will explore map() method to create summation of two squared number”.
- The script code is listed below. We have created the Parallel object with argument [5,6].Then we have called the map() method with MY_APP.getNumber() method and added the summation.
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Parallel JS Demo</title>
</head>
<body>
<script src="parallel.js"></script>
<script>
var MY_APP = {
/*Return Square of a number*/
getNumber : function(number){
return Math.pow(number,2);
}
}
var parallelObject = new Parallel([5,6]);
parallelObject.map(MY_APP.getNumber).
then(function(inData){
console.log("Resultant Array : ", inData);
console.log("Sum Of Square : ", inData[0]+inData[1]);
});
</script>
</body>
</html>
- Below screenshot shows the output in the console.