Skip to content

Commit 4edd545

Browse files
committed
Added a do function.
Infinite loop that can be used to run main game updates, etc.
1 parent af1d76f commit 4edd545

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Sequencr.js V2
1+
# Sequencr.js V3
22
Sequencr.js is a super-light-weight library that allows you to easily chain function calls together with timeouts in between, or set timeouts between iterations of a loop.
33

44
Please read the wiki for more information, and usage.

Sequencr.dev.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Sequencr.js V2
2+
Sequencr.js V3
33
44
The MIT License (MIT)
55
Copyright (c) 2016 Joshua Sideris | [email protected] | https://github.com/JSideris/Sequencr.js
@@ -35,6 +35,15 @@ function Sequencr() {
3535
onCompleted.call(this);
3636
}
3737
}
38+
39+
this.do = function (callback, timeout) {
40+
setTimeout(function (This) {
41+
var ret = callback.call(This);
42+
if(ret !== false){
43+
Sequencr.do.apply(This, [callback, timeout]);
44+
}
45+
}, timeout, this);
46+
}
3847
}
3948

4049
var Sequencr = new Sequencr();

Sequencr.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Sequencr.js V2
2+
Sequencr.js V3
33
44
The MIT License (MIT)
55
Copyright (c) 2016 Joshua Sideris | [email protected] | https://github.com/JSideris/Sequencr.js
@@ -12,4 +12,4 @@ and to permit persons to whom the Software is furnished to do so, subject to the
1212
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
1313
*/
1414

15-
function Sequencr(){this.chain=function(n,c){Sequencr["for"].apply(this,[0,n.length,function(c){n[c].call(this)},c])},this["for"]=function(n,c,t,e,i){c>n?setTimeout(function(l){var u=t.call(l,n);u!==!1?Sequencr["for"].apply(l,[n+1,c,t,e,i]):i&&i.call(this)},e,this):i&&i.call(this)}}var Sequencr=new Sequencr;
15+
function Sequencr(){this.chain=function(n,t){Sequencr["for"].apply(this,[0,n.length,function(t){n[t].call(this)},t])},this["for"]=function(n,t,c,i,e){t>n?setTimeout(function(u){var l=c.call(u,n);l!==!1?Sequencr["for"].apply(u,[n+1,t,c,i,e]):e&&e.call(this)},i,this):e&&e.call(this)},this["do"]=function(n,t){setTimeout(function(c){var i=n.call(c);i!==!1&&Sequencr["do"].apply(c,[n,t])},t,this)}}var Sequencr=new Sequencr;

changelog.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
#Changes
2+
V3 - 2016-06-10
3+
Added Sequencr.do, which is an infinite version of Sequencr.for that can also be exited by returning false in the callback. Use it for your game's animation loop or whatever.
4+
25
V2 - 2016-06-09
36
Added ability to break out of a for loop by returning false. This will immediately invoke the onCompleted callback.

0 commit comments

Comments
 (0)