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();
}
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);
});
});
}