Skip to content

Commit 9c60a54

Browse files
espyhulkoba
authored andcommitted
fix: separate arrayBufferToBlobOrBuffer helpers per env, so rollup can avoid adding a superfluous Buffer polyfill in the build.
1 parent b8c9c08 commit 9c60a54

3 files changed

Lines changed: 10 additions & 7 deletions

File tree

packages/node_modules/pouchdb-binary-utils/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"./src/binaryStringToBlobOrBuffer.js": "./src/binaryStringToBlobOrBuffer-browser.js",
2121
"./src/blobOrBufferToBase64.js": "./src/blobOrBufferToBase64-browser.js",
2222
"./src/blobOrBufferToBinaryString.js": "./src/blobOrBufferToBinaryString-browser.js",
23-
"./src/typedBuffer.js": "./src/typedBuffer-browser.js"
23+
"./src/typedBuffer.js": "./src/typedBuffer-browser.js",
24+
"./src/arrayBufferToBlobOrBuffer.js": "./src/arrayBufferToBlobOrBuffer-browser.js"
2425
}
2526
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import blob from 'pouchdb-binary-utils/src/blob';
2+
3+
function arrayBufferToBlobOrBuffer(arrayBuffer, type) {
4+
// In the browser, create a Blob
5+
return blob([arrayBuffer], { type });
6+
}
7+
8+
export default arrayBufferToBlobOrBuffer;

packages/node_modules/pouchdb-binary-utils/src/arrayBufferToBlobOrBuffer.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import blob from './blob';
2-
31
function arrayBufferToBlobOrBuffer(arrayBuffer, type) {
4-
// In the browser, create a Blob
5-
if (typeof process === 'undefined' || process.browser) {
6-
return blob([arrayBuffer], { type });
7-
}
82
// In Node.js, create a Buffer
93
const buffer = Buffer.from(arrayBuffer);
104
/* PouchDB uses `type` in various places, see `packages/node_modules/pouchdb-binary-utils/src/typedBuffer.js`

0 commit comments

Comments
 (0)