Skip to content

Commit

Permalink
Version 4 Update
Browse files Browse the repository at this point in the history
Better callbacks + control over timeouts.
  • Loading branch information
JSideris committed Aug 9, 2016
1 parent 4edd545 commit d2e6333
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
10 changes: 5 additions & 5 deletions Sequencr.dev.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Sequencr.js V3
Sequencr.js V4
The MIT License (MIT)
Copyright (c) 2016 Joshua Sideris | [email protected] | https://github.com/JSideris/Sequencr.js
Expand Down Expand Up @@ -27,12 +27,12 @@ function Sequencr() {
Sequencr.for.apply(This, [startInclusive + 1, endExclusive, callback, timeout, onCompleted]);
}
else if(onCompleted) {
onCompleted.call(this);
onCompleted.call(this, false);
}
}, timeout, this);
}, (!!(timeout && timeout.constructor && timeout.call && timeout.apply)) ? (timeout(startInclusive) || 1) : (timeout || 1), this);
}
else if(onCompleted) {
onCompleted.call(this);
onCompleted.call(this, true);
}
}

Expand All @@ -42,7 +42,7 @@ function Sequencr() {
if(ret !== false){
Sequencr.do.apply(This, [callback, timeout]);
}
}, timeout, this);
}, (!!(timeout && timeout.constructor && timeout.call && timeout.apply)) ? (timeout() || 1) : (timeout || 1), this);
}
}

Expand Down
4 changes: 2 additions & 2 deletions Sequencr.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Sequencr.js V3
Sequencr.js V4
The MIT License (MIT)
Copyright (c) 2016 Joshua Sideris | [email protected] | https://github.com/JSideris/Sequencr.js
Expand All @@ -12,4 +12,4 @@ and to permit persons to whom the Software is furnished to do so, subject to the
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*/

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;
function Sequencr(){this.chain=function(c,n){Sequencr["for"].apply(this,[0,c.length,function(n){c[n].call(this)},n])},this["for"]=function(c,n,t,l,i){n>c?setTimeout(function(e){var o=t.call(e,c);o!==!1?Sequencr["for"].apply(e,[c+1,n,t,l,i]):i&&i.call(this,!1)},l&&l.constructor&&l.call&&l.apply?l(c)||1:l||1,this):i&&i.call(this,!0)},this["do"]=function(c,n){setTimeout(function(t){var l=c.call(t);l!==!1&&Sequencr["do"].apply(t,[c,n])},n&&n.constructor&&n.call&&n.apply?n()||1:n||1,this)}}var Sequencr=new Sequencr;
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#Changes
V4 - 2016-08-08
Made the timeoute parameter optional. Default is 1 (ms).
Timeout can now either be an integer or a function that returns an integer.
Callback on Sequencr.for now provides a single parameter indicating whether the loop was broken out of early via returning false in the callback. true = breaked, false = completed iteration.

V3 - 2016-06-10
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.

Expand Down

0 comments on commit d2e6333

Please sign in to comment.