recursal/MDN huggingface dataset:
ReadableStream: locked property
===============================

The **`locked`** read-only property of the `ReadableStream` interface returns whether or not the readable stream is locked to a reader.

 A readable stream can have at most one active reader at a time, and is locked to that reader until it is released.
 A reader might be obtained using `ReadableStream.getReader()` and released using the reader's `releaseLock()` method.

Value
-----

A boolean value indicating whether or not the readable stream is locked.

Examples
--------


```js
const stream = new ReadableStream({
  // ...
});

const reader = stream.getReader();

stream.locked;
// should return true, as the stream has been locked to a reader
```

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

| Specification |
| --- |
| Streams Standard # ref-for-rs-locked② |

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

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

See also
--------

* `ReadableStream()` constructor
* Using readable streams
AudioData: copyTo() 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
**Experimental:** **This is an experimental technology**  
Check the Browser compatibility table carefully before using this in production.

The **`copyTo()`** method of the `AudioData` interface copies a plane of an `AudioData` object to a destination buffer.

Syntax
------


```js
copyTo(destination, options)
```

### Parameters

`destination`

An `ArrayBuffer`, a `TypedArray`, or a `DataView` to copy the plane to.

`options`

An object containing the following:

`planeIndex`

The index of the plane to copy from.

`frameOffset` Optional

An integer giving an offset into the plane data indicating which plane to begin copying from. Defaults to `0`.

`frameCount` Optional

An integer giving the number of frames to copy. If omitted then all frames in the plane will be copied, beginning with the frame specified in `frameOffset`.


### Return value

Undefined.

### Exceptions

`InvalidStateError` `DOMException`

Thrown if the `AudioData` object has been transferred.

`RangeError`

Thrown if one of the following conditions is met:

* The length of the sample is longer than the destination length.
* The format of the `AudioData` object describes a planar format, but `options.planeIndex` is outside of the number of planes available.
* The format of the `AudioData` object describes an interleaved format, but `options.planeIndex` is greater than `0`.

Examples
--------

The following example copies the plane at index `1` to a destination buffer.


```js
AudioData.copyTo(AudioBuffer, { planeIndex: 1 });
```

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

| Specification |
| --- |
| WebCodecs # dom-audiodata-copyto |

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

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
AudioData: timestamp 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
**Experimental:** **This is an experimental technology**  
Check the Browser compatibility table carefully before using this in production.

The **`duration`** read-only property of the `AudioData` interface returns the timestamp of this `AudioData` object.

Value
-----

An integer.

Examples
--------

The below example prints the value of `timestamp` to the console.


```js
console.log(AudioData.timestamp);
```

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

| Specification |
| --- |
| WebCodecs # dom-audiodata-timestamp |

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

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
AudioData: AudioData() constructor
==================================

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
**Experimental:** **This is an experimental technology**  
Check the Browser compatibility table carefully before using this in production.

The **`AudioData()`** constructor creates a new `AudioData` object which represents an individual audio sample.

Syntax
------


```js
new AudioData(init)
```

### Parameters

`init`

An object containing the following:

`format`

One of:

* "u8"
* "s16"
* "s32"
* "f32"
* "u8-planar"
* "s16-planar"
* "s32-planar"
* "f32-planar"

`sampleRate`

A decimal containing the sample rate in Hz.

`numberOfFrames`

An integer containing the number of frames in this sample.

`numberOfChannels`

An integer containing the number of channels in this sample.

`timestamp`

An integer indicating the data's time in microseconds .

`data`

A typed array of the audio data for this sample.

`transfer`

An array of `ArrayBuffer`s that `AudioData` will detach and take ownership of. If the array contains the `ArrayBuffer` backing `data`, `AudioData` will use that buffer directly instead of copying from it.


Exceptions
----------

`TypeError`

Thrown if `init` is in an incorrect format.

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

| Specification |
| --- |
| WebCodecs # dom-audiodata-audiodata |

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

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
AudioData: clone() 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
**Experimental:** **This is an experimental technology**  
Check the Browser compatibility table carefully before using this in production.

The **`clone()`** method of the `AudioData` interface creates a new `AudioData` object with reference to the same media resource as the original.

Syntax
------


```js
clone()
```

### Parameters

None.

### Return value

The cloned `AudioData` object.

### Exceptions

`InvalidStateError` `DOMException`

Thrown if the `AudioData` object has been transferred.

Examples
--------

The following example clones a copy of `AudioData` as `audioData2`.


```js
let audioData2 = AudioData.clone();
```

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

| Specification |
| --- |
| WebCodecs # dom-audiodata-clone |

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

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
AudioData: format 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
**Experimental:** **This is an experimental technology**  
Check the Browser compatibility table carefully before using this in production.

The **`format`** read-only property of the `AudioData` interface returns the sample format of the `AudioData` object.

Value
-----

A string. One of:

`"u8"`

8-bit unsigned integer samples, in an interleaved format.

`"s16"`

16-bit signed integer samples, in an interleaved format.

`"s32"`

32-bit signed integer samples, in an interleaved format.

`"f32"`

32-bit float samples, in an interleaved format.

`"u8-planar"`

8-bit unsigned integer samples, in a planar format.

`"s16-planar"`

16-bit signed integer samples, in a planar format.

`"s32-planar"`

32-bit signed integer samples, in a planar format.

`"f32-planar"`

32-bit float samples, in a planar format.

Examples
--------

The below example prints the value of `format` to the console.


```js
console.log(AudioData.format);
```

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

| Specification |
| --- |
| WebCodecs # dom-audiodata-format |

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

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
AudioData: numberOfFrames 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
**Experimental:** **This is an experimental technology**  
Check the Browser compatibility table carefully before using this in production.

The **`numberOfFrames`** read-only property of the `AudioData` interface returns the number of frames in the `AudioData` object.

Value
-----

An integer.

Examples
--------

The below example prints the value of `numberOfFrames` to the console.


```js
console.log(AudioData.numberOfFrames);
```

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

| Specification |
| --- |
| WebCodecs # dom-audiodata-numberofframes |

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

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
AudioData: sampleRate 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
**Experimental:** **This is an experimental technology**  
Check the Browser compatibility table carefully before using this in production.

The **`sampleRate`** read-only property of the `AudioData` interface returns the sample rate in Hz.

Value
-----

A decimal value.

Examples
--------

The below example prints the value of `sampleRate` to the console.


```js
console.log(audioData.sampleRate);
```

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

| Specification |
| --- |
| WebCodecs # dom-audiodata-samplerate |

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

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
AudioData: numberOfChannels 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
**Experimental:** **This is an experimental technology**  
Check the Browser compatibility table carefully before using this in production.

The **`numberOfChannels`** read-only property of the `AudioData` interface returns the number of channels in the `AudioData` object.

Value
-----

An integer.

Examples
--------

The below example prints the value of `numberOfChannels` to the console.


```js
console.log(AudioData.numberOfChannels);
```

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

| Specification |
| --- |
| WebCodecs # dom-audiodata-numberofchannels |

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

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
AudioData: allocationSize() 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
**Experimental:** **This is an experimental technology**  
Check the Browser compatibility table carefully before using this in production.

The **`allocationSize()`** method of the `AudioData` interface returns the size in bytes required to hold the current sample as filtered by options passed into the method.

Syntax
------


```js
allocationSize(options)
```

### Parameters

`options`

An object containing the following:

`planeIndex`

The index of the plane to return the size of.

`frameOffset` Optional

An integer giving an offset into the plane data indicating which plane to begin from. Defaults to `0`.

`frameCount` Optional

An integer giving the number of frames to return the size of. If omitted then all frames in the plane will be used, beginning with the frame specified in `frameOffset`.


### Return value

An integer containing the number of bytes needed to hold the samples described by `options`.

Examples
--------

The following example gets the size of the plane at index `1`.


```js
let size = AudioData.allocationSize({ planeIndex: 1 });
```

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

| Specification |
| --- |
| WebCodecs # dom-audiodata-allocationsize |

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

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
AudioData: duration 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
**Experimental:** **This is an experimental technology**  
Check the Browser compatibility table carefully before using this in production.

The **`duration`** read-only property of the `AudioData` interface returns the duration in microseconds of this `AudioData` object.

Value
-----

An integer.

Examples
--------

The below example prints the value of `duration` to the console.


```js
console.log(AudioData.duration);
```

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

| Specification |
| --- |
| WebCodecs # dom-audiodata-duration |

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

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
AudioData: 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
**Experimental:** **This is an experimental technology**  
Check the Browser compatibility table carefully before using this in production.

The **`close()`** method of the `AudioData` interface clears all states and releases the reference to the media resource.

Syntax
------


```js
close()
```

### Parameters

None.

### Return value

Undefined.

Examples
--------

The following example shows the `AudioData` object being closed.


```js
AudioData.close();
```

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

| Specification |
| --- |
| WebCodecs # dom-audiodata-close |

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

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

 The
 **`DOMImplementation.createHTMLDocument()`** method creates a
 new HTML `Document`.

Syntax
------


```js
createHTMLDocument()
createHTMLDocument(title)
```

### Parameters

`title` Optional

A string containing the title to give the new HTML document.

### Return value

A new HTML `Document` object.

Examples
--------

This example creates a new HTML document and inserts it into an `<iframe>` in the current document.

Here's the HTML for this example:


```html
<body>
  <p>
    Click <a href="javascript:makeDocument()">here</a> to create a new document
    and insert it below.
  </p>
  <iframe id="theFrame" src="about:blank" />
</body>
```


The JavaScript implementation of `makeDocument()` follows:


```js
function makeDocument() {
  let frame = document.getElementById("theFrame");

  let doc = document.implementation.createHTMLDocument("New Document");
  let p = doc.createElement("p");
  p.textContent = "This is a new paragraph.";

  try {
    doc.body.appendChild(p);
  } catch (e) {
    console.log(e);
  }

  // Copy the new HTML document into the frame

  let destDocument = frame.contentDocument;
  let srcNode = doc.documentElement;
  let newNode = destDocument.importNode(srcNode, true);

  destDocument.replaceChild(newNode, destDocument.documentElement);
}
```


 The code in lines 4–12 handle creating the new HTML document and inserting some content
 into it. Line 4 uses `createHTMLDocument()` to construct a new HTML document
 whose `<title>` is `"New Document"`. Lines 5 and 6 create a
 new paragraph element with some simple content, and then lines 8–12 handle inserting the
 new paragraph into the new document.

 Line 16 pulls the `contentDocument` of the frame; this is the document into
 which we'll be injecting the new content. The next two lines handle importing the
 contents of our new document into the new document's context. Finally, line 20 actually
 replaces the contents of the frame with the new document's contents.

View Live Examples

The returned document is pre-constructed with the following HTML:


```html
<!doctype html>
<html lang="en-US">
  <head>
    <meta charset="UTF-8" />
    <title>title</title>
  </head>
  <body>
    …
  </body>
</html>
```

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

| Specification |
| --- |
| DOM Standard # ref-for-dom-domimplementation-createhtmldocument① |

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

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

See also
--------

* The `DOMImplementation` interface it belongs to.
DOMImplementation: createDocument() method
==========================================

 The **`DOMImplementation.createDocument()`** method creates and
 returns an `XMLDocument`.

Syntax
------


```js
createDocument(namespaceURI, qualifiedNameStr)
createDocument(namespaceURI, qualifiedNameStr, documentType)
```

### Parameters

`namespaceURI`

 A string containing the namespace URI of the document to be
 created, or `null` if the document doesn't belong to one.


`qualifiedNameStr`

 A string containing the qualified name, that is an optional
 prefix and colon plus the local root element name, of the document to be created.


`documentType` Optional

 Is the `DocumentType` of the document to be created. It defaults to
 `null`.


### Return value

None (`undefined`).

Examples
--------


```js
const doc = document.implementation.createDocument(
  "http://www.w3.org/1999/xhtml",
  "html",
  null,
);
const body = document.createElementNS("http://www.w3.org/1999/xhtml", "body");
body.setAttribute("id", "abc");
doc.documentElement.appendChild(body);
alert(doc.getElementById("abc")); // [object HTMLBodyElement]
```

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

| Specification |
| --- |
| DOM Standard # ref-for-dom-domimplementation-createdocument② |

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

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

See also
--------

* The `DOMImplementation` interface it belongs to.
DOMImplementation: hasFeature() method
======================================

**Deprecated:** This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

 The
 **`DOMImplementation.hasFeature()`** method returns a
 boolean flag indicating if a given feature is supported. It is
 deprecated and modern browsers return `true` in all cases.

 The different implementations fairly diverged in what kind of features were reported.
 The latest version of the spec settled to force this method to always return
 `true`, where the functionality was accurate and in use.

Syntax
------


```js
hasFeature(feature, version)
```

### Parameters

`feature`

A string representing the feature name.

`version`

 A string representing the version of the specification defining
 the feature.


### Return value

None (`undefined`).

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

| Specification |
| --- |
| DOM Standard # dom-domimplementation-hasfeature |

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

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

See also
--------

* The `DOMImplementation` interface it belongs to.
DOMImplementation: createDocumentType() method
==============================================

 The **`DOMImplementation.createDocumentType()`** method returns
 a `DocumentType` object which can either be used with
 `DOMImplementation.createDocument` upon document creation or can be put
 into the document via methods like `Node.insertBefore()` or
 `Node.replaceChild()`.

Syntax
------


```js
createDocumentType(qualifiedNameStr, publicId, systemId)
```

### Parameters

`qualifiedNameStr`

 A string containing the qualified name, like
 `svg:svg`.


`publicId`

A string containing the `PUBLIC` identifier.

`systemId`

A string containing the `SYSTEM` identifiers.

### Return value

A `DocumentType`.

Examples
--------


```js
const dt = document.implementation.createDocumentType(
  "svg:svg",
  "-//W3C//DTD SVG 1.1//EN",
  "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd",
);
const d = document.implementation.createDocument(
  "http://www.w3.org/2000/svg",
  "svg:svg",
  dt,
);
alert(d.doctype.publicId); // -//W3C//DTD SVG 1.1//EN
```

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

| Specification |
| --- |
| DOM Standard # ref-for-dom-domimplementation-createdocumenttype① |

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

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

See also
--------

* The `DOMImplementation` interface it belongs to.
SharedStorage: clear() method
=============================

**Experimental:** **This is an experimental technology**  
Check the Browser compatibility table carefully before using this in production.

The **`clear()`** method of the `SharedStorage` interface clears the current origin's shared storage, removing all data from it.

Syntax
------


```js
clear()
```

### Parameters

None.

### Return value

A `Promise` that fulfills with `undefined`.

### Exceptions

* The `Promise` rejects with a `TypeError` if:
    + The database was not cleared successfully due to shared storage not being available (for example it is disabled using a browser setting).
    + The calling site does not have the Shared Storage API included in a successful privacy sandbox enrollment process.
* In the case of `WorkletSharedStorage`, the `Promise` rejects with a `TypeError` if the worklet module has not been added with `SharedStorageWorklet.addModule()`.

**Note:** In the case of `WindowSharedStorage`, if the `clear()` operation doesn't successfully write to the database for a reason other than shared storage not being available, no error is thrown — the operation still fulfills with `undefined`.

Examples
--------


```js
window.sharedStorage.clear().then(console.log("Shared storage cleared"));
```

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

| Specification |
| --- |
| Shared Storage API # dom-sharedstorage-clear |

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

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

See also
--------

* Shared Storage API