Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
emulator.on('booted', function () {
var done = false;
opts.logger && opts.logger.info(__('Emulator is booted'));
if (!opts.checkMounts || !emu.sdcard) {
// nothing to do, fire ready event
opts.logger && opts.logger.info(__('SD card not required, skipping mount check'));
emulator.emit('ready', emulator);
return;
}
opts.logger && opts.logger.info(__('Checking if SD card is mounted'));
// keep polling /sdcard until it's mounted
async.whilst(
function () { return !done; },
function (cb) {
// emulator is running, now shell into it and check if it has booted
adb.shell(deviceId, 'cd /sdcard && echo "SDCARD READY"', function (err, output) {
if (!err && output.toString().split('\n').shift().trim() == 'SDCARD READY') {
done = true;
cb();
} else {
setTimeout(cb, retryTimeout);
}
});
}.bind(this),
function () {
var mounted = false,
schema.pre('save', function(next) {
var self = this;
var pending_attachments = this[PENDING_PROP];
console.log("SAVE with pending attachments:", pending_attachments);
async.whilst(
function filesRemain() {
return pending_attachments && pending_attachments.length;
},
function processNextFile(callback) {
process_next.call(self, pending_attachments, callback);
},
function complete(err) {
while(pending_attachments && pending_attachments.length) pending_attachments.shift(); // Can't just set =[] because the property is not writeable
if (err) return next(new Error(err));
else return next(); // TODO: figure out why return next(err) doesn't work by itself
}
);
});
};
if (!teamConfig) {
// The user does not have a team, so just treat the repos config
// as manually edited
return bosco.error([
'Looks like you havent linked this workspace to a team? Try: ',
'bosco team setup'.green,
'. If you can\'t see your team in the list, Try: ',
'bosco team sync'.green
].join(''));
}
bosco.log('Fetching repository list from Github for ' + team.green + ' team ...');
var more = true;
var page = 1;
var repoList = [];
async.whilst(
function () { return more; },
function (callback) {
getRepoList(client, teamConfig, page, function (err, repos, isMore) {
if (err) { return callback(err); }
repoList = _.union(repoList, repos);
if (isMore) {
page += 1;
} else {
more = false;
}
callback();
});
},
function (err) {
if (err) {
return bosco.error(err.message);
let stddev = 0;
for (let i = 0; i < timings.length; i++) {
const time = timings[i];
avg += time;
stddev += Math.pow(time, 2);
}
avg /= timings.length;
stddev /= timings.length;
stddev -= Math.pow(avg, 2);
stddev = Math.sqrt(stddev);
callback(null, { avg, stddev });
}
async.whilst(() => {
return i++ < REPEAT;
}, (callback) => {
client.request(body, (err, time) => {
if (err)
return callback(err);
timings.push(time);
callback(null);
});
}, onDone);
}
watch: function (callback) {
callback = (callback || function(){})
this.started = Date.now()
async.whilst(this.isMatch.bind(this), this.delay.bind(this), function(err){
this.cleanup()
return callback(err)
}.bind(this))
},
function performStep(){
if (stopAnimationRequest){
stopAnimation();
return;
}
var level = 0.01,
dir = step;
async.whilst(function(){
return (level >= 0.0 && !stopAnimationRequest);
},function (callback) {
setTimeout(function(){
leds.setMasterBrightness(level);
leds.fill(new Color({r: r, g: g, b: b}));
if(level >= 0.99){
dir =- step;
}
level += dir;
callback();
},4);
}, function (err) {
process.nextTick(performStep);
});
}
performStep();
flush(cb: any): void {
const it = this._cache.begin
let next = true
asyncLib.whilst(
() => next,
(done: any) => {
if (it.value && it.value.modified) {
it.value.modified = false
it.value.val = it.value.val.serialize()
this._trie.put(Buffer.from(it.key, 'hex'), it.value.val, (err: Error) => {
if (err) return done(err)
next = it.hasNext
it.next()
done()
})
} else if (it.value && it.value.deleted) {
it.value.modified = false
it.value.deleted = false
it.value.val = new Account().serialize()
this._trie.del(Buffer.from(it.key, 'hex'), (err: Error) => {
self.getNetwork(function (err, network) {
if (err) {
return setImmediate(cb, err);
} else {
async.whilst(
function () {
return !loaded && errorCount < 5;
},
function (next) {
var peer = network.peers[Math.floor(Math.random() * network.peers.length)];
var lastBlock = modules.blocks.lastBlock.get();
function loadBlocks () {
__private.blocksToSync = peer.height;
modules.blocks.process.loadBlocksFromPeer(peer, function (err, lastValidBlock) {
if (err) {
library.logger.error(err.toString());
library.logger.error('Failed to load blocks from: ' + peer.string);
errorCount += 1;
}
collection.find(criteria, function(err, cursor) {
if (err) {
return callback(err);
}
var done = false;
async.whilst(function() { return !done; }, function(callback) {
return cursor.nextObject(function(err, page) {
if (err) {
return callback(err);
}
if (!page) {
done = true;
return callback(null);
}
return each(page, callback);
});
}, callback);
});
};
var adunit = query.adunit;
if (!endTime) {
endTime = Date.now();
}
var keyTemplate = 'm|$date';
if (publisher) keyTemplate += '|0:' + publisher;
if (advertiser) keyTemplate += '|1:' + advertiser;
if (adunit) keyTemplate += '|2:' + adunit;
var minute = (60 * 1000);
var result = [];
var time = endTime - lookbackMinutes * minute;
async.whilst(
function () { return time <= endTime; },
function (callback) {
var date = dateFormat(time, 'UTC:yyyymmddHHMM');
var key = keyTemplate
.replace('$date', date);
client.hgetall(key, function(err, hash) {
if (hash) {
var minuteItem = {
timestamp: time,
keyPattern: keyTemplate,
cost: parseFloat(hash[1]),
revenue: parseFloat(hash[2]),
impressions: parseFloat(hash[3]),
clicks: parseFloat(hash[4])
}