Skip to content

File

Types

blob

A file-like object of immutable, raw data. Blobs represent data that isn't necessarily in a JavaScript-native format. The WebApiFile interface is based on Blob, inheriting blob functionality and expanding it to support files on the user's system. See Blob on MDN

type blob = BaseFile.blob = {size: int, type_: string}

Record fields

size
int
type_
string

blobPart

@unboxed type blobPart = String(string) | Blob(blob)

blobPropertyBag

type blobPropertyBag = {
mutable type_?: string,
mutable endings?: endingType,
}

Record fields

type_
option< string >
endings
option< endingType >

endingType

type endingType =
| @as("native") Native
| @as("transparent") Transparent

file

Provides information about files and allows JavaScript in a web page to access their content. See WebApiFile on MDN

type file = BaseFile.file = {
size: int,
type_: string,
name: string,
lastModified: int,
webkitRelativePath: string,
}

Record fields

size
int
type_
string
name
string
lastModified
int
webkitRelativePath
string

filePropertyBag

type filePropertyBag = {
mutable type_?: string,
mutable endings?: endingType,
mutable lastModified?: int,
}

Record fields

type_
option< string >
endings
option< endingType >
lastModified
option< int >

fileSystemCreateWritableOptions

type fileSystemCreateWritableOptions = {
mutable keepExistingData?: bool,
}

Record fields

keepExistingData
option< bool >

fileSystemDirectoryHandle

type fileSystemDirectoryHandle = private {
kind: fileSystemHandleKind,
name: string,
}

Record fields

name
string

fileSystemFileHandle

type fileSystemFileHandle = private {
kind: fileSystemHandleKind,
name: string,
}

Record fields

name
string

fileSystemGetDirectoryOptions

type fileSystemGetDirectoryOptions = {mutable create?: bool}

Record fields

create
option< bool >

fileSystemGetFileOptions

type fileSystemGetFileOptions = {mutable create?: bool}

Record fields

create
option< bool >

fileSystemHandle

type fileSystemHandle = private {
kind: fileSystemHandleKind,
name: string,
}

Record fields

name
string

fileSystemHandleKind

type fileSystemHandleKind =
| @as("directory") Directory
| @as("file") File

fileSystemRemoveOptions

type fileSystemRemoveOptions = {mutable recursive?: bool}

Record fields

recursive
option< bool >

fileSystemWritableFileStream

type fileSystemWritableFileStream = private {locked: bool}

Record fields

locked
bool

fileSystemWriteChunkType

type fileSystemWriteChunkType = unknown

queuingStrategy

type queuingStrategy<'t> = unknown

readableStream

This Streams API interface represents a readable stream of byte data. The WebApiFetch API offers a concrete instance of a ReadableStream through the body property of a Response object. See ReadableStream on MDN

type readableStream<'r> = {locked: bool}

Record fields

locked
bool

readableStreamGetReaderOptions

type readableStreamGetReaderOptions = {
mutable mode?: readableStreamReaderMode,
}

Record fields

mode

Creates a ReadableStreamBYOBReader and locks the stream to the new reader.

This call behaves the same way as the no-argument variant, except that it only works on readable byte streams, i.e. streams which were constructed specifically with the ability to handle "bring your own buffer" reading. The returned BYOB reader provides the ability to directly read individual chunks from the stream via its read() method, into developer-supplied buffers, allowing more precise control over allocation.

readableStreamReader

type readableStreamReader<'t> = unknown

readableStreamReaderMode

type readableStreamReaderMode = @as("byob") Byob

readableWritablePair

type readableWritablePair<'r, 'w> = {
mutable readable: readableStream<'r>,
mutable writable: writableStream<'w>,
}

Record fields

readable
writable

Provides a convenient, chainable way of piping this readable stream through a transform stream (or any other { writable, readable } pair). It simply pipes the stream into the writable side of the supplied pair, and returns the readable side for further use.

Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.

streamPipeOptions

type streamPipeOptions = {
mutable preventClose?: bool,
mutable preventAbort?: bool,
mutable preventCancel?: bool,
mutable signal?: EventTypes.abortSignal,
}

Record fields

preventClose
option< bool >

Pipes this readable stream to a given writable stream destination. The way in which the piping process behaves under various error conditions can be customized with a number of passed options. It returns a promise that fulfills when the piping process completes successfully, or rejects if any errors were encountered.

Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.

Errors and closures of the source and destination streams propagate as follows:

An error in this source readable stream will abort destination, unless preventAbort is truthy. The returned promise will be rejected with the source's error, or with any error that occurs during aborting the destination.

An error in destination will cancel this source readable stream, unless preventCancel is truthy. The returned promise will be rejected with the destination's error, or with any error that occurs during canceling the source.

When this source readable stream closes, destination will be closed, unless preventClose is truthy. The returned promise will be fulfilled once this process completes, unless an error is encountered while closing the destination, in which case it will be rejected with that error.

If destination starts out closed or closing, this source readable stream will be canceled, unless preventCancel is true. The returned promise will be rejected with an error indicating piping to a closed stream failed, or with any error that occurs during canceling the source.

The signal option can be set to an AbortSignal to allow aborting an ongoing pipe operation via the corresponding Event.AbortController. In this case, this source readable stream will be canceled, and destination aborted, unless the respective options preventCancel or preventAbort are set.

preventAbort
option< bool >
preventCancel
option< bool >
signal
option< EventTypes.abortSignal >

underlyingByteSource

type underlyingByteSource = {
mutable type_: unknown,
mutable autoAllocateChunkSize?: int,
mutable start?: unknown,
mutable pull?: unknown,
mutable cancel?: underlyingSourceCancelCallback,
}

Record fields

type_
unknown
autoAllocateChunkSize
option< int >
start
option< unknown >
pull
option< unknown >

underlyingSink

type underlyingSink<'t> = unknown

underlyingSource

type underlyingSource<'t> = unknown

underlyingSourceCancelCallback

type underlyingSourceCancelCallback = JSON.t => promise<
unit,
>

writableStream

This Streams API interface provides a standard abstraction for writing streaming data to a destination, known as a sink. This object comes with built-in backpressure and queuing. See WritableStream on MDN

type writableStream<'w> = {locked: bool}

Record fields

locked
bool

writableStreamDefaultController

This Streams API interface represents a controller allowing control of a WritableStream's state. When constructing a WritableStream, the underlying sink is given a corresponding WritableStreamDefaultController instance to manipulate. See WritableStreamDefaultController on MDN

type writableStreamDefaultController = private {
signal: EventTypes.abortSignal,
}

Record fields

signal
EventTypes.abortSignal

writableStreamDefaultWriter

type writableStreamDefaultWriter<'t> = unknown

writeCommandType

type writeCommandType =
| @as("seek") Seek
| @as("truncate") Truncate
| @as("write") Write

writeParams

type writeParams = {
mutable type_: writeCommandType,
mutable size?: Null.t<int>,
mutable position?: Null.t<int>,
mutable data?: Null.t<unknown>,
}

Record fields

size
option< Null.t< int > >
position
option< Null.t< int > >
data
option< Null.t< unknown > >