add .toAuto to replicate previous behavior

This commit is contained in:
Conduitry 2018-11-07 06:42:10 -05:00
parent c82a037f97
commit 25fe25ab71
3 changed files with 6 additions and 1 deletions

View File

@ -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

View File

@ -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';

3
src/toAuto.js Normal file
View File

@ -0,0 +1,3 @@
import toBlob from './toBlob.js';
import toBuffer from './toBuffer.js';
export default files => (typeof Blob === 'undefined' ? toBuffer : toBlob)(files);