How to use is-online - 9 common examples

To help you get started, we’ve selected a few is-online examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github modulz / radix / packages / generate-icon-lib / src / services.ts View on Github external
export async function prechecks() {
  /* We can't work offline. */
  isOnline().then(isOn => {
    if (!isOn) {
      throw new CodedError(
        ERRORS.NETWORK_OFFLINE,
        'An internet connection is required to find and render Icons.',
        true
      );
    }
  });

  /* We don't want to end up deleted work-in-progress. */
  const [
    { stdout: trackedFiles },
    { stdout: untrackedFiles },
  ] = await Promise.all([
    // Checks for uncommitted changes.
    execa('git', ['diff-index', 'HEAD', './']),
github cgrossde / Pullover / src / app / services / ConnectionManager.js View on Github external
function checkInternetConnection() {
  debug.log('Checking internet connection')
  // Don't run more than one check concurrently
  if (checkingInternet) {
    return
  }
  else {
    checkingInternet = true
  }
  // Are we online?
  isOnline(function(err, internetOnline) {
    if (internetOnline) {
      // Is pushover reachable
      isReachable('api.pushover.net:443', function(error, reachable) {
        if (reachable) {
          debug.log('We are online again')
          clearInterval(checkInternetInterval)
          online()
        }
        checkingInternet = false
      })
    }
    else {
      checkingInternet = false
    }
  })
}
github VladimirIvanin / insales-uploader / lib / interface.js View on Github external
return new Promise(function (resolve, reject) {

    isOnline().then(online => {
      if (!online) {
        console.log('Не удалось скачать тему. Отсутствует соединение с интернетом!');
        resolve();
        return;
      }

      createDir(options, paths, action).then(() => {
        updateteAssets(conf, state).then(() => {
          getAssets(conf, action).then(function() {

            if (options.theme.startBackup && options.theme.backup === 'zip') {
              eventEmitter.emit('theme:zip:start', {
                message: `start zip`
              });

              zippedDir(paths, options.pathBackup, `${options.handle}-backup`, 'backup').then(function(data){
github willyb321 / media_mate / app / lib / rssparse.js View on Github external
constructor(rssFeed) {
		super(rssFeed);
		this.rssFeed = rssFeed;
		isOnline().then(online => {
			if (online === false) {
				this.emit('offline', online);
			} else {
				this.reqFeed();
			}
		});
	}
github jhwohlgemuth / tomo-cli / src / utils / index.js View on Github external
export async function populateQueue({concurrency = 1, tasks = [], dispatch = () => {}, options = {skipInstall: false}} = {}) {
    const {skipInstall} = options;
    const isNotOffline = skipInstall || await isOnline();
    const customOptions = assign({}, tasks.filter(complement(isValidTask)).reduce((acc, val) => assign(acc, val), options), {isNotOffline});
    const queue = new Queue({concurrency});
    dispatch({type: 'status', payload: {online: isNotOffline}});
    for (const [index, item] of tasks.filter(isValidTask).filter(isUniqueTask).entries()) {
        const {condition, task} = item;
        try {
            if (await condition(customOptions)) {
                await queue
                    .add(() => task(customOptions))
                    .then(() => dispatch({type: 'complete', payload: index}))
                    .catch(() => dispatch({
                        type: 'error', payload: {
                            index,
                            title: 'Failed to add task to queue',
                            location: 'task',
                            details: item.text
github nylas-mail-lives / nylas-mail / packages / client-app / src / flux / stores / online-status-store.es6 View on Github external
async _setNextOnlineState() {
    var nextIsOnline = await isOnline()
    if(!nextIsOnline) {
      nextIsOnline = await isOnline({version: 'v6'})
    }
    if (this._isOnline !== nextIsOnline) {
      this._isOnline = nextIsOnline
      this.trigger()
    }
  }
github dreamnettech / dreamtime / src / electron / src / modules / tools / system.js View on Github external
async setup() {
    const [
      graphics,
      os,
      cpu,
      mem,
      online,
    ] = await Promise.all([
      si.graphics(),
      si.osInfo(),
      si.cpu(),
      si.mem(),
      isOnline(),
    ])

    this._graphics = graphics
    this.os = os
    this.cpu = cpu
    this.memory = mem
    this.online = online

    logger.info(`GPU devices: ${this.graphics.length}`)
    logger.info(`RAM: ${this.memory.total} bytes.`)
    logger.info(`Internet connection: ${this.online}`)
    logger.debug(this)
  }
github christian-bromann / appium-hbbtv-driver / lib / proxy.js View on Github external
async preflightCheck () {
        this.log.info('doing preflight checks...')

        /**
         * make sure connection to TV was established
         * only log warning as we don't require a connection when using a launcher
         */
        if (!this.tvIPAddress) {
            this.log.error('Couldn\'t find a connection to TV. Please check network settings.')
        }

        /**
         * check internet connectivity
         */
        if (!await isOnline()) {
            throw new Error('Couldn\'t connect to the internet')
        }

        /**
         * check if devtools was build
         */
        if (!fs.existsSync(DEVTOOLS_PATH)) {
            throw new Error('Devtools frontend not found. Run `npm run build` to compile.')
        }

        this.log.info('preflight checks fine, no severe issues')
    }
github nylas-mail-lives / nylas-mail / packages / client-app / src / flux / stores / online-status-store.es6 View on Github external
async _setNextOnlineState() {
    var nextIsOnline = await isOnline()
    if(!nextIsOnline) {
      nextIsOnline = await isOnline({version: 'v6'})
    }
    if (this._isOnline !== nextIsOnline) {
      this._isOnline = nextIsOnline
      this.trigger()
    }
  }

is-online

Check if the internet connection is up

MIT
Latest version published 2 years ago

Package Health Score

59 / 100
Full package analysis

Popular is-online functions