Skip to content

Commit

Permalink
feat(utils): export some useful pipe-related util functions
Browse files Browse the repository at this point in the history
  • Loading branch information
bericp1 committed Apr 9, 2019
1 parent 3845374 commit a532af7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,16 @@ for inline documentation and types.
- `async geDisk(name: string, options: DiskManagerOptions): Disk` to get a disk by name (allowing
for aliases in config).

### Utils

This library also exports some helper methods:

- `async pipeStreams(readable: Readable, writable: Writable): Promise<string>` pipes a readable stream into a
writable stream and waits until it completes. It will reject if the pipe stream emits an error and will otherwise
resolve with the name of the event that the stream closed with (i.e. `'close'` or `'finish'`).
- `async streamToBuffer(stream: Readable): Promise<Buffer>` pipes a readable stream into a single buffer. Rejects if
the stream emits an error.

## TODO

- [ ] Make the `MemoryDisk` test generic to run on any `Disk` and figure out how to run it safely with `LocalDisk`
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ export * from './lib/types';
export * from './lib/fs/types';
export * from './lib/DiskManager';
export * from './lib/Disk';
export { pipeStreams, streamToBuffer } from './lib/utils';
export * from './drivers/s3/S3Disk';
export * from './drivers/s3/types';
export * from './drivers/local/LocalDisk';
export * from './drivers/local/types';
export * from './drivers/memory/MemoryDisk';
export * from './errors'
export * from './'

// Kept around for backwards compatibility.
export const errors = allErrors;
Expand Down

0 comments on commit a532af7

Please sign in to comment.