Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function processAction(action, context) {
if (_.isArray(action)) {
// Loop through each response validation step and verify
return Promise.mapSeries(action, single_action => processAction(single_action, context));
}
context.processed_actions.push(action);
if (action === true) {
return Promise.resolve(true);
}
if (action === false) {
return Promise.reject(exports.expected_failure);
}
throw new Error("Action type has not been implemented for mock-context");
}
return fs.truncateAsync(bucket._path).then(() => {
// This needs to be serialized because cacache explicitly
// lets very racy bucket conflicts clobber each other.
return BB.mapSeries(bucket, entry => {
const content = contentPath(cache, entry.integrity)
return fs.statAsync(content).then(() => {
return index.insert(cache, entry.key, entry.integrity, {
uid: opts.uid,
gid: opts.gid,
metadata: entry.metadata
}).then(() => { stats.totalEntries++ })
}).catch({code: 'ENOENT'}, () => {
stats.rejectedEntries++
stats.missingContent++
})
})
})
}
_runMigrationFunctions (migrations, functionName) {
const { logger, r } = this
const migrationsTable = this.migrationsTable
const migrateUp = functionName === FUNC_NAME_UP
return Promise.mapSeries(migrations, (migration) => {
const { id } = migration
const func = migration[functionName]
logger.info(migrateUp ? `↑ Running migration ${id}...` : `↓ Reverting migration ${id}...`)
const start = new Date()
// Call migration function, passing in the rethinkdb instance and the logger object
return func(r, logger)
.then(() => {
const completed = new Date()
this._registerOp(id, start, completed)
return { id, completed }
})
_sendQueueTrigger(chatId) {
const self = this;
const queue = this._sendQueues[chatId];
const sending = this._sending[chatId];
// if we are already processing the queue, or
// there is no queue, bolt!
if (sending || !queue) return;
this._sending[chatId] = true;
delete this._sendQueues[chatId];
debug("processing %d requests in send-queue for chat %s", queue.length, chatId);
Promise.mapSeries(queue, function(request) {
return request.method.apply(self, request.args)
.then(request.resolve)
.catch(request.reject);
}).then(function() {
debug("processing queue complete");
delete self._sending[chatId];
// trigger queue processing, as more requests might have been
// queued up while we were busy above
self._sendQueueTrigger(chatId);
});
}
const testExamples = (folders) => {
return bluebird.mapSeries(folders, testExample)
}
const detectHasMany = (databaseConnection, fields, collectionName) => {
const objectIdFields = fields.filter((field) => field.type === OBJECT_ID_ARRAY);
return P.mapSeries(
objectIdFields,
(objectIdField) => detectReference(databaseConnection, objectIdField, collectionName),
).then((references) => references.filter((reference) => reference));
};
module.exports.up = function createTables(options) {
var connection = options.connection;
return Promise.mapSeries(schemaTables, function createTable(table) {
logging.info('Creating table: ' + table);
return commands.createTable(table, connection);
});
};
return getVersionAndTables(options).then(function exportAllTables(result) {
tables = result.tables;
version = result.version;
return Promise.mapSeries(tables, function (tableName) {
return exportTable(tableName, options);
});
}).then(function formatData(tableData) {
var exportData = {
private async onAfterStateChanged(
voxaEvent: IVoxaIntentEvent,
reply: IVoxaReply,
transition: SystemTransition,
): Promise {
voxaEvent.log.debug("Running onAfterStateChangeCallbacks");
await bluebird.mapSeries(this.onAfterStateChangeCallbacks, (fn) => {
return fn(voxaEvent, reply, transition);
});
voxaEvent.log.debug("Transition is now", { transition });
return transition;
}
const getBands = requestArr =>
Promise.mapSeries(requestArr, item => requestBands(item));