Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = function upload(stream, idOrPath, tag, done) {
var queries = new Array(global.parallelQueries);
var tx = db.begin();
for( var i = 0, len = queries.length; i < len; ++i ) {
queries[i] = FileVersion.insert({index: i}).execWithin(tx);
}
Promise.all(queries).then(function() {
tx.commit();
done();
}, function(err) {
tx.rollback();
done(err);
});
}
});
case 'MultiPolygon':
return doc.coordinates.forEach(function (coord) {
emit({
type: 'Polygon',
coordinates: coord
});
});
case 'GeometryCollection':
return doc.geometries.forEach(fixMulti);
default:
return emit(doc);
}
}
func(doc, fixMulti);
return Promise.all(emited);
}
var lastSeq;
}).then(function(names) {
var out = {};
return Promise.all(Object.keys(names).map(function(key) {
return readFile(names[key]).then(function(v) {
out[key] = v;
});
})).then(function() {
return out;
});
}).then(yes, no);
});
}).on('error', reject).on('end', function () {
resolve(Promise.all(promises).then(function () {
return Object.keys(out).map(function (id) {
return out[id];
});
}));
});
});
handlers.bulkDocs = function (orig, args) {
for (var i = 0; i < args.docs.length; i++) {
args.docs[i] = incoming(args.docs[i]);
}
return Promise.all(args.docs).then(function (docs) {
args.docs = docs;
return orig();
});
};
Store.prototype.batch = function(array, cb) {
var self = this;
return Promise.all(array.map(function (item) {
return new Promise(function (resolve, reject) {
function callback(err, value) {
if (err) {
reject(err);
} else {
resolve(value);
}
}
if (item.type === 'del') {
return self.del(item.key, callback);
}
return self.put(item.key, item.value, callback);
});
})).then(function () {
cb();
}, cb);
return getNames(pathString).then(function(names){
var out = {};
return Promise.all(Object.keys(names).map(function(key){
return readFiles(path.join(pathString, names[key])).then(function(v){
out[key] = v;
});
})).then(function(){
return out;
});
});
};
function doCouch1(baseUrl, auth) {
return Promise.all(requests.map(function (req) {
var urlString = formatUrl(baseUrl, auth, req.path);
return updateConfig(urlString, req.value);
}));
}