MCPcopy Index your code
hub / github.com/apache/pouchdb / fetchData

Function fetchData

lib/index.js:7159–7190  ·  view source on GitHub ↗
(filename)

Source from the content-addressed store, hash-verified

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 () {

Callers 3

fetchAttachmentsFunction · 0.70
fetchedFunction · 0.70
HttpPouchFunction · 0.70

Calls 8

encodeDocIdFunction · 0.70
encodeAttachmentIdFunction · 0.70
ourFetchFunction · 0.70
genDBUrlFunction · 0.70
blobToBase64Function · 0.70
paramsToStrFunction · 0.70
setupFunction · 0.70
fetchJSONFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…