Skip to content

Instantly share code, notes, and snippets.

@venkatperi
Created June 25, 2017 01:53
Show Gist options
  • Save venkatperi/1cddb221bc3033d394e7b3607fecd16a to your computer and use it in GitHub Desktop.
Save venkatperi/1cddb221bc3033d394e7b3607fecd16a to your computer and use it in GitHub Desktop.
Execute array of promises in sequence
pseq = ( arr ) => arr.reduce(
( r, n ) => r.then( typeof n === 'function' ? n : () => Promise.resolve( n ) ),
Promise.resolve() );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment