Skip to content

Make Blob compliance with documentation #383

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

Merged
merged 4 commits into from
Aug 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions api-reports/2_12.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2534,9 +2534,12 @@ raw/BiquadFilterNode[JT] val numberOfOutputs: Int
raw/BiquadFilterNode[JT] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit
raw/BiquadFilterNode[JT] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit
raw/BiquadFilterNode[JT] var `type`: String
raw/Blob[JC] def close(): Unit
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not actually removed, just moved down a line

raw/Blob[JC] def arrayBuffer(): js.Promise[ArrayBuffer]
raw/Blob[JC] @deprecated("This method seems to have been added in error and not actually exist.", "1.2.0") def close(): Unit
raw/Blob[JC] def size: Double
raw/Blob[JC] def slice(start: Double?, end: Double?, contentType: String?): Blob
raw/Blob[JC] def stream(): ReadableStream[Byte]
raw/Blob[JC] def text(): js.Promise[String]
raw/Blob[JC] def `type`: String
raw/Blob[JO]
raw/BlobPropertyBag[JT] def endings: String
Expand Down Expand Up @@ -3770,10 +3773,13 @@ raw/EventTarget[JC] def dispatchEvent(evt: Event): Boolean
raw/EventTarget[JC] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit
raw/EventTarget[JC] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit
raw/External[JT]
raw/File[JC] def close(): Unit
raw/File[JC] def arrayBuffer(): js.Promise[ArrayBuffer]
raw/File[JC] @deprecated("This method seems to have been added in error and not actually exist.", "1.2.0") def close(): Unit
raw/File[JC] def name: String
raw/File[JC] def size: Double
raw/File[JC] def slice(start: Double?, end: Double?, contentType: String?): Blob
raw/File[JC] def stream(): ReadableStream[Byte]
raw/File[JC] def text(): js.Promise[String]
raw/File[JC] def `type`: String
raw/FileList[JT] @scala.scalajs.js.annotation.JSBracketAccess def apply(index: Int): T
raw/FileList[JT] def item(index: Int): T
Expand Down
10 changes: 8 additions & 2 deletions api-reports/2_13.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2534,9 +2534,12 @@ raw/BiquadFilterNode[JT] val numberOfOutputs: Int
raw/BiquadFilterNode[JT] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit
raw/BiquadFilterNode[JT] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit
raw/BiquadFilterNode[JT] var `type`: String
raw/Blob[JC] def close(): Unit
raw/Blob[JC] def arrayBuffer(): js.Promise[ArrayBuffer]
raw/Blob[JC] @deprecated("This method seems to have been added in error and not actually exist.", "1.2.0") def close(): Unit
raw/Blob[JC] def size: Double
raw/Blob[JC] def slice(start: Double?, end: Double?, contentType: String?): Blob
raw/Blob[JC] def stream(): ReadableStream[Byte]
raw/Blob[JC] def text(): js.Promise[String]
raw/Blob[JC] def `type`: String
raw/Blob[JO]
raw/BlobPropertyBag[JT] def endings: String
Expand Down Expand Up @@ -3770,10 +3773,13 @@ raw/EventTarget[JC] def dispatchEvent(evt: Event): Boolean
raw/EventTarget[JC] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit
raw/EventTarget[JC] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit
raw/External[JT]
raw/File[JC] def close(): Unit
raw/File[JC] def arrayBuffer(): js.Promise[ArrayBuffer]
raw/File[JC] @deprecated("This method seems to have been added in error and not actually exist.", "1.2.0") def close(): Unit
raw/File[JC] def name: String
raw/File[JC] def size: Double
raw/File[JC] def slice(start: Double?, end: Double?, contentType: String?): Blob
raw/File[JC] def stream(): ReadableStream[Byte]
raw/File[JC] def text(): js.Promise[String]
raw/File[JC] def `type`: String
raw/FileList[JT] @scala.scalajs.js.annotation.JSBracketAccess def apply(index: Int): T
raw/FileList[JT] def item(index: Int): T
Expand Down
59 changes: 48 additions & 11 deletions src/main/scala/org/scalajs/dom/raw/lib.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
package org.scalajs.dom.raw

import org.scalajs.dom.experimental.ReadableStream
import scala.scalajs.js
import scala.scalajs.js.annotation._
import scala.scalajs.js.typedarray.ArrayBuffer
Expand Down Expand Up @@ -7839,14 +7840,18 @@ object BlobPropertyBag {
}

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

def `type`: String = js.native
@deprecated(
"This method seems to have been added in error and not actually exist.",
"1.2.0")
def close(): Unit = js.native

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

/**
* The slice is used to create a new Blob object containing the data in the specified
* range of bytes of the source Blob.
* A string indicating the MIME type of the data contained in the Blob. If the type
* is unknown, this string is empty.
*
* MDN
*/
def `type`: String = js.native

/**
* A string indicating the MIME type of the data contained in the Blob. If the type
* is unknown, this string is empty.
*
* MDN
*/
def slice(start: Double = js.native, end: Double = js.native,
contentType: String = js.native): Blob = js.native

def close(): Unit = js.native
/**
* Returns a ReadableStream that can be used to read the contents of the blob.
*
* MDN
*/
def stream(): ReadableStream[Byte] = js.native

/**
* Returns a promise that resolves with a USVString containing the entire
* contents of the blob interpreted as UTF-8 text.
*
* MDN
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/USVString
*/
def text(): js.Promise[String] = js.native

/**
* Returns a promise that resolves with an ArrayBuffer containing the entire
* contents of the blob as binary data.
*/
def arrayBuffer(): js.Promise[ArrayBuffer] = js.native
}

@js.native
Expand Down