Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

baby-workers

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

baby-workers - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

2

package.json
{
"name": "baby-workers",
"version": "0.0.7",
"version": "0.0.8",
"description": "Manage your functions asynchronously or as stack with baby-workers.",

@@ -5,0 +5,0 @@ "main": "workers.min.js",

@@ -21,3 +21,3 @@ var Workers = function()

});
} : Object.value);
} : Object.values);

@@ -24,0 +24,0 @@ var $process = function(processName)

@@ -1,1 +0,1 @@

var Workers=function(){var t={NONE:null,TYPE:{ROOT:"root",PARENT:"parent",NODE:"node"},STATUS:{WAITING:"waiting",RUNNING:"running",FINISH:"finish"}};Object.values="function"!=typeof Object.values?function(t){return Object.keys(t).map(function(e){return t[e]})}:Object.value;var e=function(r){this.create=function(r,n,s){return void 0!==a.children[r]||void 0!==a.this[r]?null:(a.children[r]=new e(r),a.children[r].init(a.this,t.TYPE.PARENT),a.children[r].set(n,s),a.this[r]=a.children[r],a.this[r])},this.init=function(e,r){switch(a.parent=e,a.type=r,r){case t.TYPE.ROOT:delete a.this.timeout,delete a.this.interval,delete a.this.run,delete a.this.stack,delete a.this.pop,delete a.this.set,delete a.this.parent,delete a.this.root,delete a.this.node;break;case t.TYPE.PARENT:delete a.this.pop,delete a.this.root;break;case t.TYPE.NODE:delete a.this.timeout,delete a.this.interval,delete a.this.run,delete a.this.stack,delete a.this.node}return delete a.this.init,a.this},this.set=function(r,n){n=null==n||"object"!=typeof n||void 0==n[0]?[n]:Object.values(n);for(var i in n){var o=new e(a.name);o.init(a.this,t.TYPE.NODE),s.nodes.push(o),s.worker+=1}return s.data=n,s.callback=r,a.status=t.STATUS.WAITING,a.totalWorkers=1,delete a.this.set,a.this},this.stack=function(){return s.stack.status=!0,a.this.run(),delete a.this.stack,a.this},this.timeout=function(t){return t=null==t||"number"!=typeof t?1:t,setTimeout(a.this.run,t),delete a.this.timeout,a.this},this.interval=function(t){t=null==t||"number"!=typeof t?1e3:t,a.this.addWorker();var e=setInterval(a.this.run,t);return a.this.stop=function(){a.this.removeWorker(!1),clearInterval(e)},delete a.this.interval,a.this},this.run=function(){a.status=t.STATUS.RUNNING;for(var e in s.data)(!0!==s.stack.status||s.stack.isRunning!==t.STATUS.RUNNING&&s.stack.currentNode===parseInt(e))&&(s.nodes[e].addWorker(),s.stack.isRunning=t.STATUS.RUNNING,s.callback(s.nodes[e],s.data[e]));return 0==s.stack.currentNode&&(a.totalWorkers-=1),a.this},this.pop=function(){return a.totalWorkers-=1,0===a.totalWorkers&&n(),a.parent.removeWorker(!0),a.this},this.getName=function(){return a.name},this.getType=function(){return a.type},this.getStatus=function(){return a.status},this.addWorker=function(){return a.totalWorkers+=1,null!==a.parent&&a.parent.addWorker(),a.this},this.removeWorker=function(e){return"boolean"==typeof e&&!0===e&&(s.worker-=1,a.status=t.STATUS.FINISH,!0===s.stack.status&&(s.stack.currentNode+=1,s.stack.isRunning=t.STATUS.WAITING,a.this.run())),a.totalWorkers-=1,0===a.totalWorkers&&n(),null!==a.parent&&a.parent.removeWorker(!1),a.this},this.complete=function(t,e){return 0===a.totalWorkers&&(t(a.error,a.fatalError),"boolean"!=typeof e||1==e)?a.this:(a.completeCallback.push({callback:t,removeAfterCall:e}),a.this)},this.error=function(t,e){return a.error=null===a.error?t:a.error,a.fatalError=null===a.fatalError?e:a.fatalError,null!==a.parent&&a.parent.error(t,e),a.this},this.save=function(t){return a.save=t,a.this},this.get=function(){return a.save},this.root=function(){return a.parent},this.parent=function(e,r){return null==a.parent?null:(r=void 0==r?t.TYPE.PARENT:r,a.parent.getName()!==e||r!==t.NONE&&a.parent.getType()!==r?void 0===a.parent.parent?null:a.parent.parent(e,r):a.parent)},this.parentNode=function(e){return a.this.parent(e,t.TYPE.NODE)},this.node=function(t){return void 0==a.nodes[t]?null:a.nodes[t]};var n=function(){var t=[];for(var e in a.completeCallback)"boolean"==typeof a.completeCallback[e].removeAfterCall&&0==a.completeCallback[e]&&t.push(a.completeCallback[e]),a.completeCallback[e].callback(a.error);a.completeCallback=t},s={nodes:[],worker:0,data:[],callback:null,stack:{status:!1,currentNode:0,isRunning:t.STATUS.WAITING}},a={this:this,name:r,parent:null,status:t.NONE,type:t.NONE,save:null,error:null,fatalError:null,children:{},completeCallback:[],totalWorkers:0}};return new e("root").init(null,t.TYPE.ROOT)};module.exports=Workers;
var Workers=function(){var t={NONE:null,TYPE:{ROOT:"root",PARENT:"parent",NODE:"node"},STATUS:{WAITING:"waiting",RUNNING:"running",FINISH:"finish"}};Object.values="function"!=typeof Object.values?function(t){return Object.keys(t).map(function(e){return t[e]})}:Object.values;var e=function(r){this.create=function(r,n,s){return void 0!==a.children[r]||void 0!==a.this[r]?null:(a.children[r]=new e(r),a.children[r].init(a.this,t.TYPE.PARENT),a.children[r].set(n,s),a.this[r]=a.children[r],a.this[r])},this.init=function(e,r){switch(a.parent=e,a.type=r,r){case t.TYPE.ROOT:delete a.this.timeout,delete a.this.interval,delete a.this.run,delete a.this.stack,delete a.this.pop,delete a.this.set,delete a.this.parent,delete a.this.root,delete a.this.node;break;case t.TYPE.PARENT:delete a.this.pop,delete a.this.root;break;case t.TYPE.NODE:delete a.this.timeout,delete a.this.interval,delete a.this.run,delete a.this.stack,delete a.this.node}return delete a.this.init,a.this},this.set=function(r,n){n=null==n||"object"!=typeof n||void 0==n[0]?[n]:Object.values(n);for(var i in n){var o=new e(a.name);o.init(a.this,t.TYPE.NODE),s.nodes.push(o),s.worker+=1}return s.data=n,s.callback=r,a.status=t.STATUS.WAITING,a.totalWorkers=1,delete a.this.set,a.this},this.stack=function(){return s.stack.status=!0,a.this.run(),delete a.this.stack,a.this},this.timeout=function(t){return t=null==t||"number"!=typeof t?1:t,setTimeout(a.this.run,t),delete a.this.timeout,a.this},this.interval=function(t){t=null==t||"number"!=typeof t?1e3:t,a.this.addWorker();var e=setInterval(a.this.run,t);return a.this.stop=function(){a.this.removeWorker(!1),clearInterval(e)},delete a.this.interval,a.this},this.run=function(){a.status=t.STATUS.RUNNING;for(var e in s.data)(!0!==s.stack.status||s.stack.isRunning!==t.STATUS.RUNNING&&s.stack.currentNode===parseInt(e))&&(s.nodes[e].addWorker(),s.stack.isRunning=t.STATUS.RUNNING,s.callback(s.nodes[e],s.data[e]));return 0==s.stack.currentNode&&(a.totalWorkers-=1),a.this},this.pop=function(){return a.totalWorkers-=1,0===a.totalWorkers&&n(),a.parent.removeWorker(!0),a.this},this.getName=function(){return a.name},this.getType=function(){return a.type},this.getStatus=function(){return a.status},this.addWorker=function(){return a.totalWorkers+=1,null!==a.parent&&a.parent.addWorker(),a.this},this.removeWorker=function(e){return"boolean"==typeof e&&!0===e&&(s.worker-=1,a.status=t.STATUS.FINISH,!0===s.stack.status&&(s.stack.currentNode+=1,s.stack.isRunning=t.STATUS.WAITING,a.this.run())),a.totalWorkers-=1,0===a.totalWorkers&&n(),null!==a.parent&&a.parent.removeWorker(!1),a.this},this.complete=function(t,e){return 0===a.totalWorkers&&(t(a.error,a.fatalError),"boolean"!=typeof e||1==e)?a.this:(a.completeCallback.push({callback:t,removeAfterCall:e}),a.this)},this.error=function(t,e){return a.error=null===a.error?t:a.error,a.fatalError=null===a.fatalError?e:a.fatalError,null!==a.parent&&a.parent.error(t,e),a.this},this.save=function(t){return a.save=t,a.this},this.get=function(){return a.save},this.root=function(){return a.parent},this.parent=function(e,r){return null==a.parent?null:(r=void 0==r?t.TYPE.PARENT:r,a.parent.getName()!==e||r!==t.NONE&&a.parent.getType()!==r?void 0===a.parent.parent?null:a.parent.parent(e,r):a.parent)},this.parentNode=function(e){return a.this.parent(e,t.TYPE.NODE)},this.node=function(t){return void 0==a.nodes[t]?null:a.nodes[t]};var n=function(){var t=[];for(var e in a.completeCallback)"boolean"==typeof a.completeCallback[e].removeAfterCall&&0==a.completeCallback[e]&&t.push(a.completeCallback[e]),a.completeCallback[e].callback(a.error);a.completeCallback=t},s={nodes:[],worker:0,data:[],callback:null,stack:{status:!1,currentNode:0,isRunning:t.STATUS.WAITING}},a={this:this,name:r,parent:null,status:t.NONE,type:t.NONE,save:null,error:null,fatalError:null,children:{},completeCallback:[],totalWorkers:0}};return new e("root").init(null,t.TYPE.ROOT)};module.exports=Workers;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc