How to use deasync - 10 common examples

To help you get started, we’ve selected a few deasync 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 JBader89 / PlugBot / node_modules / plugAPI / src / client.js View on Github external
if (fs.existsSync(_cookies.path)) {
            _cookies.load();
            request.get('https://plug.dj/_/users/me', {
                headers: {
                    'User-Agent': 'plugAPI_' + PlugAPIInfo.version,
                    Cookie: _cookies.toString()
                }
            }, function(err, res) {
                if (res.statusCode === 200) {
                    loggedIn = true;
                }
                loggingIn = false;
            });
            // Wait until the session is set
            while (loggingIn) {
                deasync.sleep(100);
            }
        }
        if (!loggedIn) {
            loggingIn = true;

            request.get('https://plug.dj/', {
                headers: {
                    'User-Agent': 'plugAPI_' + PlugAPIInfo.version,
                    Cookie: _cookies.toString()
                }
            }, function(err, res, body) {
                var csrfToken;

                _cookies.fromHeaders(res.headers);

                csrfToken = body.split('_csrf')[1].split('"')[1];
github qminer / qminer / src / nodejs / datasets / datasets.js View on Github external
base: _base
        }

        console.log('Loading dataset ' + options.store + ' ...');
        _base.loadCSV(options, function (err) {
            if (err) return callback(err);
            
            var Iris = _base.store(options.store);
            console.log(options.store + ' dataset loaded')

            finished = true;
        })

        // Used deasync module to turn this function into sync. 
        while (finished == false) {
            require('deasync').runLoopOnce();
        }
        return _base.store(options.store);
    }
github qminer / qminer / nodedoc / datasetsdoc.js View on Github external
base: _base
        }

        console.log('Loading dataset ' + options.store + ' ...');
        _base.loadCSV(options, function (err) {
            if (err) return callback(err);
            
            var Iris = _base.store(options.store);
            console.log(options.store + ' dataset loaded')

            finished = true;
        })

        // Used deasync module to turn this function into sync. 
        while (finished == false) {
            require('deasync').runLoopOnce();
        }
        return _base.store(options.store);
    }
github qminer / qminer / src / nodejs / intellisense / datasets_intellisense.js View on Github external
base: _base
        }

        console.log('Loading dataset ' + options.store + ' ...');
        _base.loadCSV(options, function (err) {
            if (err) return callback(err);
            
            var Iris = _base.store(options.store);
            console.log(options.store + ' dataset loaded')

            finished = true;
        })

        // Used deasync module to turn this function into sync. 
        while (finished == false) {
            require('deasync').runLoopOnce();
        }
        return _base.store(options.store);
    }
github gazooka / GhostInAzureWebApp / postinstall.js View on Github external
.on('error', function () {
			logging.error('Failed to create server.cache.js.gz');
			compressionFinished = true;
		})
		.pipe(output)
		.on('finish', function () {
			logging.info('Created server.cache.js.gz');
			compressionFinished = true;
		})
		.on('error', function () {
			logging.error('Failed to create server.cache.js.gz');
			compressionFinished = true;
		});

	// wait for compression to complete
	deasync.loopWhile(function(){return !compressionFinished;});
}
github oxygenhq / oxygen / src / core / OxygenCore.js View on Github external
step.stats = module._getStats(methodName);
        } else {
            step.stats = {};
        }
    
        if (err) {
            step.failure = errorHelper.getFailureFromError(err);
            // let the module decide whether a screenshot should be taken on error or not
            if (typeof module._takeScreenshot === 'function') {
                try {
                    step.screenshot = module._takeScreenshot(methodName);
                }
                catch (e) {
                    // If we are here, we were unable to get a screenshot
                    // Try to wait for a moment (in Perfecto Cloud, the screenshot might not be immidiately available)
                    deasync.sleep(1000);
                    try {
                        step.screenshot = module._takeScreenshot(methodName);
                    }
                    catch (e) {
                        // FIXME: indicate to user that an attempt to take a screenshot has failed
                    }
                }
            }
        }
        return step;
    }
github oxygenhq / oxygen / lib / script-boilerplate.js View on Github external
var lineColumn = getLineAndColumnFromStacktrace(err, scriptPath);
            if (lineColumn) {
                err.line = lineColumn.line;
                err.column = lineColumn.column;
            }
        }
        step.failure._line = err.line;
        // let the module decide whether a screenshot should be taken on error or not
        if (typeof module._takeScreenshot === 'function') {
            try {
                step.screenshot = module._takeScreenshot(methodName);
            }
            catch (e) {
                // If we are here, we were unable to get a screenshot
                // Try to wait for a moment (in Perfecto Cloud, the screenshot might not be immidiately available)
                deasync.sleep(1000);
                try {
                    step.screenshot = module._takeScreenshot(methodName);
                }
                catch (e) {
                    // FIXME: indicate to user that an attempt to take a screenshot has failed
                }
            }
        }
    }
    rs.steps.push(step);
}
github pannous / angle / angle.js / extensions.js View on Github external
downloadSync2 = wget2 = (url) => {
	ret = undefined// global hack
	fetch(urlify(url)).then(response => response.text().then(data => ret = data))
	while (ret === undefined) {
		require('deasync').runLoopOnce();
	}
	return ret
}
github wix / redux-testkit / src / mockStore.js View on Github external
dispatchSync(action) {
    let done = false;
    let result;
    action(this.mockDispatch, this.getState).then((r) => {
      result = r;
      done = true;
    });
    require('deasync').loopWhile(() => !done);
    //require('deasync').sleep(100);
    return result;
  }
github Strider-CD / core / test / helpers / persistence.js View on Github external
beforeEach: function (cb) {
      mongoose.connect(config.mongoDbURI)
      require('deasync').loopWhile(function () {
        return mongoose.connection.readyState !== 1
      })
      cb()
    },
    afterEach: function (cb) {

deasync

Turns async function into sync via JavaScript wrapper of Node event loop

MIT
Latest version published 7 months ago

Package Health Score

66 / 100
Full package analysis