Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function readAsBlobOrBuffer(storedObject, type) {
// In the browser, we've stored a binary string. This now comes back as a
// browserified Node-style Buffer (implemented as a typed array),
// but we want a Blob instead.
var byteArray = new Uint8Array(storedObject);
return createBlob([byteArray], {type: type});
}
function readAsBlobOrBuffer(storedObject, type) {
// In the browser, we've stored a binary string. This now comes back as a
// browserified Node-style Buffer (implemented as a typed array),
// but we want a Blob instead.
var byteArray = new Uint8Array(storedObject);
return createBlob([byteArray], {type: type});
}
function readAsBlobOrBuffer(storedObject, type) {
// In the browser, we've stored a binary string. This now comes back as a
// browserified Node-style Buffer (implemented as a typed array),
// but we want a Blob instead.
var byteArray = new Uint8Array(storedObject);
return pouchdbBinaryUtils.blob([byteArray], {type: type});
}
return new Promise(function (resolve) {
var blob = createBlob(['']);
var req = txn.objectStore(DETECT_BLOB_SUPPORT_STORE).put(blob, 'key');
req.onsuccess = function () {
var matchedChrome = navigator.userAgent.match(/Chrome\/(\d+)/);
var matchedEdge = navigator.userAgent.match(/Edge\//);
// MS Edge pretends to be Chrome 42:
// https://msdn.microsoft.com/en-us/library/hh869301%28v=vs.85%29.aspx
resolve(matchedEdge || !matchedChrome ||
parseInt(matchedChrome[1], 10) >= 43);
};
req.onerror = txn.onabort = function (e) {
// If the transaction aborts now its due to not being able to
// write to the database, likely due to the disk being full
e.preventDefault();
e.stopPropagation();
function readBlobData(body, type, asBlob, callback) {
if (asBlob) {
if (!body) {
callback(createBlob([''], {type: type}));
} else if (typeof body !== 'string') { // we have blob support
callback(body);
} else { // no blob support
callback(b64StringToBlob(body, type));
}
} else { // as base64 string
if (!body) {
callback('');
} else if (typeof body !== 'string') { // we have blob support
readAsBinaryString(body, function (binary) {
callback(btoa(binary));
});
} else { // no blob support
callback(body);
}
}
function createEmptyBlobOrBuffer(type) {
return createBlob([''], {type: type});
}
xhr.onreadystatechange = function () {
if (xhr.readyState !== 4) {
return;
}
var response = {
statusCode: xhr.status
};
if (xhr.status >= 200 && xhr.status < 300) {
var data;
if (options.binary) {
data = createBlob([xhr.response || ''], {
type: xhr.getResponseHeader('Content-Type')
});
} else {
data = xhr.responseText;
}
callback(null, response, data);
} else {
var err = {};
if (timedout) {
err = new Error('ETIMEDOUT');
err.code = 'ETIMEDOUT';
} else if (typeof xhr.response === 'string' && xhr.response !== '') {
try {
err = JSON.parse(xhr.response);
} catch (e) {}
}
function createEmptyBlobOrBuffer(type) {
return pouchdbBinaryUtils.blob([''], {type: type});
}
function createBlobOrBufferFromParts(parts, type) {
return createBlob(parts, {type: type});
}