Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FileReaderSync() documentation #25621

Merged
merged 5 commits into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion files/en-us/web/api/filereader/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ File objects may be obtained from a {{domxref("FileList")}} object returned as a
## Constructor

- {{domxref("FileReader.FileReader", "FileReader()")}}
- : Returns a newly constructed `FileReader`.
- : Returns a new `FileReader` object.

See [Using files from web applications](/en-US/docs/Web/API/File_API/Using_files_from_web_applications) for details and examples.

Expand Down
40 changes: 40 additions & 0 deletions files/en-us/web/api/filereadersync/filereadersync/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
title: FileReaderSync()
slug: Web/API/FileReaderSync/FileReaderSync
page-type: web-api-constructor
browser-compat: api.FileReaderSync.FileReaderSync
---

{{APIRef("File API")}}

The **`FileReaderSync()`** constructor creates a new {{domxref("FileReaderSync")}}.

## Syntax

```js-nolint
new FileReaderSync()
```

### Parameters

None.

## Examples

The following code snippet shows creation of a [`FileReaderSync`](/en-US/docs/Web/API/FileReaderSync) object using the `FileReaderSync()` constructor and subsequent usage of the object:

```js
function readFile(blob) {
const reader = new FileReaderSync();
postMessage(reader.readAsDataURL(blob));
}
```
teoli2003 marked this conversation as resolved.
Show resolved Hide resolved
> **Note:** This snippet must be used inside a {{domxref("Worker")}}, as synchronous interfaces can't be used on the main thread.

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}
5 changes: 5 additions & 0 deletions files/en-us/web/api/filereadersync/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ The `FileReaderSync` interface allows to read {{DOMxRef("File")}} or {{DOMxRef("

> **Warning:** This interface is **only available** in [workers](/en-US/docs/Web/API/Worker) as it enables synchronous I/O that could potentially block.

## Constructor

- {{domxref("FileReaderSync.FileReaderSync", "FileReaderSync()")}}
- : Returns a new `FileReaderSync` object.

## Instance properties

This interface does not have any properties.
Expand Down