Skip to content

Instantly share code, notes, and snippets.

@kmaglione
Created February 13, 2018 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kmaglione/754fbdd582e881faac111970e8ff9182 to your computer and use it in GitHub Desktop.
Save kmaglione/754fbdd582e881faac111970e8ff9182 to your computer and use it in GitHub Desktop.
function each(ary, fn) {
ary = Array.from(ary);
return (function next() {
if (ary.length) {
return Promise.resolve(fn(ary.shift())).then(next);
}
})();
}
each(category.channels, channel => {
return list(channel).then(items => {
return each(items, item => {
return process(item, category.id);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment