fast-speedtest-api icon indicating copy to clipboard operation
fast-speedtest-api copied to clipboard

Get all values in verbose mode

Open Kunoacc opened this issue 6 years ago • 2 comments

In verbose mode, all the download speeds are available and logged in the console. Is there anyway to get the values as a response from the promise? i want to stream all the values to a client through WS

Kunoacc avatar Jan 30 '19 10:01 Kunoacc

This feature is not available at the moment, I'm going to think about implementing it

branchard avatar Feb 03 '19 16:02 branchard

I just added an event listener (https://github.com/branchard/fast-speedtest-api/commit/5b90bcdfc9454e198ffd3719b3fafd3d4bff7398) that allows to pass a callback that's called every time a mesure is done.

You can use it like that:

const FastSpeedtest = require('../src/Api');

let speedtest = new FastSpeedtest({
  token: 'the-key'
});

speedtest.addListener(FastSpeedtest.EVENTS.measure, (currentSpeed) => {
  console.log(`Current speed: ${currentSpeed} ${FastSpeedtest.UNITS.Mbps.name}`);
});

speedtest.getSpeed().then(s => {
  console.log(`Speed: ${s} ${FastSpeedtest.UNITS.Mbps.name}`);
}).catch(e => {
  console.error(e.message);
});

For the moment it is only available in the dev branch.

branchard avatar Feb 03 '19 22:02 branchard