Skip to content

Commit

Permalink
update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Danny Blue committed Oct 5, 2015
1 parent eab606c commit 39fd801
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 0 deletions.
45 changes: 45 additions & 0 deletions dist/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,13 @@ function $worker() {
}

return {
/**
* create a new worker
*
* @param {function} method - the function to run when the web worker is triggered
*
* @return {Object}
*/
create: function (method) {
var obj = Object.create(_worker);

Expand All @@ -191,6 +198,13 @@ function $worker() {
return obj;
},

/**
* success method for all workers belonging to the 'group'
*
* @param {function} fn - the success method to run
*
* @return {success}
*/
success: function (fn) {
_workers.forEach(function (current) {
current.shell.onmessage = fn;
Expand All @@ -199,6 +213,13 @@ function $worker() {
return this;
},

/**
* error method to run for all workers belonging to the 'group'
*
* @param {function} fn - the error method to run
*
* @return {error}
*/
error: function (fn) {
_workers.forEach(function (current) {
current.shell.onerror = fn;
Expand All @@ -207,12 +228,26 @@ function $worker() {
return this;
},

/**
* extend the prototype for all workers in a given group
*
* @param {object} obj
*
* @return {extend}
*/
extend: function (obj) {
_extend(_worker, obj);

return this;
},

/**
* run all workers in a certain group
*
* @param {string|number|object|array} data - the data to pass to the worker
*
* @return {run}
*/
run: function (data) {
_workers.forEach(function (current) {
_postMessage(current, data);
Expand All @@ -221,6 +256,11 @@ function $worker() {
return this;
},

/**
* terminate all workers in the group
*
* @return {terminate}
*/
terminate: function () {
_workers.forEach(function (current) {
current.shell.terminate();
Expand All @@ -231,6 +271,11 @@ function $worker() {
return this;
},

/**
* Returns a list of all workers in the group
*
* @return {Array}
*/
list: function() {
return _workers;
}
Expand Down
45 changes: 45 additions & 0 deletions src/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,13 @@ function $worker() {
}

return {
/**
* create a new worker
*
* @param {function} method - the function to run when the web worker is triggered
*
* @return {Object}
*/
create: function (method) {
var obj = Object.create(_worker);

Expand All @@ -191,6 +198,13 @@ function $worker() {
return obj;
},

/**
* success method for all workers belonging to the 'group'
*
* @param {function} fn - the success method to run
*
* @return {success}
*/
success: function (fn) {
_workers.forEach(function (current) {
current.shell.onmessage = fn;
Expand All @@ -199,6 +213,13 @@ function $worker() {
return this;
},

/**
* error method to run for all workers belonging to the 'group'
*
* @param {function} fn - the error method to run
*
* @return {error}
*/
error: function (fn) {
_workers.forEach(function (current) {
current.shell.onerror = fn;
Expand All @@ -207,12 +228,26 @@ function $worker() {
return this;
},

/**
* extend the prototype for all workers in a given group
*
* @param {object} obj
*
* @return {extend}
*/
extend: function (obj) {
_extend(_worker, obj);

return this;
},

/**
* run all workers in a certain group
*
* @param {string|number|object|array} data - the data to pass to the worker
*
* @return {run}
*/
run: function (data) {
_workers.forEach(function (current) {
_postMessage(current, data);
Expand All @@ -221,6 +256,11 @@ function $worker() {
return this;
},

/**
* terminate all workers in the group
*
* @return {terminate}
*/
terminate: function () {
_workers.forEach(function (current) {
current.shell.terminate();
Expand All @@ -231,6 +271,11 @@ function $worker() {
return this;
},

/**
* Returns a list of all workers in the group
*
* @return {Array}
*/
list: function() {
return _workers;
}
Expand Down

0 comments on commit 39fd801

Please sign in to comment.