lib/wait-on.js
function waitOn(opts, cb) {
  if (cb !== undefined) {
    return waitOnImpl(opts, cb);
  } else {
    return new Promise(function (resolve, reject) {
      waitOnImpl(opts, function(err) {
        if (err) {
          reject(err);
        } else {
          resolve();
        }
      })
    });
  }
}
function waitOn(opts, cb) {
  if (cb !== undefined) {
    return waitOnImpl(opts, cb);
  } else {
    return new Promise(function (resolve, reject) {
      waitOnImpl(opts, function(err) {
        if (err) {
          reject(err);
        } else {
          resolve();
        }
      })
    });
  }
}
function waitOn ( opts , cb ) { if ( cb !== undefined ) { return waitOnImpl ( opts , cb ) ; } else { return new Promise ( function ( resolve , reject ) { waitOnImpl ( opts , function ( err ) { if ( err ) { reject ( err ) ; } else { resolve ( ) ; } } ) } ) ; } }
Waits for resources to become available before calling callback

Polls file, http(s), tcp ports, sockets for availability.

Resource types are distinquished by their prefix with default being `file:`
- file:/path/to/file - waits for file to be available and size to stabilize
- http://foo.com:8000/bar verifies HTTP HEAD request returns 2XX
- https://my.bar.com/cat verifies HTTPS HEAD request returns 2XX
- http-get:  - HTTP GET returns 2XX response. ex: http://m.com:90/foo
- https-get: - HTTPS GET returns 2XX response. ex: https://my/bar
- tcp:my.server.com:3000 verifies a service is listening on port
- socket:/path/sock verifies a service is listening on (UDS) socket

@param opts object configuring waitOn
@param opts.resources array of string resources to wait for. prefix determines the type of resource with the default type of `file:`
@param opts.delay integer - optional initial delay in ms, default 0
@param opts.interval integer - optional poll resource interval in ms, default 250ms
@param opts.log boolean - optional flag to turn on logging to stdout
@param opts.timeout integer - optional timeout in ms, default Infinity. Aborts with error.
@param opts.verbose boolean - optional flag to turn on debug output
@param opts.window integer - optional stabilization time in ms, default 750ms. Waits this amount of time for file sizes to stabilize or other resource availability to remain unchanged. If less than interval then will be reset to interval
@param cb optional callback function with signature cb(err) - if err is provided then, resource checks did not succeed
if not specified, wait-on will return a promise that will be rejected if resource checks did not succeed or resolved otherwise
Waits for resources to become available before calling callback