-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Please don't forget to check out the project page for this library.
Sequencr.js is a super-light-weight library that allows you to easily and neatly chain function calls together using timeouts or promises, or use timeouts or promises between iterations of a loop, effectively achieving asynchronous JavaScript loops.
There are currently five helpers in this library:
Sequencr.chain - chains functions together with timeouts in-between
Sequencr.for - a for loop with timeouts
Sequencr.do - a do loop with timeouts (great for game update loops)
Sequencr.promiseChain - chains functions together via promises
Sequencr.promiseFor - a for loop with promises
The inner working mechanism of Sequencr.js is setTimeout, or native JavaScript promises (depending on the helper method). It's an easier way to manage callbacks and promises.
Sequencr.js preserves the this
scope, and can be made to work with custom parameters. See below for examples for advanced usage.
I created this library to use in some of my own projects but thought it would be useful to a lot of other people who may be frustrated with JavaScript's lack of a clean way to do sleeping/yielding. This is obviously a fairly simple library and it's free to use under the MIT license in whatever you need it for. If you'd like to say "thank you", pledge a donation on Patreon.
I'd like to continue updating this library and adding new features and functionality. Please feel free to request features to [email protected] or submit changes to the code.
While the code is free to use, this wiki, gh-pages content, and graphics are subject to copyright.