O'Reilly logo

Async JavaScript by Trevor Burnham

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Minimalist Flow Control with Step

Tim Caswell’s Step is a lightweight library.[42] In fact, its API consists of a single function: Step.

Step takes a list of functions; here’s an example:

 
Step(task1, task2, task3);

Each function can control the flow in three ways.

  • It can call this to make Step run the next function in the list.

  • It can call a callback generated by this.parallel or this.group n times to tell Step to run the next function n times.

  • It can return a value, which will also make Step run the next function in the list. This makes it easy to mix synchronous functions with async ones.

The next function will receive the results of its predecessor (that is, its return value or the arguments it passed to this) or the results of all ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required