Skip to content

Commit 7dcb538

Browse files
committed
Make Blob compliance with documentation
1 parent 3ad597c commit 7dcb538

File tree

1 file changed

+45
-12
lines changed

1 file changed

+45
-12
lines changed

src/main/scala/org/scalajs/dom/raw/lib.scala

+45-12
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
*/
1010
package org.scalajs.dom.raw
1111

12+
import org.scalajs.dom.experimental.ReadableStream
13+
1214
import scala.scalajs.js
1315
import scala.scalajs.js.annotation._
1416
import scala.scalajs.js.typedarray.ArrayBuffer
@@ -7970,14 +7972,18 @@ object BlobPropertyBag {
79707972
}
79717973

79727974
/**
7973-
* A Blob object represents a file-like object of immutable, raw data. Blobs
7974-
* represent data that isn't necessarily in a JavaScript-native format. The File
7975-
* interface is based on Blob, inheriting blob functionality and expanding it to
7976-
* support files on the user's system.
7975+
* A Blob object represents a file-like object of immutable, raw data; they can be
7976+
* read as text or binary data, or converted into a ReadableStream so its methods
7977+
* can be used for processing the data. Blobs can represent data that isn't
7978+
* necessarily in a JavaScript-native format. The File interface is based on Blob,
7979+
* inheriting blob functionality and expanding it to support files on the user's system.
7980+
*
7981+
* To construct a Blob from other non-blob objects and data, use the Blob()
7982+
* constructor. To create a blob that contains a subset of another blob's data, use the
7983+
* slice() method. To obtain a Blob object for a file on the user's file system, see
7984+
* the File documentation.
79777985
*
7978-
* An easy way to construct a Blob is by invoking the Blob constuctor. Another
7979-
* way is to use the slice() method to create a blob that contains a subset of
7980-
* another blob's data.
7986+
* The APIs accepting Blob objects are also listed in the File documentation.
79817987
*
79827988
* MDN
79837989
*/
@@ -7987,8 +7993,6 @@ class Blob(blobParts: js.Array[js.Any] = js.native,
79877993
options: BlobPropertyBag = js.native)
79887994
extends js.Object {
79897995

7990-
def `type`: String = js.native
7991-
79927996
/**
79937997
* The size, in bytes, of the data contained in the Blob object.
79947998
*
@@ -7997,15 +8001,44 @@ class Blob(blobParts: js.Array[js.Any] = js.native,
79978001
def size: Double = js.native
79988002

79998003
/**
8000-
* The slice is used to create a new Blob object containing the data in the specified
8001-
* range of bytes of the source Blob.
8004+
* A string indicating the MIME type of the data contained in the Blob. If the type
8005+
* is unknown, this string is empty.
8006+
*
8007+
* MDN
8008+
*/
8009+
def `type`: String = js.native
8010+
8011+
/**
8012+
* A string indicating the MIME type of the data contained in the Blob. If the type
8013+
* is unknown, this string is empty.
80028014
*
80038015
* MDN
80048016
*/
80058017
def slice(start: Double = js.native, end: Double = js.native,
80068018
contentType: String = js.native): Blob = js.native
80078019

8008-
def close(): Unit = js.native
8020+
/**
8021+
* Returns a ReadableStream that can be used to read the contents of the blob.
8022+
*
8023+
* MDN
8024+
*/
8025+
def stream(): ReadableStream[Byte] = js.native
8026+
8027+
/**
8028+
* Returns a promise that resolves with a USVString containing the entire
8029+
* contents of the blob interpreted as UTF-8 text.
8030+
*
8031+
* MDN
8032+
*
8033+
* @see https://developer.mozilla.org/en-US/docs/Web/API/USVString
8034+
*/
8035+
def text(): scala.scalajs.js.Promise[String] = js.native
8036+
8037+
/**
8038+
* Returns a promise that resolves with an ArrayBuffer containing the entire
8039+
* contents of the blob as binary data.
8040+
*/
8041+
def arrayBuffer(): scala.scalajs.js.Promise[ArrayBuffer] = js.native
80098042
}
80108043

80118044
@js.native

0 commit comments

Comments
 (0)