Skip to content

Commit 0541a0d

Browse files
authored
Merge pull request #383 from FabioPinheiro/MDN-Blob
Make Blob compliance with documentation
2 parents 3388dc4 + 7b6baca commit 0541a0d

File tree

3 files changed

+64
-15
lines changed

3 files changed

+64
-15
lines changed

api-reports/2_12.txt

+8-2
Original file line numberDiff line numberDiff line change
@@ -2534,9 +2534,12 @@ raw/BiquadFilterNode[JT] val numberOfOutputs: Int
25342534
raw/BiquadFilterNode[JT] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit
25352535
raw/BiquadFilterNode[JT] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit
25362536
raw/BiquadFilterNode[JT] var `type`: String
2537-
raw/Blob[JC] def close(): Unit
2537+
raw/Blob[JC] def arrayBuffer(): js.Promise[ArrayBuffer]
2538+
raw/Blob[JC] @deprecated("This method seems to have been added in error and not actually exist.", "1.2.0") def close(): Unit
25382539
raw/Blob[JC] def size: Double
25392540
raw/Blob[JC] def slice(start: Double?, end: Double?, contentType: String?): Blob
2541+
raw/Blob[JC] def stream(): ReadableStream[Byte]
2542+
raw/Blob[JC] def text(): js.Promise[String]
25402543
raw/Blob[JC] def `type`: String
25412544
raw/Blob[JO]
25422545
raw/BlobPropertyBag[JT] def endings: String
@@ -3770,10 +3773,13 @@ raw/EventTarget[JC] def dispatchEvent(evt: Event): Boolean
37703773
raw/EventTarget[JC] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit
37713774
raw/EventTarget[JC] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit
37723775
raw/External[JT]
3773-
raw/File[JC] def close(): Unit
3776+
raw/File[JC] def arrayBuffer(): js.Promise[ArrayBuffer]
3777+
raw/File[JC] @deprecated("This method seems to have been added in error and not actually exist.", "1.2.0") def close(): Unit
37743778
raw/File[JC] def name: String
37753779
raw/File[JC] def size: Double
37763780
raw/File[JC] def slice(start: Double?, end: Double?, contentType: String?): Blob
3781+
raw/File[JC] def stream(): ReadableStream[Byte]
3782+
raw/File[JC] def text(): js.Promise[String]
37773783
raw/File[JC] def `type`: String
37783784
raw/FileList[JT] @scala.scalajs.js.annotation.JSBracketAccess def apply(index: Int): T
37793785
raw/FileList[JT] def item(index: Int): T

api-reports/2_13.txt

+8-2
Original file line numberDiff line numberDiff line change
@@ -2534,9 +2534,12 @@ raw/BiquadFilterNode[JT] val numberOfOutputs: Int
25342534
raw/BiquadFilterNode[JT] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit
25352535
raw/BiquadFilterNode[JT] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit
25362536
raw/BiquadFilterNode[JT] var `type`: String
2537-
raw/Blob[JC] def close(): Unit
2537+
raw/Blob[JC] def arrayBuffer(): js.Promise[ArrayBuffer]
2538+
raw/Blob[JC] @deprecated("This method seems to have been added in error and not actually exist.", "1.2.0") def close(): Unit
25382539
raw/Blob[JC] def size: Double
25392540
raw/Blob[JC] def slice(start: Double?, end: Double?, contentType: String?): Blob
2541+
raw/Blob[JC] def stream(): ReadableStream[Byte]
2542+
raw/Blob[JC] def text(): js.Promise[String]
25402543
raw/Blob[JC] def `type`: String
25412544
raw/Blob[JO]
25422545
raw/BlobPropertyBag[JT] def endings: String
@@ -3770,10 +3773,13 @@ raw/EventTarget[JC] def dispatchEvent(evt: Event): Boolean
37703773
raw/EventTarget[JC] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit
37713774
raw/EventTarget[JC] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit
37723775
raw/External[JT]
3773-
raw/File[JC] def close(): Unit
3776+
raw/File[JC] def arrayBuffer(): js.Promise[ArrayBuffer]
3777+
raw/File[JC] @deprecated("This method seems to have been added in error and not actually exist.", "1.2.0") def close(): Unit
37743778
raw/File[JC] def name: String
37753779
raw/File[JC] def size: Double
37763780
raw/File[JC] def slice(start: Double?, end: Double?, contentType: String?): Blob
3781+
raw/File[JC] def stream(): ReadableStream[Byte]
3782+
raw/File[JC] def text(): js.Promise[String]
37773783
raw/File[JC] def `type`: String
37783784
raw/FileList[JT] @scala.scalajs.js.annotation.JSBracketAccess def apply(index: Int): T
37793785
raw/FileList[JT] def item(index: Int): T

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

+48-11
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010
package org.scalajs.dom.raw
1111

12+
import org.scalajs.dom.experimental.ReadableStream
1213
import scala.scalajs.js
1314
import scala.scalajs.js.annotation._
1415
import scala.scalajs.js.typedarray.ArrayBuffer
@@ -7839,14 +7840,18 @@ object BlobPropertyBag {
78397840
}
78407841

78417842
/**
7842-
* A Blob object represents a file-like object of immutable, raw data. Blobs
7843-
* represent data that isn't necessarily in a JavaScript-native format. The File
7844-
* interface is based on Blob, inheriting blob functionality and expanding it to
7845-
* support files on the user's system.
7843+
* A Blob object represents a file-like object of immutable, raw data; they can be
7844+
* read as text or binary data, or converted into a ReadableStream so its methods
7845+
* can be used for processing the data. Blobs can represent data that isn't
7846+
* necessarily in a JavaScript-native format. The File interface is based on Blob,
7847+
* inheriting blob functionality and expanding it to support files on the user's system.
78467848
*
7847-
* An easy way to construct a Blob is by invoking the Blob constuctor. Another
7848-
* way is to use the slice() method to create a blob that contains a subset of
7849-
* another blob's data.
7849+
* To construct a Blob from other non-blob objects and data, use the Blob()
7850+
* constructor. To create a blob that contains a subset of another blob's data, use the
7851+
* slice() method. To obtain a Blob object for a file on the user's file system, see
7852+
* the File documentation.
7853+
*
7854+
* The APIs accepting Blob objects are also listed in the File documentation.
78507855
*
78517856
* MDN
78527857
*/
@@ -7856,7 +7861,10 @@ class Blob(blobParts: js.Array[js.Any] = js.native,
78567861
options: BlobPropertyBag = js.native)
78577862
extends js.Object {
78587863

7859-
def `type`: String = js.native
7864+
@deprecated(
7865+
"This method seems to have been added in error and not actually exist.",
7866+
"1.2.0")
7867+
def close(): Unit = js.native
78607868

78617869
/**
78627870
* The size, in bytes, of the data contained in the Blob object.
@@ -7866,15 +7874,44 @@ class Blob(blobParts: js.Array[js.Any] = js.native,
78667874
def size: Double = js.native
78677875

78687876
/**
7869-
* The slice is used to create a new Blob object containing the data in the specified
7870-
* range of bytes of the source Blob.
7877+
* A string indicating the MIME type of the data contained in the Blob. If the type
7878+
* is unknown, this string is empty.
7879+
*
7880+
* MDN
7881+
*/
7882+
def `type`: String = js.native
7883+
7884+
/**
7885+
* A string indicating the MIME type of the data contained in the Blob. If the type
7886+
* is unknown, this string is empty.
78717887
*
78727888
* MDN
78737889
*/
78747890
def slice(start: Double = js.native, end: Double = js.native,
78757891
contentType: String = js.native): Blob = js.native
78767892

7877-
def close(): Unit = js.native
7893+
/**
7894+
* Returns a ReadableStream that can be used to read the contents of the blob.
7895+
*
7896+
* MDN
7897+
*/
7898+
def stream(): ReadableStream[Byte] = js.native
7899+
7900+
/**
7901+
* Returns a promise that resolves with a USVString containing the entire
7902+
* contents of the blob interpreted as UTF-8 text.
7903+
*
7904+
* MDN
7905+
*
7906+
* @see https://developer.mozilla.org/en-US/docs/Web/API/USVString
7907+
*/
7908+
def text(): js.Promise[String] = js.native
7909+
7910+
/**
7911+
* Returns a promise that resolves with an ArrayBuffer containing the entire
7912+
* contents of the blob as binary data.
7913+
*/
7914+
def arrayBuffer(): js.Promise[ArrayBuffer] = js.native
78787915
}
78797916

78807917
@js.native

0 commit comments

Comments
 (0)