Skip to content

Commit 44543a9

Browse files
committed
Docs: Add async/await usage example.
1 parent 6a0d6ee commit 44543a9

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,18 @@ document.getElementById('file-input').onchange = function () {
130130
}
131131
```
132132

133+
With
134+
[async/await](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Async_await)
135+
(requires a modern browser or a code transpiler like
136+
[Babel](https://babeljs.io/) or [TypeScript](https://www.typescriptlang.org/)):
137+
138+
```js
139+
document.getElementById('file-input').onchange = async function () {
140+
let data = await loadImage(this.files[0], { maxWidth: 600 })
141+
document.body.appendChild(data.image)
142+
}
143+
```
144+
133145
### Image scaling
134146

135147
It is also possible to use the image scaling functionality directly with an

0 commit comments

Comments
 (0)