I have a function
function getDevices() {
var devices = [];
/* code that checks lan for devices and pushes to device array */
/* this is done with an event emitter so its occurs as devices are found */
setTimeout(5000, function() {/*stop searching for devices*/});
return devices;
}
How do i get the function get devices to return all the devices after the 5 seconds?
I saw this post: which uses callbacks but it doesn't end up returning the function. Id like to have a global variable that i can assign the result of getDevices() to without having to access the global variable inside the getDevices function