Table of Contents

Class WritableStreamDefaultWriter

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

The WritableStreamDefaultWriter interface of the Streams API is the object returned by GetWriter() and once created locks the writer to the WritableStream ensuring that no other streams can write to the underlying sink.

[Value("WritableStreamDefaultWriter")]
public class WritableStreamDefaultWriter
Inheritance
WritableStreamDefaultWriter
Derived
Inherited Members

Remarks

Constructors

WritableStreamDefaultWriter()

public WritableStreamDefaultWriter()

WritableStreamDefaultWriter(WritableStream)

The WritableStreamDefaultWriter()
constructor creates a new WritableStreamDefaultWriter object instance.

public WritableStreamDefaultWriter(WritableStream stream)

Parameters

stream WritableStream

Remarks

NOTE

You generally wouldn't use this constructor manually; instead,
you'd use the GetWriter() method.

See also on MDN

Properties

Closed

The closed read-only property of the
WritableStreamDefaultWriter interface returns a
Promise that fulfills if the stream becomes closed, or rejects if
the stream errors or the writer's lock is released.

[Value("closed")]
public Task<GlobalObject.Undefined> Closed { get; }

Property Value

Task<GlobalObject.Undefined>

A Promise.

Remarks

DesiredSize

The desiredSize read-only property of the
WritableStreamDefaultWriter interface returns the desired size required
to fill the stream&apos;s internal queue.

[Value("desiredSize")]
public double? DesiredSize { get; }

Property Value

double?

An integer. Note that this can be negative if the queue is over-full.The value will be null if the stream cannot be successfully written to
(due to either being errored, or having an abort queued up), and zero if the stream is
closed.

Remarks

Ready

The ready read-only property of the
WritableStreamDefaultWriter interface returns a {{jsxref("Promise")}}
that resolves when the desired size of the stream&apos;s internal queue transitions from
non-positive to positive, signaling that it is no longer applying backpressure.

[Value("ready")]
public Task<GlobalObject.Undefined> Ready { get; }

Property Value

Task<GlobalObject.Undefined>

A Promise.

Remarks

Methods

Abort(dynamic)

The abort() method of the
WritableStreamDefaultWriter interface aborts the stream, signaling that
the producer can no longer successfully write to the stream and it is to be immediately
moved to an error state, with any queued writes discarded.

[Value("abort")]
public Task<GlobalObject.Undefined> Abort(dynamic reason = null)

Parameters

reason dynamic

Returns

Task<GlobalObject.Undefined>

A Promise, which fulfills to undefined when the stream is aborted, or
rejects with an error if the writer was inactive or the receiver stream is invalid.

Remarks

If the writer is active, the abort() method behaves the same as that for
the associated stream (Abort(dynamic)). If not, it returns a
rejected promise.

See also on MDN

Close()

The close() method of the
WritableStreamDefaultWriter interface closes the associated writable
stream.

[Value("close")]
public Task<GlobalObject.Undefined> Close()

Returns

Task<GlobalObject.Undefined>

A Promise, which fulfills with the undefined if all
remaining chunks were successfully written before the close, or rejects with an error if
a problem was encountered during the process.

Remarks

The underlying sink will finish processing any previously-written chunks, before
invoking the close behavior. During this time any further attempts to write will fail
(without erroring the stream).

See also on MDN

ReleaseLock()

The releaseLock() method of the
WritableStreamDefaultWriter interface releases the writer's lock on the
corresponding stream. After the lock is released, the writer is no longer active. If the
associated stream is errored when the lock is released, the writer will appear errored
in the same way from now on; otherwise, the writer will appear closed.

[Value("releaseLock")]
public GlobalObject.Undefined ReleaseLock()

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

Write(dynamic)

The write() method of the
WritableStreamDefaultWriter interface writes a passed chunk of data to a
WritableStream and its underlying sink, then returns a
Promise that resolves to indicate the success or failure of the write
operation.

[Value("write")]
public Task<GlobalObject.Undefined> Write(dynamic chunk = null)

Parameters

chunk dynamic

Returns

Task<GlobalObject.Undefined>

A Promise, which fulfills with the undefined upon a
successful write, or rejects if the write fails or stream becomes errored before the
writing process is initiated.

Remarks

Note that what &quot;success&quot; means is up to the underlying sink; it might indicate that the
chunk has been accepted, and not necessarily that it is safely saved to its ultimate
destination.

See also on MDN