(filename)
| 7157 | // which we cannot parse. Also, this is more efficient than |
| 7158 | // receiving attachments as base64-encoded strings. |
| 7159 | async function fetchData(filename) { |
| 7160 | const att = atts[filename]; |
| 7161 | const path$$1 = encodeDocId(doc._id) + '/' + encodeAttachmentId(filename) + |
| 7162 | '?rev=' + doc._rev; |
| 7163 | |
| 7164 | const response = await ourFetch(genDBUrl(host, path$$1)); |
| 7165 | |
| 7166 | let blob; |
| 7167 | if ('buffer' in response) { |
| 7168 | blob = await response.buffer(); |
| 7169 | } else { |
| 7170 | /* istanbul ignore next */ |
| 7171 | blob = await response.blob(); |
| 7172 | } |
| 7173 | |
| 7174 | let data; |
| 7175 | if (opts.binary) { |
| 7176 | const typeFieldDescriptor = Object.getOwnPropertyDescriptor(blob.__proto__, 'type'); |
| 7177 | if (!typeFieldDescriptor || typeFieldDescriptor.set) { |
| 7178 | blob.type = att.content_type; |
| 7179 | } |
| 7180 | data = blob; |
| 7181 | } else { |
| 7182 | data = await new Promise(function (resolve) { |
| 7183 | blobToBase64(blob, resolve); |
| 7184 | }); |
| 7185 | } |
| 7186 | |
| 7187 | delete att.stub; |
| 7188 | delete att.length; |
| 7189 | att.data = data; |
| 7190 | } |
| 7191 | |
| 7192 | const promiseFactories = filenames.map(function (filename) { |
| 7193 | return function () { |
no test coverage detected
searching dependent graphs…