recursal/MDN huggingface dataset:
NDEFReadingEvent: message property
==================================

**Secure context:** This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

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

The **`message`** property of the `NDEFReadingEvent` interface returns an `NDEFMessage` object containing the received message.

Value
-----

An `NDEFMessage` object.

Examples
--------

This example shows how to create a convenience function that reads a single tag and then stops polling, saving battery life by cutting unneeded work. The example could easily be extended to time out after a given amount of milliseconds.


```js
const ndefReader = new NDEFReader();

function read() {
  return new Promise((resolve, reject) => {
    const ctlr = new AbortController();
    ctlr.signal.onabort = reject;
    ndefReader.addEventListener(
      "reading",
      (event) => {
        ctlr.abort();
        resolve(event);
      },
      { once: true },
    );
    ndefReader.scan({ signal: ctlr.signal }).catch((err) => reject(err));
  });
}

read().then(({ serialNumber }) => {
  console.log(serialNumber);
});
```

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

| Specification |
| --- |
| Web NFC API # dom-ndefreadingevent-message |

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

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

**Secure context:** This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

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

The **`serialNumber`** property of the `NDEFReadingEvent` interface returns the serial number of the device, which is used for anti-collision and identification, or an empty string if no serial number is available.

Value
-----

A string containing the device's serial number.

Examples
--------

This example shows how to create a convenience function that reads a single tag and then stops polling, saving battery life by cutting unneeded work. The example could easily be extended to time out after a given amount of milliseconds.


```js
const ndefReader = new NDEFReader();

function read() {
  return new Promise((resolve, reject) => {
    const ctlr = new AbortController();
    ctlr.signal.onabort = reject;
    ndefReader.addEventListener(
      "reading",
      (event) => {
        ctlr.abort();
        resolve(event);
      },
      { once: true },
    );
    ndefReader.scan({ signal: ctlr.signal }).catch((err) => reject(err));
  });
}

read().then(({ serialNumber }) => {
  console.log(serialNumber);
});
```

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

| Specification |
| --- |
| Web NFC API # dom-ndefreadingevent-serialnumber |

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

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

 The **`PeriodicWave()`** constructor of the Web Audio API creates a new
 `PeriodicWave` object instance.

Syntax
------


```js
new PeriodicWave(context)
new PeriodicWave(context, options)
```

### Parameters

`context`

 A `BaseAudioContext` representing the audio context you want the node
 to be associated with.


`options` Optional

 A
 `PeriodicWaveOptions`
 dictionary object defining the properties you want the `PeriodicWave` to
 have (It also inherits the options defined in the PeriodicWaveConstraints
 dictionary.):


`real`

 A `Float32Array` containing the cosine terms
 that you want to use to form the wave (equivalent to the `real`
 parameter of `BaseAudioContext.createPeriodicWave`).


`imag`

 A `Float32Array` containing the sine terms that
 you want to use to form the wave (equivalent to the `imag` parameter of
 `BaseAudioContext.createPeriodicWave`).


`channelCount`

 Represents an integer used to determine how many channels are used when up-mixing and down-mixing connections to any inputs to the node. (See
 `AudioNode.channelCount` for more information.) Its usage and precise
 definition depend on the value of `channelCountMode`.


`channelCountMode`

 Represents an enumerated value describing the way channels must be matched between
 the node's inputs and outputs. (See `AudioNode.channelCountMode` for more
 information including default values.)


`channelInterpretation`

 Represents an enumerated value describing the meaning of the channels. This
 interpretation will define how audio up-mixing and down-mixing will happen.
 The possible values are `"speakers"` or `"discrete"`. (See
 `AudioNode.channelCountMode` for more information including default
 values.)



### Return value

A new `PeriodicWave` object instance.

Examples
--------


```js
const real = new Float32Array(2);
const imag = new Float32Array(2);
const ac = new AudioContext();

real[0] = 0;
imag[0] = 0;
real[1] = 1;
imag[1] = 0;

const wave = new PeriodicWave(ac, {
  real,
  imag,
  disableNormalization: false,
});
```

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

| Specification |
| --- |
| Web Audio API # dom-periodicwave-periodicwave |

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

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

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

 The **`GPUValidationError()`** constructor creates a new
 `GPUValidationError` object instance.

Syntax
------


```js
new GPUValidationError(message)
```

### Parameters

`message`

A string providing a human-readable message that explains why the error occurred.

Examples
--------

A developer would not manually use the constructor to create a `GPUValidationError` object. The user agent uses this constructor to create an appropriate object when a validation error is surfaced by `GPUDevice.popErrorScope` or the `uncapturederror` event.

See the main `GPUValidationError` page for a specific example involving a `GPUValidationError` object instance.

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

| Specification |
| --- |
| WebGPU # dom-gpuvalidationerror-gpuvalidationerror |

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

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

See also
--------

* The WebGPU API
* WebGPU Error Handling best practices
RTCAudioSourceStats: timestamp property
=======================================

The **`timestamp`** property of the `RTCAudioSourceStats` dictionary is a `DOMHighResTimeStamp` object specifying the time at which the data in the object was sampled.

The time is given in milliseconds elapsed since the first moment of January 1, 1970, UTC (also known as Unix time).

Value
-----

A `DOMHighResTimeStamp` value indicating the time at which the activity described by the statistics in this object was recorded, in milliseconds elapsed since the beginning of January 1, 1970, UTC.

The value should be accurate to within a few milliseconds but may not be entirely precise, either because of hardware or operating system limitations or because of fingerprinting protection in the form of reduced clock precision or accuracy.

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

| Specification |
| --- |
| Identifiers for WebRTC's Statistics API # dom-rtcstats-timestamp |

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

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

The `RTCAudioSourceStats` dictionary's **`kind`** property is a string value that is used to differentiate `audio` and `video` media sources.

Along with the `type`, this identifies the object as an `RTCAudioSourceStats` object when iterating the `RTCStatsReport` returned by `RTCRtpSender.getStats()` or `RTCPeerConnection.getStats()`.

Value
-----

A string with the value `audio`.

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

| Specification |
| --- |
| Identifiers for WebRTC's Statistics API # dom-rtcmediasourcestats-kind |

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

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

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

 The `RTCAudioSourceStats` dictionary's **`totalSamplesDuration`** property represents the combined duration of all samples produced by the media source over the lifetime of this stats object, in seconds.
 It does not include samples dropped before reaching this media source.

This can be used with `totalAudioEnergy` to compute an average audio level over different intervals.

**Note:** For audio duration of remotely sourced tracks, see `RTCInboundRtpStreamStats.totalSamplesDuration`.

Value
-----

A number indicating the total duration of all samples produced by this source over the lifetime this stats object, in seconds.

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

| Specification |
| --- |
| Identifiers for WebRTC's Statistics API # dom-rtcaudiosourcestats-totalsamplesduration |

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

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

The **`id`** property of the `RTCAudioSourceStats` dictionary is a string which uniquely identifies the object for which this object provides statistics.

Using the `id`, you can correlate this statistics object with others, in order to monitor statistics over time for a given WebRTC object, such as an `RTCPeerConnection`, or an `RTCDataChannel`.

Value
-----

A string that uniquely identifies the object for which this `RTCAudioSourceStats` object provides statistics.

The format of the ID string is not defined by the specification, so you cannot reliably make any assumptions about the contents of the string, or assume that the format of the string will remain unchanged for a given object type.

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

| Specification |
| --- |
| Identifiers for WebRTC's Statistics API # dom-rtcstats-id |

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

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

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

The `RTCAudioSourceStats` dictionary's **`totalAudioEnergy`** property represents the total audio energy of the media source over the lifetime of this stats object.

The total energy across a particular duration can be determined by subtracting the value of this property returned by two different `getStats()` calls.

**Note:** For audio energy of remotely sourced tracks, see `RTCInboundRtpStreamStats.totalAudioEnergy`.

Value
-----

A number produced by summing the energy of every sample over the lifetime of this stats object.

 The energy of each sample is calculated by dividing the sample's value by the highest-intensity encodable value, squaring the result, and then multiplying by the duration of the sample in seconds.
 This is shown as an equation below:


duration
⁢

(

sample\_level
max\_level

)

2

Note that if multiple audio channels are used, the audio energy of a sample refers to the highest energy of any channel.

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

| Specification |
| --- |
| Identifiers for WebRTC's Statistics API # dom-rtcaudiosourcestats-totalaudioenergy |

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

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

The `RTCAudioSourceStats` dictionary's property **`type`** is a string with value `media-source`.

 The type of `media-source` identifies the type of statistics as either `RTCAudioSourceStats` or `RTCVideoSourceStats` when iterating the `RTCStatsReport` returned by `RTCRtpSender.getStats()` or `RTCPeerConnection.getStats()`.
 The type of stats can further be differentiated using the `kind`, which will be `audio` for `RTCAudioSourceStats`.

Value
-----

A string with the value `media-source`.

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

| Specification |
| --- |
| Identifiers for WebRTC's Statistics API # dom-rtcstats-type |

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

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

The `RTCAudioSourceStats` dictionary's property **`trackIdentifier`** contains the `id` attribute of the associated `MediaStreamTrack`.

Value
-----

A string containing the value of the associated `MediaStreamTrack.id`.

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

| Specification |
| --- |
| Identifiers for WebRTC's Statistics API # dom-rtcmediasourcestats-trackidentifier |

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

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

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

The `RTCAudioSourceStats` dictionary's **`audioLevel`** property represents the audio level of the media source.

 The level is averaged over some small implementation-dependent interval.
 Users can alternatively calculate the average audio level over some arbitrary duration using the algorithm described in the `RTCAudioSourceStats` description.

**Note:** For audio levels of remotely sourced tracks, see `RTCInboundRtpStreamStats.audioLevel`.

Value
-----

A number between 0 and 1 (linear), where 1.0 represents 0 dBov (decibels relative to full scale (DBFS)), 0 represents silence, and 0.5 represents approximately 6 dB SPL change in the sound pressure level from 0 dBov.

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

| Specification |
| --- |
| Identifiers for WebRTC's Statistics API # dom-rtcaudiosourcestats-audiolevel |

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

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

 The **`Selection.focusOffset`** read-only property returns the
 number of characters that the selection's focus is offset within the
 `Selection.focusNode`.

 This number is zero-based. If the selection ends with the first character in the
 `Selection.focusNode`, `0` is returned.

Value
-----

A number.

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

| Specification |
| --- |
| Selection API # dom-selection-focusoffset |

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

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

See also
--------

* `Selection`, the interface it belongs to.
Selection: rangeCount property
==============================

 The **`Selection.rangeCount`** read-only property returns the
 number of ranges in the selection.

 Before the user has clicked a freshly loaded page, the `rangeCount` is
 `0`. After the user clicks on the page, `rangeCount` is
 `1`, even if no selection is visible.

 A user can normally only select one range at a time, so the `rangeCount`
 will usually be `1`. Scripting can be used to make the selection contain more
 than one range.

 Gecko browsers allow multiple selections across table cells. Firefox allows to select
 multiple ranges in the document by using Ctrl+click (unless the click occurs within an
 element that has the `display: table-cell` CSS property assigned).

Value
-----

A number.

Examples
--------

 The following example will show the `rangeCount` every second. Select text
 in the browser to see it change.

### HTML


```html
<table>
  <tr>
    <td>a.1</td>
    <td>a.2</td>
  </tr>
  <tr>
    <td>b.1</td>
    <td>b.2</td>
  </tr>
  <tr>
    <td>c.1</td>
    <td>c.2</td>
  </tr>
</table>
```

### JavaScript


```js
setInterval(() => {
  console.log(window.getSelection().rangeCount);
}, 1000);
```

### Result

 Open your console to see how many ranges are in the selection. In Gecko browsers, you
 can select multiple ranges across table cells by holding down `Ctrl` (or `Cmd` on MacOS) while
 dragging with the mouse.

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

| Specification |
| --- |
| Selection API # dom-selection-rangecount |

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

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

See also
--------

* `Selection`, the interface it belongs to.
Selection: type property
========================

 The **`type`** read-only property of the
 `Selection` interface returns a string describing the
 type of the current selection.

Value
-----

 A string describing the type of the current selection. Possible
 values are:

`None`

No selection has currently been made.

`Caret`

 The selection is collapsed (i.e. the caret is placed on some
 text, but no range has been selected).


`Range`

A range has been selected.

Examples
--------

 In this example, the event handler will fire each time a new selection is made.
 `console.log(selection.type)` will return `Caret` or
 `Range` depending on whether the caret is placed at a single point in the
 text, or a range has been selected.


```js
let selection;

document.onselectionchange = () => {
  console.log("New selection made");
  selection = document.getSelection();
  console.log(selection.type);
};
```

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

| Specification |
| --- |
| Selection API # dom-selection-type |

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

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

See also
--------

* `Selection`
Selection: containsNode() method
================================

 The **`Selection.containsNode()`** method indicates whether a
 specified node is part of the selection.

Syntax
------


```js
containsNode(node)
containsNode(node)
containsNode(node, partialContainment)
```

### Parameters

`node`

The node that is being looked for in the selection.

`partialContainment` Optional

 When `true`, `containsNode()` returns `true` when a
 part of the node is part of the selection. When `false`,
 `containsNode()` only returns `true` when the entire node is
 part of the selection. If not specified, the default value `false` is used.


### Return value

Returns `true` if the given node is part of the selection, and `false` otherwise.

Examples
--------

### Check for selection

This snippet checks whether anything inside the body element is selected.


```js
console.log(window.getSelection().containsNode(document.body, true));
```

### Find the hidden word

 In this example, a message appears when you select the secret word. It uses
 `addEventListener()` to check for
 `selectionchange` events.

#### HTML


```html
<p>Can you find the secret word?</p>
<p>
  Hmm, where <span id="secret" style="color:transparent">SECRET</span> could it
  be?
</p>
<p id="win" hidden>You found it!</p>
```


#### JavaScript


```js
const secret = document.getElementById("secret");
const win = document.getElementById("win");

// Listen for selection changes
document.addEventListener("selectionchange", () => {
  const selection = window.getSelection();
  const found = selection.containsNode(secret);

  win.toggleAttribute("hidden", !found);
});
```


#### Result

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

| Specification |
| --- |
| Selection API # dom-selection-containsnode |

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

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

See also
--------

* `Selection`, the interface it belongs to.
Selection: setPosition() method
===============================

The **`Selection.setPosition()`** method collapses the current selection to a single point. The document is not modified. If the content is focused and editable, the caret will blink there.

**Note:** This method is an alias for the `Selection.collapse()` method.

Syntax
------


```js
setPosition(node)
setPosition(node, offset)
```

### Parameters

`node`

 The caret location will be within this node. This value can also be set to
 `null` — if `null` is specified, the method will behave like
 `Selection.removeAllRanges()`, i.e. all ranges will be removed from the
 selection.


`offset` Optional

 The offset in `node` to which the selection will be collapsed. If not
 specified, the default value `0` is used.


### Return value

None (`undefined`).

Examples
--------


```js
// Place the caret at the beginning of an HTML document's body.
const body = document.querySelector("body");
window.getSelection().setPosition(body, 0);
```

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

| Specification |
| --- |
| Selection API # dom-selection-collapse |

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

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

See also
--------

* `Selection.collapse()`
Selection: toString() method
============================

 The **`Selection.toString()`** method returns a string
 currently being represented by the selection object, i.e. the currently selected text.

Syntax
------


```js
toString()
```

### Parameters

None.

### Return value

A string representing the selection.

Description
-----------

This method returns the currently selected text.

 In JavaScript, this method is called automatically when
 a function the selection object is passed to requires a string:


```js
alert(window.getSelection()); // What is called
alert(window.getSelection().toString()); // What is actually being effectively called.
```

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

| Specification |
| --- |
| Selection API # dom-selection-stringifier |

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

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

See also
--------

* `Selection`, the interface it belongs to.
Selection: collapse() method
============================

The **`Selection.collapse()`** method collapses the current selection to a single point. The document is not modified. If the content is focused and editable, the caret will blink there.

**Note:** This method is an alias for the `Selection.setPosition()` method.

Syntax
------


```js
collapse(node)
collapse(node, offset)
```

### Parameters

`node`

 The caret location will be within this node. This value can also be set to
 `null` — if `null` is specified, the method will behave like
 `Selection.removeAllRanges()`, i.e. all ranges will be removed from the
 selection.


`offset` Optional

 The offset in `node` to which the selection will be collapsed. If not
 specified, the default value `0` is used.


### Return value

None (`undefined`).

Examples
--------


```js
// Place the caret at the beginning of an HTML document's body.
const body = document.querySelector("body");
window.getSelection().collapse(body, 0);
```

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

| Specification |
| --- |
| Selection API # dom-selection-collapse |

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

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

See also
--------

* `Selection.setPosition()`