{"size": 693, "ext": "js", "max_stars_repo_path": "algs/mapPromise/index.js", "max_stars_repo_name": "diegojimenes/listAlg", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "algs/mapPromise/index.js", "max_issues_repo_name": "diegojimenes/listAlg", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "algs/mapPromise/index.js", "max_forks_repo_name": "diegojimenes/listAlg", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 31.5, "max_line_length": 83, "alphanum_fraction": 0.5584415584}
/**
    map com promise, ultil para quando precisamos fazer alguma request ou algo
    assincrono no meio de uma iteração
    @function
    @name map 
    * @author diego jimenes <contato.diegojimenes@gmail.com>
    * @arguments
    * @example
    *   algs.map(list,(item, index) => {
    *       return fetch(`https://jsonplaceholder.typicode.com/posts/${index + 1}`)
    *           .then(response => response.json())
    *           .then(json => {
    *               return [...acc, json]
    *           })
    *   }, [])
 */

const map = (list, call) => list.reduce((promise, item, index) => {
    return promise.then(() => call(item, index))
}, Promise.resolve())

module.exports = map