pear-opwait
v1.0.0
Published
Pear operation stream promise wrapper
Readme
pear-opwait
Pear operation stream promise wrapper
API
opwait(stream[, onstatus])
Waits for a stream that emits status objects { tag, data }.
Resolves with the final payload, forwards errors while allowing observation of intermediate statuses.
Returns Promise<any> of the final data.
Arguments
stream:Readableemitting{ tag, data }onstatus:(status) => void|Promise<void>optional observer for each status
Behavior
- Listens to
data,end,error tag === 'final'→ storesdataas resolution valuetag === 'error'→ destroys stream withERR_OPERATION_FAILED(message, data)onstatusmay be async; rejection throws into the stream viadestroy(err)- Promise resolves on
endwith last seenfinal(ornullif none) - Promise rejects on
errorfrom the stream (including wrapped operation errors)
License
Apache-2.0
