I am trying out the package [proxy-lists](https://www.npmjs.com/package/proxy-lists#getproxies), which uses an event emitter to receive proxies.

I created the following example:

```
const ProxyLists = require('proxy-lists');

function main() {

    const options = {
        countries: null
    };

    // `gettingProxies` is an event emitter object.
    const gettingProxies = ProxyLists.getProxies(options);

    let data = []
    gettingProxies.on('data', function (proxies) {
        console.log(proxies);
        data.push(proxies)
        if (data.length > 1000) {
            return data
        }
    });
}

console.log("First Call");
const res = main()
console.log(res);
console.log("Last Call");

```

However, I receive the following output:

```
First Call
undefined
Last Call
[ { ipAddress: 'ip-192-169-156-211.ip.secureserver.net',
    port: 52324,
    country: null,
    source: 'rosinstrument' },
  { ipAddress: 'ip-192-169-218-61.ip.secureserver.net',

```

As you can see the `console.log`'s are already called when the function is running. However, I would prefer the following *synchronous* order:

```
First Call
[ { ipAddress: '72.89.213.193.static.cust.telenor.com',
    port: 51024,
    country: 'us',
    source: 'rosinstrument' },
  { ipAddress: '50.250.56.129',
    port: 48380,
    country: 'us',
    source: 'rosinstrument' },
...
Last Call

```

Any suggestions what I am doing wrong?