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

Function fetchAttachment

lib/index.js:4972–5002  ·  view source on GitHub ↗
(att, stores, opts)

Source from the content-addressed store, hash-verified

4970}
4971
4972function fetchAttachment(att, stores, opts) {
4973 var type = att.content_type;
4974 return new Promise(function (resolve, reject) {
4975 stores.binaryStore.get(att.digest, function (err, buffer) {
4976 var data;
4977 if (err) {
4978 /* istanbul ignore if */
4979 if (err.name !== 'NotFoundError') {
4980 return reject(err);
4981 } else {
4982 // empty
4983 if (!opts.binary) {
4984 data = '';
4985 } else {
4986 data = binStringToBluffer('', type);
4987 }
4988 }
4989 } else { // non-empty
4990 if (opts.binary) {
4991 data = readAsBlobOrBuffer(buffer, type);
4992 } else {
4993 data = buffer.toString('base64');
4994 }
4995 }
4996 delete att.stub;
4997 delete att.length;
4998 att.data = data;
4999 resolve();
5000 });
5001 });
5002}
5003
5004function fetchAttachments(results, stores, opts) {
5005 var atts = [];

Callers 1

fetchAttachmentsFunction · 0.70

Calls 4

binStringToBlufferFunction · 0.70
readAsBlobOrBufferFunction · 0.70
getMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…