recursal/MDN huggingface dataset:
WebGL2RenderingContext: beginQuery() method
===========================================

 The **`WebGL2RenderingContext.beginQuery()`** method of the WebGL 2 API starts an asynchronous query. The
 `target` parameter indicates which kind of query to begin.

Syntax
------


```js
beginQuery(target, query)
```

### Parameters

`target`

A `GLenum` specifying the target of the query. Possible values:

`gl.ANY_SAMPLES_PASSED`

 Specifies an occlusion query: these queries
 detect whether an object is visible (whether the scoped drawing commands pass the
 depth test and if so, how many samples pass).


`gl.ANY_SAMPLES_PASSED_CONSERVATIVE`

 Same as above, but less
 accurate and faster version.


`gl.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN`

 Number of primitives that
 are written to transform feedback buffers.



`query`

A `WebGLQuery` object for which to start the querying.

### Return value

None (`undefined`).

Examples
--------


```js
const query = gl.createQuery();
gl.beginQuery(gl.ANY\_SAMPLES\_PASSED, query);

// …
```

Specifications
--------------

| Specification |
| --- |
| WebGL 2.0 Specification # 3.7.12 |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `WebGLQuery`
WebGL2RenderingContext: isVertexArray() method
==============================================

 The **`WebGL2RenderingContext.isVertexArray()`** method of the
 WebGL API returns `true` if the
 passed object is a valid `WebGLVertexArrayObject` object.

Syntax
------


```js
isVertexArray(vertexArray)
```

### Parameters

`vertexArray`

A `WebGLVertexArrayObject` (VAO) object to test.

### Return value

 A `GLboolean` indicating whether the given object is a valid
 `WebGLVertexArrayObject` object (`true`) or not
 (`false`).

Examples
--------


```js
const vao = gl.createVertexArray();
gl.bindVertexArray(vao);

// …

gl.isVertexArray(vao);
```

Specifications
--------------

| Specification |
| --- |
| WebGL 2.0 Specification # 3.7.17 |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `WebGLVertexArrayObject`
WebGL2RenderingContext: readBuffer() method
===========================================

 The **`WebGL2RenderingContext.readBuffer()`** method of the WebGL 2 API selects a color buffer as the
 source for pixels for subsequent calls to
 `copyTexImage2D`,
 `copyTexSubImage2D`,
 `copyTexSubImage3D` or
 `readPixels`.

Syntax
------


```js
readBuffer(source)
```

### Parameters

`source`

A `GLenum` specifying a color buffer. Possible values:

`gl.BACK`

Reads from the back color buffer.

`gl.NONE`

Reads from no color buffer.

`gl.COLOR_ATTACHMENT{0-15}`

Reads from one of the 16 color attachment buffers.


### Return value

None (`undefined`).

Examples
--------


```js
gl.readBuffer(gl.COLOR\_ATTACHMENT0);
```

Specifications
--------------

| Specification |
| --- |
| WebGL 2.0 Specification # 3.7.4 |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `WebGLRenderingContext.copyTexImage2D()`
* `WebGLRenderingContext.copyTexSubImage2D()`
* `WebGL2RenderingContext.copyTexSubImage3D()`
* `WebGLRenderingContext.readPixels()`
TextTrackCueList: getCueById() method
=====================================

The **`getCueById()`** method of the `TextTrackCueList` interface returns the first `VTTCue` in the list represented by the `TextTrackCueList` object whose identifier matches the value of `id`.

Syntax
------


```js
getCueById(id)
```

### Parameters

`id`

A string which is an identifier for the cue.

### Return value

A `VTTCue` object.

Examples
--------

The `TextTrack.cues` property returns a `TextTrackCueList` containing the current cues for that particular track. Calling `cues.getCueById("second")` returns the `VTTCue` with an ID of "second".
```

WEBVTT

first
00:00:00.000 --> 00:00:00.999 line:80%
Hildy!

second
00:00:01.000 --> 00:00:01.499 line:80%
How are you?
```



```js
const video = document.getElementById("video");
video.onplay = () => {
  console.log(video.textTracks[0].cues.getCueById("second")); // a VTTCue object;
};
```

Specifications
--------------

| Specification |
| --- |
| HTML Standard # dom-texttrackcuelist-getcuebyid |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
TextTrackCueList: length property
=================================

The **`length`** read-only property of the `TextTrackCueList` interface returns the number of cues in the list.

Value
-----

An `unsigned long` which is the number of cues in the list.

Examples
--------

The `TextTrack.cues` property returns a `TextTrackCueList` containing the current cues for that particular track. Calling `cues.length` returns the number of cues in the list. Using the WebVTT track below, the value of `length` is 5.
```

WEBVTT

first
00:00:00.000 --> 00:00:00.999  line:80%
Hildy!

second
00:00:01.000 --> 00:00:01.499 line:80%
How are you?

third
00:00:01.500 --> 00:00:02.999 line:80%
Tell me, is the ruler of the universe in?

fourth
00:00:03.000 --> 00:00:04.299 line:80%
Yes, they're in - in a bad humor

fifth
00:00:04.300 --> 00:00:06.000 line:80%
Somebody must've stolen the crown jewels
```



```js
const video = document.getElementById("video");
video.onplay = () => {
  console.log(video.textTracks[0].cues.length); // 5
};
```

Specifications
--------------

| Specification |
| --- |
| HTML Standard # dom-texttrackcuelist-length |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
VideoEncoder: reset() method
============================

Limited availability
--------------------

This feature is not Baseline because it does not work in some of the most widely-used browsers.

* Learn more
* See full compatibility
* Report feedback
**Secure context:** This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

 The **`reset()`** method of the `VideoEncoder` interface synchronously cancels all pending encodes and callbacks, frees all underlying resources and sets the `state` to "unconfigured".
 After calling `reset()`, `configure()` must be called before resuming `encode()` calls.

**Note:** To avoid discarding frames queued via `encode()`, `flush()` should be called and completed before calling `reset()`.

Syntax
------


```js
reset()
```

### Parameters

None.

### Return value

None (`undefined`).

### Exceptions

`InvalidStateError` `DOMException`

Thrown if the `state` is `"closed"`.

Examples
--------

The following example resets the `VideoEncoder`.


```js
VideoEncoder.reset();
```

Specifications
--------------

| Specification |
| --- |
| WebCodecs # dom-videoencoder-reset |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
VideoEncoder: encode() method
=============================

Limited availability
--------------------

This feature is not Baseline because it does not work in some of the most widely-used browsers.

* Learn more
* See full compatibility
* Report feedback
**Secure context:** This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

 The **`encode()`** method of the `VideoEncoder` interface asynchronously encodes a `VideoFrame`.
 Encoded data (`EncodedVideoChunk`) or an error will eventually be returned via the callbacks provided to the `VideoEncoder` constructor.

Syntax
------


```js
encode(frame)
encode(frame, options)
```

### Parameters

`frame`

A `VideoFrame` object.

`options` Optional

An object containing the following members:

`keyFrame` Optional

A `boolean`, defaulting to `false` giving the user agent flexibility to decide if this frame should be encoded as a key frame. If `true` this indicates that the given frame must be encoded as a key frame.

`vp9` Optional

Encode options for the VP9 codec.

`quantizer`

Frame quantizer value 0 to 63. Only effective if `VideoEncoder` was configured with `quantizer` bitrate mode.


`av1` Optional

Encode options for the AV1 codec.

`quantizer`

Frame quantizer value 0 to 63. Only effective if `VideoEncoder` was configured with `quantizer` bitrate mode.


`avc` Optional

Encode options for the AVC (H.264) codec.

`quantizer`

Frame quantizer value 0 to 51. Only effective if `VideoEncoder` was configured with `quantizer` bitrate mode.


### Return value

None (`undefined`).

### Exceptions

`InvalidStateError` `DOMException`

Thrown if the `state` is not `"configured"`.

`DataError` `DOMException`

Thrown if the `chunk` cannot be decoded due to relying on other frames for decoding.

Examples
--------

In the following example `encode` is passed a `VideoFrame`, and the options parameter indicating that this frame should be considered a keyframe.


```js
encoder.encode(frame, { keyFrame: true });
```


Setting per-frame QP value for encoding individual frames.


```js
const encoder = new VideoEncoder(init);
const encoderConfig = {
  codec: "vp09.00.10.08",
  width: 800,
  height: 600,
  bitrateMode: "quantizer",
  framerate: 30,
  latencyMode: "realtime",
};
encoder.configure(encoderConfig);

const encodeOptions = { keyFrame: false };
const qp = calculateQp(codec, frame);

if (codec.includes("vp09")) {
  encodeOptions.vp9 = { quantizer: qp };
} else if (codec.includes("av01")) {
  encodeOptions.av1 = { quantizer: qp };
} else if (codec.includes("avc")) {
  encodeOptions.avc = { quantizer: qp };
}

encoder.encode(frame, encodeOptions);
```

Specifications
--------------

| Specification |
| --- |
| WebCodecs # dom-videoencoder-encode |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
VideoEncoder: state property
============================

Limited availability
--------------------

This feature is not Baseline because it does not work in some of the most widely-used browsers.

* Learn more
* See full compatibility
* Report feedback
**Secure context:** This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The **`state`** read-only property of the `VideoEncoder` interface returns the current state of the underlying codec.

Value
-----

A string containing one of the following values:

`"unconfigured"`

The codec is not configured for decoding.

`"configured"`

The codec has a valid configuration and is ready.

`"closed"`

The codec is no longer usable and system resources have been released.

Examples
--------

The following example prints the state of the `VideoEncoder` to the console.


```js
console.log(VideoEncoder.state);
```

Specifications
--------------

| Specification |
| --- |
| WebCodecs # dom-videoencoder-state |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
VideoEncoder: dequeue event
===========================

Limited availability
--------------------

This feature is not Baseline because it does not work in some of the most widely-used browsers.

* Learn more
* See full compatibility
* Report feedback
**Secure context:** This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The **`dequeue`** event of the `VideoEncoder` interface fires to signal a decrease in `VideoEncoder.encodeQueueSize`.

This eliminates the need for developers to use a `setTimeout()` poll to determine when the queue has decreased, and more work should be queued up.

Syntax
------

Use the event name in methods like `addEventListener()`, or set an event handler property.


```js
addEventListener("dequeue", (event) => {});

ondequeue = (event) => {};
```

Example
-------


```js
videoEncoder.addEventListener("dequeue", (event) => {
  // Queue up more encoding work
});
```

Specifications
--------------

| Specification |
| --- |
| WebCodecs # eventdef-videencoder-dequeue |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
VideoEncoder: encodeQueueSize property
======================================

Limited availability
--------------------

This feature is not Baseline because it does not work in some of the most widely-used browsers.

* Learn more
* See full compatibility
* Report feedback
**Secure context:** This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The **`encodeQueueSize`** read-only property of the `VideoEncoder` interface returns the number of pending encode requests in the queue.

Value
-----

An integer containing the number of requests.

Examples
--------

The following example prints the size of the queue to the console.


```js
console.log(VideoEncoder.encodeQueueSize);
```

Specifications
--------------

| Specification |
| --- |
| WebCodecs # dom-videoencoder-encodequeuesize |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
VideoEncoder: close() method
============================

Limited availability
--------------------

This feature is not Baseline because it does not work in some of the most widely-used browsers.

* Learn more
* See full compatibility
* Report feedback
**Secure context:** This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The **`close()`** method of the `VideoEncoder` interface ends all pending work and releases system resources.

Syntax
------


```js
close()
```

### Parameters

None.

### Return value

None (`undefined`).

Examples
--------

The following example closes the `VideoEncoder`.


```js
VideoEncoder.close();
```

Specifications
--------------

| Specification |
| --- |
| WebCodecs # dom-videoencoder-close |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
VideoEncoder: flush() method
============================

Limited availability
--------------------

This feature is not Baseline because it does not work in some of the most widely-used browsers.

* Learn more
* See full compatibility
* Report feedback
**Secure context:** This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The **`flush()`** method of the `VideoEncoder` interface forces all pending encodes to complete.

Syntax
------


```js
flush()
```

### Parameters

None.

### Return value

A `Promise` that resolves once the encoder's initialization is completed and all pending `EncodedVideoChunk`s are returned.

### Exceptions

`InvalidStateError` `DOMException`

Returned if the Promise is rejected because the `state` is not `configured`.

Examples
--------

The following example flushes the `VideoEncoder`.


```js
VideoEncoder.flush();
```

Specifications
--------------

| Specification |
| --- |
| WebCodecs # dom-videoencoder-flush |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
VideoEncoder: isConfigSupported() static method
===============================================

Limited availability
--------------------

This feature is not Baseline because it does not work in some of the most widely-used browsers.

* Learn more
* See full compatibility
* Report feedback
**Secure context:** This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The **`isConfigSupported()`** static method of the `VideoEncoder` interface checks if `VideoEncoder` can be successfully configured with the given config.

Syntax
------


```js
VideoEncoder.isConfigSupported(config)
```

### Parameters

`config`

The dictionary object accepted by `VideoEncoder.configure`

### Return value

A `Promise` that resolves with an object containing the following members:

`supported`

A boolean value which is `true` if the given config is supported by the encoder.

`config`

A copy of the given config with all the fields recognized by the encoder.

### Exceptions

`TypeError`

Thrown if the provided `config` is invalid; that is, if doesn't have required values (such as an empty `codec` field) or has invalid values (such as a negative `width`)

Examples
--------

 The following example tests if the browser supports accelerated and un-accelerated
 versions of several video codecs.


```js
const codecs = ["avc1.42001E", "vp8", "vp09.00.10.08", "av01.0.04M.08"];
const accelerations = ["prefer-hardware", "prefer-software"];

const configs = [];
for (const codec of codecs) {
  for (const acceleration of accelerations) {
    configs.push({
      codec,
      hardwareAcceleration: acceleration,
      width: 1280,
      height: 720,
      bitrate: 2\_000\_000,
      bitrateMode: "constant",
      framerate: 30,
      not\_supported\_field: 123,
    });
  }
}

for (const config of configs) {
  const support = await VideoEncoder.isConfigSupported(config);
  console.log(
    `VideoEncoder's config ${JSON.stringify(support.config)} support: ${
 support.supported
 }`,
  );
}
```

Specifications
--------------

| Specification |
| --- |
| WebCodecs # dom-videoencoder-isconfigsupported |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
DocumentType: remove() method
=============================

The **`DocumentType.remove()`** method removes a document's `doctype`.

Syntax
------


```js
remove()
```

### Parameters

None.

### Return value

None (`undefined`).

Examples
--------

### Using `remove()`


```js
document.doctype; // "<!DOCTYPE html>'
document.doctype.remove();
document.doctype; // null
```

Specifications
--------------

| Specification |
| --- |
| DOM Standard # ref-for-dom-childnode-remove① |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `Document.doctype`
DocumentType: systemId property
===============================

The read-only **`systemId`** property of the `DocumentType` returns the URL of the associated DTD.

For synthetic `DocumentType`, this property reflects the value given in parameter to `DOMImplementation.createDocumentType()`.

For HTML documents, browsers always set it up to `html`, whatever the actual `DOCTYPE` in the source code is. For SVG documents, for example, it can be `"http://www.w3.org/2000/svg"`.

Value
-----

A string.

Examples
--------


```js
const docType = document.implementation.createDocumentType(
  "svg",
  "",
  "http://www.w3.org/2000/svg",
);

console.log(docType.systemId); // Displays "http://www.w3.org/2000/svg"
```

Specifications
--------------

| Specification |
| --- |
| DOM Standard # dom-documenttype-systemid |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
DocumentType: after() method
============================

 The **`DocumentType.after()`** method inserts a set of
 `Node` objects or strings in the children list of the
 `DocumentType`'s parent, just after the `DocumentType`.
 Strings are inserted as equivalent `Text` nodes.

Syntax
------


```js
after(param1)
after(param1, param2)
after(param1, param2, /\* …, \*/ paramN)
```

### Parameters

`param1`, …, `paramN`

A set of `Node` objects or strings to insert.

### Return value

None (`undefined`).

### Exceptions

`HierarchyRequestError` `DOMException`

Thrown when the node cannot be inserted at the specified point in the hierarchy.

Examples
--------


```js
let docType = document.implementation.createDocumentType("html", "", "");
let myDoc = document.implementation.createDocument("", "", docType);

docType.after(document.createElement("html"));

myDoc.childNodes;
// NodeList [<!DOCTYPE html>, <html>]
```

Specifications
--------------

| Specification |
| --- |
| DOM Standard # ref-for-dom-childnode-after① |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `DocumentType.before()`
DocumentType: before() method
=============================

 The **`DocumentType.before()`** method inserts a set of
 `Node` objects or strings in the children list of the
 `DocumentType`'s parent, just before the `DocumentType`.
 Strings are inserted as equivalent `Text` nodes.

Syntax
------


```js
before(param1)
before(param1, param2)
before(param1, param2, /\* …, \*/ paramN)
```

### Parameters

`param1`, …, `paramN`

A set of `Node` objects or strings to insert.

### Return value

None (`undefined`).

### Exceptions

`HierarchyRequestError` `DOMException`

Thrown when the node cannot be inserted at the specified point in the hierarchy.

Examples
--------

### Adding a conditional comment

 Comment nodes are valid before doctype declarations but not advisable
 given they trigger quirks mode in IE. A
 conditional comment
 works for IE as well, though:


```js
let docType = document.implementation.createDocumentType("html", "", "");
let myDoc = document.implementation.createDocument("", "", docType);

docType.before(
  document.createComment("<!--[if !IE]> conditional comment <![endif]-->"),
);

myDoc.childNodes;
// NodeList [<!--[if !IE]> conditional comment <![endif]-->, <!DOCTYPE html>]
```

Specifications
--------------

| Specification |
| --- |
| DOM Standard # ref-for-dom-childnode-before① |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `DocumentType.after()`
DocumentType: replaceWith() method
==================================

The **`DocumentType.replaceWith()`** method replaces the document type with a set of given nodes.

Syntax
------


```js
replaceWith(node1)
replaceWith(node1, node2)
replaceWith(node1, node2, /\* …, \*/ nodeN)
```

### Parameters

`node1`, …, `nodeN`

A set of nodes to replace the `DocumentType` with.

### Return value

None (`undefined`).

### Exceptions

`HierarchyRequestError` `DOMException`

Thrown when the node cannot be inserted at the specified point in the hierarchy.

Examples
--------

### Using `replaceWith()`


```js
let svg_dt = document.implementation.createDocumentType(
  "svg:svg",
  "-//W3C//DTD SVG 1.1//EN",
  "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd",
);

document.doctype.replaceWith(svg_dt);
```

Specifications
--------------

| Specification |
| --- |
| DOM Standard # ref-for-dom-childnode-replacewith① |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.

See also
--------

* `Element.replaceWith()`
DocumentType: name property
===========================

The read-only **`name`** property of the `DocumentType` returns the type of the document.

For synthetic `DocumentType`, this property reflects the value given in parameter to `DOMImplementation.createDocumentType()`.

For HTML documents, browsers always set it up to `html`, whatever the actual `DOCTYPE` in the source code is.

Value
-----

A string.

Examples
--------


```js
const docType = document.implementation.createDocumentType("html", "", "");

console.log(docType.name); // Displays `html`
```

Specifications
--------------

| Specification |
| --- |
| DOM Standard # dom-documenttype-name |

Browser compatibility
---------------------

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.