Skip to content

Class: FileWritableStream

Documentation / @wtf/platform-fs / writable / FileWritableStream

Defined in: packages/platform-fs/src/writable.ts:90

The writable of a file, a WritableStream of the standard’s chunks, over sink: each written where it is, or where a write says, and the file grown with zeros to a write past its end; a seek moves where it writes, and a truncate cuts or grows the file, and moves where it writes back to its end where that is past it. size is what the file holds as it opens, as of keepExistingData. A write as an object of no data, position or size its type needs is a SyntaxError, a DOMException, and data of null, or a number that is no whole one from 0, a TypeError. A chunk that fails aborts the sink, and errors the writable: the file is as it was. Its close() puts what was written in the file’s place; its abort() leaves it.

Extends

Implements

Constructors

Constructor

new FileWritableStream(sink, size?): FileWritableStream;

Defined in: packages/platform-fs/src/writable.ts:94

Parameters

ParameterTypeDefault value
sinkWritableSinkundefined
sizenumber0

Returns

FileWritableStream

Overrides

WritableStream<FileSystemWriteChunk>.constructor

Properties

PropertyModifierTypeDescriptionInherited fromDefined in
lockedreadonlybooleanThe locked read-only property of the WritableStream interface returns a boolean indicating whether the WritableStream is locked to a writer. MDN ReferenceFileSystemWritableFileStream.locked WritableStream.locked-

Methods

abort()

abort(reason?): Promise<void>;

Defined in: typescript

The abort() method of the WritableStream 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.

MDN Reference

Parameters

ParameterType
reason?any

Returns

Promise<void>

Implementation of

FileSystemWritableFileStream.abort

Inherited from

WritableStream.abort

close()

close(): Promise<void>;

Defined in: typescript

The close() method of the WritableStream interface closes the associated stream. All chunks written before this method is called are sent before the returned promise is fulfilled.

MDN Reference

Returns

Promise<void>

Implementation of

FileSystemWritableFileStream.close

Inherited from

WritableStream.close

getWriter()

getWriter(): WritableStreamDefaultWriter<FileSystemWriteChunk>;

Defined in: typescript

The getWriter() method of the WritableStream interface returns a new instance of WritableStreamDefaultWriter and locks the stream to that instance. While the stream is locked, no other writer can be acquired until this one is released.

MDN Reference

Returns

WritableStreamDefaultWriter<FileSystemWriteChunk>

Implementation of

FileSystemWritableFileStream.getWriter

Inherited from

WritableStream.getWriter

seek()

seek(position): Promise<void>;

Defined in: packages/platform-fs/src/writable.ts:169

Where it writes next, in bytes from the start.

Parameters

ParameterType
positionnumber

Returns

Promise<void>

Implementation of

FileSystemWritableFileStream.seek

truncate()

truncate(size): Promise<void>;

Defined in: packages/platform-fs/src/writable.ts:174

Cuts the file to size, or grows it with zeros.

Parameters

ParameterType
sizenumber

Returns

Promise<void>

Implementation of

FileSystemWritableFileStream.truncate

write()

write(data): Promise<void>;

Defined in: packages/platform-fs/src/writable.ts:161

Writes data, as a chunk of the stream: where it is, or as a write as an object says. The writable is not locked while it writes, so a write after it is queued after it.

Parameters

ParameterType
dataFileSystemWriteChunk

Returns

Promise<void>

Implementation of

FileSystemWritableFileStream.write