Comparing version 0.0.9 to 1.0.0
@@ -1,18 +0,15 @@ | ||
// Cycle Icon designed by Nick Remis - http://www.thenounproject.com/nremis/ | ||
;(function(world){ | ||
'use strict'; | ||
var Ordine = function(params){ | ||
this.finalCallback = params.callback || false; | ||
var Ordine = function(params,error){ | ||
this.success = params.success || false; | ||
this.error = params.error || false; | ||
this.procs = []; | ||
this.completedprocs = 0; | ||
this.waiting = { | ||
shoudI : false | ||
shouldI : false | ||
}; | ||
if (typeof params == 'function'){ | ||
this.finalCallback = params; | ||
this.success = params; | ||
this.error = error || false; | ||
} | ||
@@ -29,8 +26,6 @@ return this; | ||
world.Ordine = Ordine; | ||
})(this); | ||
;(function(Ordine) { | ||
'use strict'; | ||
Ordine.prototype.enqueue = function(procc,waitPrevious){ | ||
@@ -49,13 +44,11 @@ if (this.procs.length === 0){ | ||
;(function(Ordine) { | ||
'use strict'; | ||
Ordine.prototype.loop = function(untill){ | ||
for (var proc in this.procs){ | ||
if (proc >= this.completedprocs){ | ||
if (this.waiting.shoudI === false){ | ||
if (this.waiting.shouldI === false){ | ||
if (!untill){ | ||
if (this.procs[proc].wait){ | ||
this.waiting.shoudI = true; | ||
this.waiting.shouldI = true; | ||
this.waiting.proc = proc; | ||
@@ -65,3 +58,2 @@ }else{ | ||
} | ||
}else{ | ||
@@ -72,3 +64,3 @@ if (proc == untill){ | ||
if (this.procs[proc].wait){ | ||
this.waiting.shoudI = true; | ||
this.waiting.shouldI = true; | ||
this.waiting.proc = proc; | ||
@@ -81,4 +73,2 @@ }else{ | ||
} | ||
} | ||
@@ -90,13 +80,11 @@ } | ||
;(function(Ordine) { | ||
'use strict'; | ||
Ordine.prototype.next = function(){ | ||
this.completedprocs +=1; | ||
if (this.procs.length === this.completedprocs){ | ||
this.finalCallback(); | ||
this.success(); | ||
} | ||
if (this.waiting.shoudI){ | ||
if (this.waiting.shouldI){ | ||
if (this.waiting.proc == this.completedprocs){ | ||
this.waiting.shoudI = false; | ||
this.waiting.shouldI = false; | ||
this.resume(); | ||
@@ -109,9 +97,9 @@ } | ||
;(function(Ordine) { | ||
'use strict'; | ||
Ordine.prototype.resume = function(){ | ||
this.loop(this.completedprocs); | ||
}; | ||
} (this.Ordine)); | ||
;(function(Ordine) { | ||
'use strict'; | ||
Ordine.prototype.run = function(){ | ||
@@ -121,3 +109,2 @@ this.loop(); | ||
}; | ||
} (this.Ordine)); |
@@ -1,2 +0,2 @@ | ||
!function(a){"use strict";var b=function(a){return this.finalCallback=a.callback||!1,this.procs=[],this.completedprocs=0,this.waiting={shoudI:!1},"function"==typeof a&&(this.finalCallback=a),this};"undefined"!=typeof exports&&("undefined"!=typeof module&&module.exports&&(exports=module.exports=b),module.exports=b),a.Ordine=b}(this),function(a){a.prototype.enqueue=function(a,b){return 0===this.procs.length&&(b=!1),this.procs.push({proc:a,wait:b||!1}),this}}(this.Ordine),function(a){a.prototype.loop=function(a){for(var b in this.procs)b>=this.completedprocs&&this.waiting.shoudI===!1&&(a&&b==a?this.procs[b].proc():this.procs[b].wait?(this.waiting.shoudI=!0,this.waiting.proc=b):this.procs[b].proc())}}(this.Ordine),function(a){a.prototype.next=function(){this.completedprocs+=1,this.procs.length===this.completedprocs&&this.finalCallback(),this.waiting.shoudI&&this.waiting.proc==this.completedprocs&&(this.waiting.shoudI=!1,this.resume())}}(this.Ordine),function(a){a.prototype.resume=function(){this.loop(this.completedprocs)}}(this.Ordine),function(a){a.prototype.run=function(){return this.loop(),this}}(this.Ordine); | ||
!function(a){"use strict";var b=function(a,b){return this.success=a.success||!1,this.error=a.error||!1,this.procs=[],this.completedprocs=0,this.waiting={shouldI:!1},"function"==typeof a&&(this.success=a,this.error=b||!1),this};"undefined"!=typeof exports&&("undefined"!=typeof module&&module.exports&&(exports=module.exports=b),module.exports=b),a.Ordine=b}(this),function(a){"use strict";a.prototype.enqueue=function(a,b){return 0===this.procs.length&&(b=!1),this.procs.push({proc:a,wait:b||!1}),this}}(this.Ordine),function(a){"use strict";a.prototype.loop=function(a){for(var b in this.procs)b>=this.completedprocs&&this.waiting.shouldI===!1&&(a&&b==a?this.procs[b].proc():this.procs[b].wait?(this.waiting.shouldI=!0,this.waiting.proc=b):this.procs[b].proc())}}(this.Ordine),function(a){"use strict";a.prototype.next=function(){this.completedprocs+=1,this.procs.length===this.completedprocs&&this.success(),this.waiting.shouldI&&this.waiting.proc==this.completedprocs&&(this.waiting.shouldI=!1,this.resume())}}(this.Ordine),function(a){"use strict";a.prototype.resume=function(){this.loop(this.completedprocs)}}(this.Ordine),function(a){"use strict";a.prototype.run=function(){return this.loop(),this}}(this.Ordine); | ||
//# sourceMappingURL=ordine.min.js.map |
{ | ||
"name": "ordine", | ||
"version": "0.0.9", | ||
"version": "1.0.0", | ||
"description": "Callbacks made almost easy.", | ||
@@ -25,4 +25,3 @@ "main": "dist/ordine.js", | ||
"homepage": "https://github.com/guisouza/Ordine", | ||
"dependencies": { | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
@@ -29,0 +28,0 @@ "grunt": "^0.4.5", |
@@ -9,3 +9,3 @@ | ||
Constructor : | ||
Constructor : | ||
====== | ||
@@ -20,3 +20,3 @@ | ||
# Constructor arguments : | ||
# Constructor arguments : | ||
__callback(function):__ | ||
@@ -26,7 +26,7 @@ This the only required argument which is the callback for the queue. | ||
#Enqueue method : | ||
#Enqueue method : | ||
```javascript | ||
var myQueue = new Queue(function(){ | ||
var myQueue = new Ordine(function(){ | ||
console.log('uh!?') | ||
@@ -62,12 +62,15 @@ }) | ||
__Proccess(function):__ | ||
Asynchronous stuff. | ||
__Sync(boolean):__ | ||
This argument have to be the answer for the question : "This process will wait the previous process end to be executed" | ||
# Run Method : | ||
# Run Method : | ||
The run method trigger the queue execution. | ||
// Cycle Icon designed by Nick Remis - http://www.thenounproject.com/nremis/ |
;(function(Ordine) { | ||
'use strict'; | ||
Ordine.prototype.enqueue = function(procc,waitPrevious){ | ||
@@ -3,0 +4,0 @@ if (this.procs.length === 0){ |
;(function(Ordine) { | ||
'use strict'; | ||
Ordine.prototype.loop = function(untill){ | ||
for (var proc in this.procs){ | ||
if (proc >= this.completedprocs){ | ||
if (this.waiting.shoudI === false){ | ||
if (this.waiting.shouldI === false){ | ||
if (!untill){ | ||
if (this.procs[proc].wait){ | ||
this.waiting.shoudI = true; | ||
this.waiting.shouldI = true; | ||
this.waiting.proc = proc; | ||
@@ -17,3 +15,2 @@ }else{ | ||
} | ||
}else{ | ||
@@ -24,3 +21,3 @@ if (proc == untill){ | ||
if (this.procs[proc].wait){ | ||
this.waiting.shoudI = true; | ||
this.waiting.shouldI = true; | ||
this.waiting.proc = proc; | ||
@@ -33,4 +30,2 @@ }else{ | ||
} | ||
} | ||
@@ -37,0 +32,0 @@ } |
;(function(Ordine) { | ||
'use strict'; | ||
Ordine.prototype.next = function(){ | ||
this.completedprocs +=1; | ||
if (this.procs.length === this.completedprocs){ | ||
this.finalCallback(); | ||
this.success(); | ||
} | ||
if (this.waiting.shoudI){ | ||
if (this.waiting.shouldI){ | ||
if (this.waiting.proc == this.completedprocs){ | ||
this.waiting.shoudI = false; | ||
this.waiting.shouldI = false; | ||
this.resume(); | ||
@@ -14,0 +12,0 @@ } |
;(function(Ordine) { | ||
'use strict'; | ||
Ordine.prototype.resume = function(){ | ||
this.loop(this.completedprocs); | ||
}; | ||
} (this.Ordine)); |
;(function(Ordine) { | ||
'use strict'; | ||
Ordine.prototype.run = function(){ | ||
@@ -7,3 +7,2 @@ this.loop(); | ||
}; | ||
} (this.Ordine)); |
@@ -1,18 +0,15 @@ | ||
// Cycle Icon designed by Nick Remis - http://www.thenounproject.com/nremis/ | ||
;(function(world){ | ||
'use strict'; | ||
var Ordine = function(params){ | ||
this.finalCallback = params.callback || false; | ||
var Ordine = function(params,error){ | ||
this.success = params.success || false; | ||
this.error = params.error || false; | ||
this.procs = []; | ||
this.completedprocs = 0; | ||
this.waiting = { | ||
shoudI : false | ||
shouldI : false | ||
}; | ||
if (typeof params == 'function'){ | ||
this.finalCallback = params; | ||
this.success = params; | ||
this.error = error || false; | ||
} | ||
@@ -29,5 +26,2 @@ return this; | ||
world.Ordine = Ordine; | ||
})(this); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
11925
248
0
73
14