| [ Web Proxy ] |
| Viewing: https://developers.cloudflare.com/workers/runtime-apis/streams/writablestream/ | [Back] [Original] |
A WritableStream is the writable property of a TransformStream. On the Workers platform, WritableStream cannot be directly created using the WritableStream constructor.
A typical way to write to a WritableStream is to pipe a ReadableStream to it.
readableStream
.pipeTo(writableStream)
.then(() => console.log('All data successfully written!'))
.catch(e => console.error('Something went wrong!', e));
To write to a WritableStream directly, you must use its writer.
const writer = writableStream.getWriter();
writer.write(data);
Refer to the WritableStreamDefaultWriter documentation for further detail.
locked boolean
abort(reasonstringoptional) : Promise<void>
undefined. reason is an optional human-readable string indicating the reason for cancellation. reason will be passed to the underlying sinks abort algorithm. If this writable stream is one side of a TransformStream, then its abort algorithm causes the transforms readable side to become errored with reason.Warning
Any data not yet written is lost upon abort.
getWriter() : WritableStreamDefaultWriter
WritableStreamDefaultWriter and locks the WritableStream to that writer instance.| Web Proxy Viewer | New URL | Original Page |