From 25fe25ab71e4b9bc36bc3b04453cabd2c44bd20b Mon Sep 17 00:00:00 2001 From: Conduitry Date: Wed, 7 Nov 2018 06:42:10 -0500 Subject: [PATCH] add .toAuto to replicate previous behavior --- README.md | 3 ++- src/index.js | 1 + src/toAuto.js | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 src/toAuto.js 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);