recursal/MDN huggingface dataset:
NDEFReader: scan() method
=========================

**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 `scan()` method of the `NDEFReader` interface activates a reading device and returns a `Promise` that either resolves when an NFC tag read operation is scheduled or rejects if a hardware or permission error is encountered. This method triggers a permission prompt if the "nfc" permission has not been previously granted.

Syntax
------


```js
scan(options)
```

### Parameters

`options` Optional

An object with the following properties:

`signal`

An `AbortSignal` that allows cancelling this `scan()` operation.


### Return value

 A `Promise` that resolves immediately after
 scheduling read operations for the NFC adapter.

Exceptions
----------

 This method doesn't throw exceptions; instead, it rejects the returned promise,
 passing a `DOMException` whose `name` is one of the
 following:

`AbortError` `DOMException`

Returned if the scan operation was aborted with the `AbortSignal` passed in the `options` argument.

`InvalidStateError` `DOMException`

Returned if there's already an ongoing scan.

`NotAllowedError` `DOMException`

Returned if the permission for this operation was rejected.

`NotSupportedError` `DOMException`

Returned if there is no NFC adapter compatible with Web NFC or a connection cannot be established.

Examples
--------

### Handle scanning errors

This example shows what happens when a scan promise rejects and `readingerror` is thrown.


```js
const ndef = new NDEFReader();
ndef
  .scan()
  .then(() => {
    console.log("Scan started successfully.");
    ndef.onreadingerror = (event) => {
      console.log(
        "Error! Cannot read data from the NFC tag. Try a different one?",
      );
    };
    ndef.onreading = (event) => {
      console.log("NDEF message read.");
    };
  })
  .catch((error) => {
    console.log(`Error! Scan failed to start: ${error}.`);
  });
```

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

| Specification |
| --- |
| Web NFC API # dom-ndefreader-scan |

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

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

**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 `reading` event of the `NDEFReader` interface is fired whenever a new reading is available from compatible NFC devices (e.g. NFC tags supporting NDEF) when these devices are within the reader's magnetic induction field.

Syntax
------

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


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

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

Event type
----------

A generic `Event`.

Examples
--------

The following example shows how to process events using both the `onreading` and `onreadingerror` event handlers.


```js
const ndef = new NDEFReader();
ndef
  .scan()
  .then(() => {
    console.log("Scan started successfully.");
    ndef.onreadingerror = (event) => {
      console.log(
        "Error! Cannot read data from the NFC tag. Try a different one?",
      );
    };
    ndef.onreading = (event) => {
      console.log("NDEF message read.");
    };
  })
  .catch((error) => {
    console.log(`Error! Scan failed to start: ${error}.`);
  });
```

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

| Specification |
| --- |
| Web NFC API # dom-ndefreader-onreading |

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

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

See also
--------

* `NDEFReader.readingerror_event`
NDEFReader: NDEFReader() constructor
====================================

**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 **`NDEFReader()`**
 constructor of the `NDEFReader` interface returns a
 new `NDEFReader` object, which is used to read NDEF messages from
 compatible NFC devices, e.g. NDEF tags, within the reader's magnetic induction
 field.

Syntax
------


```js
new NDEFReader()
```

### Parameters

None.

### Return value

A new `NDEFReader`.

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

| Specification |
| --- |
| Web NFC API # dom-ndefreader-constructor |

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

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

**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 `readingerror` event of the `NDEFReader` interface is fired whenever an error occurs during reading of NFC tags, e.g. when tags leave the reader's magnetic induction field.

Syntax
------

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


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

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

Event type
----------

A generic `Event`.

Examples
--------

The following example shows how to process events using both the `onreading` and `onreadingerror` event handlers.


```js
const ndef = new NDEFReader();
ndef
  .scan()
  .then(() => {
    console.log("Scan started successfully.");
    ndef.onreadingerror = (event) => {
      console.log(
        "Error! Cannot read data from the NFC tag. Try a different one?",
      );
    };
    ndef.onreading = (event) => {
      console.log("NDEF message read.");
    };
  })
  .catch((error) => {
    console.log(`Error! Scan failed to start: ${error}.`);
  });
```

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

| Specification |
| --- |
| Web NFC API # dom-ndefreader-onreadingerror |

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

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

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

The **`close()`** method of the `MIDIPort` interface makes the access to the MIDI device connected to this `MIDIPort` unavailable.

If the port is successfully closed a new `MIDIConnectionEvent` is queued to the `MIDIPort statechange` and `MIDIAccess statechange` events, and the `MIDIPort.connection` property is changed to `"closed"`.

Syntax
------


```js
close()
```

### Parameters

None.

### Return value

Returns a `Promise` which resolves once the port has been closed.

Examples
--------

The following example shows an output port being closed.


```js
let output = midiAccess.outputs.get(portID);
output.close(); // closes the port
```

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

| Specification |
| --- |
| Web MIDI API # dom-midiport-close |

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

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

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

The **`id`** read-only property of the `MIDIPort` interface returns the unique ID of the port.

Value
-----

A string containing an ID for the port.

Examples
--------

The following example loops through all input ports and prints the id of each to the console.


```js
for (const entry of midiAccess.inputs) {
  const input = entry[1];
  console.log(input.id);
}
```

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

| Specification |
| --- |
| Web MIDI API # dom-midiport-id |

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

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

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

The **`state`** read-only property of the `MIDIPort` interface returns the state of the port.

Value
-----

A string containing the state of the port, one of:

`"disconnected"`

The device that this `MIDIPort` represents is disconnected from the system.

`"connected"`

The device that this `MIDIPort` represents is currently connected.

Examples
--------

The following example loops through all input ports and prints the state of each to the console.


```js
for (const entry of midiAccess.inputs) {
  const input = entry[1];
  console.log(input.state);
}
```

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

| Specification |
| --- |
| Web MIDI API # dom-midiport-state |

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

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

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

The **`type`** read-only property of the `MIDIPort` interface returns the type of the port, indicating whether this is an input or output MIDI port.

Value
-----

A string containing the type of the port, one of:

`"input"`

The `MIDIPort` is an input port.

`"output"`

The `MIDIPort` is an output port.

Examples
--------

The following example loops through all input ports and prints the `type` of each to the console.


```js
for (const entry of midiAccess.inputs) {
  const input = entry[1];
  console.log(input.type); // should always be input
}
```

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

| Specification |
| --- |
| Web MIDI API # dom-midiport-type |

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

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

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

The **`statechange`** event of the `MIDIPort` interface is fired when a port changes from open to closed, or closed to open.

Syntax
------

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


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

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

Event type
----------

A `MIDIConnectionEvent`. Inherits from `Event`.

Event

MIDIConnectionEventEvent properties
----------------

`MIDIConnectionEvent.port` Read only 

Returns a reference to a `MIDIPort` instance for a port that has been connected or disconnected.

Example
-------

In the following example the current `MIDIPort.state` is logged each time it changes.


```js
port.onstatechange = (event) => {
  console.log(port.state);
};
```

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

| Specification |
| --- |
| Web MIDI API # dom-midiport-onstatechange |

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

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

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

The **`manufacturer`** read-only property of the `MIDIPort` interface returns the manufacturer of the port.

Value
-----

A string containing the manufacturer of the port.

Examples
--------

The following example loops through all input ports and prints the manufacturer of each to the console.


```js
for (const entry of midiAccess.inputs) {
  const input = entry[1];
  console.log(input.manufacturer);
}
```

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

| Specification |
| --- |
| Web MIDI API # dom-midiport-manufacturer |

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

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

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

The **`open()`** method of the `MIDIPort` interface makes the MIDI device connected to this `MIDIPort` explicitly available.

If the port is successfully opened a new `MIDIConnectionEvent` is queued to the `MIDIPort statechange` and `MIDIAccess statechange` events, and the `MIDIPort.connection` property is changed to `"open"`.

If the port is already open when this method is called, then the promise will resolve successfully.

Syntax
------


```js
open()
```

### Parameters

None.

### Return value

A `Promise` which resolves once access to the port has been successfully obtained.

### Exceptions

`InvalidAccessError` `DOMException`

The promise is rejected with this error if the port is unavailable and cannot be opened.

Examples
--------

The following example shows an output port being opened.


```js
const output = midiAccess.outputs.get(portID);
output.open(); // opens the port
```

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

| Specification |
| --- |
| Web MIDI API # dom-midiport-open |

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

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

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

The **`connection`** read-only property of the `MIDIPort` interface returns the connection state of the port.

Value
-----

Returns a string containing the connection state of the port, one of:

`"open"`

The device that this `MIDIPort` represents has been opened and is available.

`"closed"`

The device that this `MIDIPort` represents has not been opened, or has been closed.

`"pending"`

The device that this `MIDIPort` represents has been opened but has subsequently disconnected.

Examples
--------

The following example loops through all input ports and prints the connection status of each to the console.


```js
for (const entry of midiAccess.inputs) {
  const input = entry[1];
  console.log(input.connection);
}
```

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

| Specification |
| --- |
| Web MIDI API # dom-midiport-connection |

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

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

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

The **`version`** read-only property of the `MIDIPort` interface returns the version of the port.

Value
-----

A string containing the version of the port.

Examples
--------

The following example loops through all input ports and prints the version of each to the console.


```js
for (const entry of midiAccess.inputs) {
  const input = entry[1];
  console.log(input.version);
}
```

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

| Specification |
| --- |
| Web MIDI API # dom-midiport-version |

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

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

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

The **`name`** read-only property of the `MIDIPort` interface returns the system name of the port.

Value
-----

A string containing the system name of the port.

Examples
--------

The following example loops through all input ports and prints the name of each to the console.


```js
for (const entry of midiAccess.inputs) {
  const input = entry[1];
  console.log(input.name);
}
```

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

| Specification |
| --- |
| Web MIDI API # dom-midiport-name |

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

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

The **`baseVal`** property of the `SVGAnimatedLength` interface contains the initial value of an SVG enumeration.

Value
-----

A `SVGLength` containing the initial value of the length.

Examples
--------


```html
<svg
 xmlns="http://www.w3.org/2000/svg"
 viewBox="0 0 100 100"
 width="200"
 height="200">
  <circle cx="50" cy="50" r="20px" fill="gold" id="circle"></circle>
</svg>
<pre id="log"></pre>
```



```js
const unit = [
  "unknown",
  "",
  "%",
  "em",
  "ex",
  "px",
  "cm",
  "mm",
  "in",
  "pt",
  "pc",
];
const circle = document.getElementById("circle");
const log = document.getElementById("log");
const baseValue = circle.r.baseVal.value;
const baseUnit = unit[circle.r.baseVal.unitType];

log.textContent = `The 'circle.r.baseVal' is ${baseValue} (in ${baseUnit}).`;
```

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

| Specification |
| --- |
| Scalable Vector Graphics (SVG) 2 # \_\_svg\_\_SVGAnimatedEnumeration\_\_baseVal |

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

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

See also
--------

* `SVGAnimatedLength.animVal`
SVGAnimatedLength: animVal property
===================================

The **`animVal`** property of the `SVGAnimatedLength` interface contains the current value of an SVG enumeration. If there is no animation, it is the same value as the `baseVal`.

Value
-----

An `SVGLength` containing the current value of the enumeration.

Examples
--------


```html
<svg
 xmlns="http://www.w3.org/2000/svg"
 viewBox="0 0 100 100"
 width="200"
 height="200">
  <circle cx="50" cy="50" r="20" fill="gold" id="circle">
    <animate
 attributeName="r"
 values="20;25;10;20"
 dur="8s"
 repeatCount="indefinite" />
  </circle>
</svg>
<pre id="log"></pre>
```



```js
const circle = document.getElementById("circle");
const log = document.getElementById("log");

function displayLog() {
  const animValue = circle.r.animVal.value;
  const baseValue = circle.r.baseVal.value;
  log.textContent = `The 'circle.r.animVal' is ${animValue}.\n`;
  log.textContent += `The 'circle.r.baseVal' is ${baseValue}.`;
  requestAnimationFrame(displayLog);
}
displayLog();
```

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

| Specification |
| --- |
| Scalable Vector Graphics (SVG) 2 # \_\_svg\_\_SVGAnimatedLength\_\_animVal |

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

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

See also
--------

* `SVGAnimatedLength.baseVal`
PerformanceTiming: domainLookupStart property
=============================================

**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.

**Warning:** This interface of this property is deprecated in the Navigation Timing Level 2 specification. Please use the `PerformanceNavigationTiming`
 interface instead.


 The legacy
 **`PerformanceTiming.domainLookupStart`**
 read-only property returns an `unsigned long long` representing the moment,
 in milliseconds since the UNIX epoch, where the domain lookup starts. If a persistent
 connection is used, or the information is stored in a cache or a local resource, the
 value will be the same as `PerformanceTiming.fetchStart`.

Value
-----

An `unsigned long long`.

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

 This feature is no longer on track to become a standard, as the Navigation Timing specification has marked it as deprecated.
 Use the `PerformanceNavigationTiming` interface instead.

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

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

See also
--------

* The `PerformanceTiming` interface it belongs to.
PerformanceTiming: domLoading property
======================================

**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.

**Warning:** This interface of this property is deprecated in the Navigation Timing Level 2 specification. Please use the `PerformanceNavigationTiming`
 interface instead.


 The legacy
 **`PerformanceTiming.domLoading`**
 read-only property returns an `unsigned long long` representing the moment,
 in milliseconds since the UNIX epoch, when the parser started its work, that is when its
 `Document.readyState` changes to `'loading'` and the
 corresponding `readystatechange` event is thrown.

Value
-----

An `unsigned long long`.

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

 This feature is no longer on track to become a standard, as the Navigation Timing specification has marked it as deprecated.
 Use the `PerformanceNavigationTiming` interface instead.

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

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

See also
--------

* The `PerformanceTiming` interface it belongs to.
PerformanceTiming: navigationStart property
===========================================

**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.

**Warning:** This interface of this property is deprecated in the Navigation Timing Level 2 specification.
 Please use the `PerformanceNavigationTiming` interface instead.


 The legacy
 **`PerformanceTiming.navigationStart`**
 read-only property returns an `unsigned long long` representing the moment,
 in milliseconds since the UNIX epoch, right after the prompt for unload terminates on
 the previous document in the same browsing context. If there is no previous document,
 this value will be the same as `PerformanceTiming.fetchStart`.

Value
-----

An `unsigned long long`.

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

 This feature is no longer on track to become a standard, as the Navigation Timing specification has marked it as deprecated.
 Use the `PerformanceNavigationTiming` interface instead.

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

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

See also
--------

* The `PerformanceTiming` interface it belongs to.