Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function preprocessString(att, blobType, callback) {
var asBinary = parseBase64(att.data);
if (asBinary.error) {
return callback(asBinary.error);
}
att.length = asBinary.length;
if (blobType === 'blob') {
att.data = binStringToBlobOrBuffer(asBinary, att.content_type);
} else if (blobType === 'base64') {
att.data = btoa(asBinary);
} else { // binary
att.data = asBinary;
}
binaryMd5(asBinary, function (result) {
att.digest = 'md5-' + result;
callback();
});
}
function preprocessBlob(att, blobType, callback) {
binaryMd5(att.data, function (md5) {
att.digest = 'md5-' + md5;
// size is for blobs (browser), length is for buffers (node)
att.length = att.data.size || att.data.length || 0;
if (blobType === 'binary') {
blufferToBinaryString(att.data, function (binString) {
att.data = binString;
callback();
});
} else if (blobType === 'base64') {
blufferToBase64(att.data, function (b64) {
att.data = b64;
callback();
});
} else {
callback();
}
var promiseForView = sourceDB.info().then(function (info) {
var depDbName = info.db_name + '-mrview-' +
(temporary ? 'temp' : stringMd5(viewSignature));
// save the view name in the source db so it can be cleaned up if necessary
// (e.g. when the _design doc is deleted, remove all associated view data)
function diffFunction(doc) {
doc.views = doc.views || {};
var fullViewName = viewName;
if (fullViewName.indexOf('/') === -1) {
fullViewName = viewName + '/' + viewName;
}
var depDbs = doc.views[fullViewName] = doc.views[fullViewName] || {};
/* istanbul ignore if */
if (depDbs[depDbName]) {
return; // no update necessary
}
depDbs[depDbName] = true;
return doc;
return function (data) {
pouchdbMd5.binaryMd5(data, onMD5Load(doc, key, data, attachmentSaved));
};
}
return new Promise(function (resolve) {
binaryMd5(queryData, resolve);
});
}).then(function (md5sum) {
return function (data) {
binaryMd5(data, onMD5Load(doc, key, data, attachmentSaved))
}
}
return function (data) {
pouchdbMd5.binaryMd5(data, onMD5Load(doc, key, data, attachmentSaved));
};
}
return new Promise(function (resolve) {
md5(binData, function (result) {
attachment.digest = 'md5-' + result;
attachment.length = binData.size || binData.length || 0;
resolve(attachment);
});
});
}
function getMd5() {
return md5 || (md5 = stringMd5(JSON.stringify(requestDef)));
}
function rev(doc, deterministic_revs) {
var clonedDoc = clone(doc);
if (!deterministic_revs) {
return uuid.v4().replace(/-/g, '').toLowerCase();
}
delete clonedDoc._rev_tree;
return stringMd5(JSON.stringify(clonedDoc));
}