diff --git a/README.md b/README.md index 8cc35b9..a7accc2 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,8 @@ const output = doNotZip.toArray([ { path: 'yet/another/file3.bin', data: [1, 2, 3, 4, 5] }, ]); // => output will be an array of bytes -// use .toBuffer on the server to generate a Buffer, and use .toBlob on the client to generate a Blog +// use .toBuffer on the server to generate a Buffer, and use .toBlob on the client to generate a Blob +// use .toAuto to generate a Buffer on the server or a Blob on the client ``` ## Thanks diff --git a/src/index.js b/src/index.js index 64f43d8..1f7fcac 100644 --- a/src/index.js +++ b/src/index.js @@ -1,3 +1,4 @@ export { default as toArray } from './toArray.js'; +export { default as toAuto } from './toAuto.js'; export { default as toBlob } from './toBlob.js'; export { default as toBuffer } from './toBuffer.js'; diff --git a/src/toAuto.js b/src/toAuto.js new file mode 100644 index 0000000..4cba5d0 --- /dev/null +++ b/src/toAuto.js @@ -0,0 +1,3 @@ +import toBlob from './toBlob.js'; +import toBuffer from './toBuffer.js'; +export default files => (typeof Blob === 'undefined' ? toBuffer : toBlob)(files);