# Lunes 2023/11/06 semana B

# Labs que veremos en clase

# Temas que veremos en clase

# Algunas Soluciones

# Exercise: Write the fetchCommits async generator

Write the fetchCommits async generator:

Here is the code of the paginated-data.js client program:

import _ from 'lodash';

import { fetchCommits } from './fetch-commits.js';

(async () => {

    let someRepos = ['torvalds/linux',
        'ULL-MII-SYTWS-2324/ULL-MII-SYTWS-2324.github.io',
        'javascript-tutorial/en.javascript.info',
        'ULL-MII-SYTWS-2324/generators-marcos-barrios-lorenzo-alu0101056944']
    let count = 0;

    let repoName = _.sample(someRepos);
    console.log(`repoName = ${repoName}`);

    for await (const commit of fetchCommits(repoName)) {

        if (!commit.author) console.log(commit.commit.author.name);
        else console.log(commit?.author?.login || "no login known");

        if (++count == 100) { // let's stop at 100 commits
            break;
        }
    }

})();
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Last Updated: a month ago