How to use the deasync.sleep function in deasync

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 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 adobe / node-smb-server / spec / lib / test-fs.js View on Github external
TestFS.prototype.statSync = function (filePath) {
  var self = this;
  var sync = true;
  var data = null;
  var syncErr = null;
  self.stat(filePath, function(err, stat) {
    data = stat;
    syncErr = err;
    sync = false;
  });
  while(sync) {require('deasync').sleep(100);}

  if (syncErr) {
    throw syncErr;
  }

  return data;
};
github enb / enb / test / lib / build-flow.js View on Github external
change(target) {
                    const filename = _getFilename(target);

                    deasync.sleep(10);

                    fs.writeFileSync(filename, 'new-value');
                },
                fileInfo(target) {
github ash47 / TheyAreBillionsModKit / Broken Stuff / MapEditor / index.js View on Github external
}
		}
	}

	var done = false;

	newImage.writeImage(newFilename, function(err) {
		if(err) throw err;

		console.log('wrote merged image');

		done = true;
	});

	while(!done) {
		deasync.sleep(1);
	}

	return newImage;
}
github Digiturk / wface / packages / cli / bin / commands / version / index.js View on Github external
function getLatest(packageName) {
  var sync = true;
  var data = null;
  npm.load({ parseable: true }, function (er, npm) {
    if (er) {
      sync = false;
      return cb(er);
    }
    npm.commands.show([packageName, "version"], true, (version,x) => {      
      data = x;
      sync = false;
    });
  })
  while(sync) {require('deasync').sleep(100);}
  return  Object.keys(data)[0];
}
github ash47 / TheyAreBillionsModKit / Broken Stuff / MapEditor / index.js View on Github external
function readImageSync(fileLocation) {
	var toReturn = null;

	PNGImage.readImage(fileLocation, function (err, image) {
	    if (err) throw err;

	    toReturn = image;
	});

	while(toReturn == null) {
		deasync.sleep(1);
	}

	return toReturn;
}
github unimonkiez / react-cordova-boilerplate / bin / get-webpack-config.js View on Github external
);

  let sync = true;
  let data = null;
  compiler.outputFileSystem = fs;
  compiler.run(err => {
    if (err) {
      throw err;
    }
    const fileContent = fs.readFileSync(bundlePath).toString('ascii');
    data = requireFromString(fileContent);
    sync = false;
  });

  while (sync) {
    deasync.sleep(100);
  }

  return data;
};
github codejamninja / reactant / packages / core / src / config / ports.js View on Github external
setBasePort() {
    this.getBasePort().then(basePort => {
      this.basePort = basePort;
    });
    while (!this.basePort) sleep(100);
    return true;
  }

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