Skip to content

Commit 1e69c31

Browse files
authored
indexeddb.bulkDocs(): inline parseBase64() (#8793)
1 parent 10d9edc commit 1e69c31

1 file changed

Lines changed: 4 additions & 13 deletions

File tree

  • packages/node_modules/pouchdb-adapter-indexeddb/src

‎packages/node_modules/pouchdb-adapter-indexeddb/src/bulkDocs.js‎

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,6 @@ export default function (api, req, opts, metadata, dbOpts, idbChanges, callback)
4444
return doc.rev_tree[0].ids[1].status === 'missing';
4545
}
4646

47-
function parseBase64(data) {
48-
try {
49-
return atob(data);
50-
} catch (e) {
51-
return {
52-
error: createError(BAD_ARG, 'Attachment is not a valid base64 string')
53-
};
54-
}
55-
}
56-
5747
// Reads the original doc from the store if available
5848
// As in allDocs with keys option using multiple get calls is the fastest way
5949
function fetchExistingDocs(txn, docs) {
@@ -327,9 +317,10 @@ export default function (api, req, opts, metadata, dbOpts, idbChanges, callback)
327317

328318
var binData;
329319
if (typeof attachment.data === 'string') {
330-
binData = parseBase64(attachment.data);
331-
if (binData.error) {
332-
return Promise.reject(binData.error);
320+
try {
321+
binData = atob(attachment.data);
322+
} catch (e) {
323+
return Promise.reject(createError(BAD_ARG, 'Attachment is not a valid base64 string'));
333324
}
334325
attachment.data = binStringToBlobOrBuffer(binData, attachment.content_type);
335326
} else {

0 commit comments

Comments
 (0)