recursal/MDN huggingface dataset:
FileReaderSync: readAsArrayBuffer() method
==========================================

The **`readAsArrayBuffer()`** method of the `FileReaderSync` interface allows to read `File` or `Blob` objects in a synchronous way into an `ArrayBuffer`. This interface is only available in workers as it enables synchronous I/O that could potentially block.

**Note:** This feature is available in Web Workers

Syntax
------


```js
readAsArrayBuffer(blob)
```

### Parameters

`blob`

The `File` or `Blob` to read into the `File` or `ArrayBuffer`.

### Return value

An `ArrayBuffer` representing the file's data.

Exceptions
----------

The following exceptions can be raised by this method:

`NotFoundError` `DOMException`

Thrown if the resource represented by the DOM `File` or `Blob` cannot be found, e.g. because it has been erased.

`SecurityError` `DOMException`

Thrown if one of the following problematic situation is detected:

* the resource has been modified by a third party;
* too many read are performed simultaneously;
* the file pointed by the resource is unsafe for a use from the Web (like it is a system file).

`NotReadableError` `DOMException`

Thrown if the resource cannot be read due to a permission problem, like a concurrent lock.

`EncodingError` `DOMException`

Thrown if the resource is a data URL and exceed the limit length defined by each browser.

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

| Specification |
| --- |
| File API # readAsArrayBufferSyncSection |

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

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

See also
--------

* File API
* `File`
* `FileReaderSync`
* `FileReader`
* `Blob`
FileReaderSync: FileReaderSync() constructor
============================================

The **`FileReaderSync()`** constructor creates a new `FileReaderSync`.

**Note:** This feature is available in Web Workers

Syntax
------


```js
new FileReaderSync()
```

### Parameters

None.

Examples
--------

The following code snippet shows creation of a `FileReaderSync` object using the `FileReaderSync()` constructor and subsequent usage of the object:


```js
function readFile(blob) {
  const reader = new FileReaderSync();
  postMessage(reader.readAsDataURL(blob));
}
```


**Note:** This snippet must be used inside a `Worker`, as synchronous interfaces can't be used on the main thread.

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

| Specification |
| --- |
| File API # filereadersyncConstrctr |

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

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

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

When the `getAvailability()` method is called, the user agent *MUST* run the following steps:

Input

*presentationUrls*, a list of presentation request URLs

Output

*P*, a Promise

1. If one of the following conditions is true:
    * The result of running the prohibits mixed security contexts algorithm on the document's settings object is `"Prohibits Mixed Security Contexts"` and *presentationUrl* is an a priori unauthenticated URL.
    * The document object's active sandboxing flag set has the sandboxed presentation browsing context flag set.Run the following substeps:
    1. Return a Promise rejected with a `SecurityError` `DOMException`.
    2. Abort these steps.
2. Let *P* be a new Promise.
3. Return *P*, but continue running these steps in parallel.
4. If the user agent is unable to monitor the list of available presentation displays for the entire duration of the controlling browsing context (e.g., because the user has disabled this feature), then:
    1. Resolve *P* with a new `PresentationAvailability` object with its `value` property set to `false`.
    2. Abort all the remaining steps.
5. If the user agent is unable to continuously monitor the list of available presentation displays but can find presentation displays in order to start a connection, then:
    1. Reject *P* with a `NotSupportedError` `DOMException`.
    2. Abort all the remaining steps.
6. If there exists a tuple (*A*, *presentationUrls*) in the set of availability objects, then:
    1. Resolve *P* with *A*.
    2. Abort all the remaining steps.
7. Let *A* be a new `PresentationAvailability` object with its `value` property set as follows:
    1. `false` if the list of available presentation displays is empty.
    2. `true` if there is at least one compatible presentation display for some member of *presentationUrls*. Meaning there is an entry *(presentationUrl, display)* in the list of available presentation displays for some *presentationUrl* in *presentationUrls*.
    3. `false` otherwise.
8. Create a tuple (*A*, *presentationUrls*) and add it to the set of availability objects.
9. Run the algorithm to monitor the list of available presentation displays.
10. Resolve *P* with *A*.
Browser compatibility
---------------------

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

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

The **`start()`** property of the `PresentationRequest` interface returns a `Promise` that resolves with a `PresentationConnection` after the user agent prompts the user to select a display and grant permission to use that display.

Syntax
------


```js
start()
```

### Parameters

None.

### Return value

A `Promise` that resolves with a `PresentationConnection`.

Security
--------

Transient user activation is required. The user has to interact with the page or a UI element in order for this feature to work.

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

| Specification |
| --- |
| Presentation API # selecting-a-presentation-display |

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

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

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

 The **`PresentationRequest()`**
 constructor creates a new `PresentationRequest` object which creates a
 new PresentationRequest.

Syntax
------


```js
new PresentationRequest(url)
new PresentationRequest(urls)
```

### Parameters

`url` or `urls\[]`

 A URL or array of URLs that are possible URLs used to create, or reconnect, a
 presentation for the PresentationRequest instance.


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

| Specification |
| --- |
| Presentation API # constructing-a-presentationrequest |

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

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

 The read-only **`booleanValue`** property of the
 `XPathResult` interface returns the boolean value of a result with
 `XPathResult.resultType` being `BOOLEAN_TYPE`.

**Note:** This feature is available in Web Workers

Value
-----

 The return value is the boolean value of the `XPathResult` returned by
 `Document.evaluate()`.

### Exceptions

#### TYPE\_ERR

 In case `XPathResult.resultType` is not `BOOLEAN_TYPE`, an
 `XPathException` of type `TYPE_ERR` is thrown.

Examples
--------

The following example shows the use of the `booleanValue` property.

### HTML


```html
<div>XPath example</div>
<p>Text is 'XPath example': <output></output></p>
```

### JavaScript


```js
const xpath = "//div/text() = 'XPath example'";
const result = document.evaluate(
  xpath,
  document,
  null,
  XPathResult.BOOLEAN\_TYPE,
  null,
);
document.querySelector("output").textContent = result.booleanValue;
```

### Result

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

| Specification |
| --- |
| DOM Standard # dom-xpathresult-booleanvalue |

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

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

 The read-only **`singleNodeValue`** property of the
 `XPathResult` interface returns a `Node` value or
 `null` in case no node was matched of a result with
 `XPathResult.resultType` being `ANY_UNORDERED_NODE_TYPE` or
 `FIRST_ORDERED_NODE_TYPE`.

Value
-----

 The return value is the `Node` value of the `XPathResult`
 returned by `Document.evaluate()`.

### Exceptions

#### TYPE\_ERR

 In case `XPathResult.resultType` is not
 `ANY_UNORDERED_NODE_TYPE` or `FIRST_ORDERED_NODE_TYPE`, an
 `XPathException` of type `TYPE_ERR` is thrown.

Examples
--------

The following example shows the use of the `singleNodeValue` property.

### HTML


```html
<div>XPath example</div>
<div>
  Tag name of the element having the text content 'XPath example':
  <output></output>
</div>
```

### JavaScript


```js
const xpath = "//\*[text()='XPath example']";
const result = document.evaluate(
  xpath,
  document,
  null,
  XPathResult.FIRST\_ORDERED\_NODE\_TYPE,
  null,
);
document.querySelector("output").textContent = result.singleNodeValue.localName;
```

### Result

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

| Specification |
| --- |
| DOM Standard # dom-xpathresult-singlenodevalue |

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

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

 The **`snapshotItem()`** method of the
 `XPathResult` interface returns an item of the snapshot collection or
 `null` in case the index is not within the range of nodes. Unlike the
 iterator result, the snapshot does not become invalid, but may not correspond to the
 current document if it is mutated.

Syntax
------


```js
snapshotItem(i)
```

### Parameters

`i`

A number, the index of the item.

### Return value

 The `Node` at the given index within the node set of the
 `XPathResult`.

### Exceptions

#### TYPE\_ERR

 In case `XPathResult.resultType` is not
 `UNORDERED_NODE_SNAPSHOT_TYPE` or `ORDERED_NODE_SNAPSHOT_TYPE`, an
 `XPathException` of type `TYPE_ERR` is thrown.

Examples
--------

The following example shows the use of the `snapshotItem()` method.

### HTML


```html
<div>XPath example</div>
<div>Tag names of the matched nodes: <output></output></div>
```

### JavaScript


```js
const xpath = "//div";
const result = document.evaluate(
  xpath,
  document,
  null,
  XPathResult.ORDERED\_NODE\_SNAPSHOT\_TYPE,
  null,
);
let node = null;
const tagNames = [];
for (let i = 0; i < result.snapshotLength; i++) {
  node = result.snapshotItem(i);
  tagNames.push(node.localName);
}
document.querySelector("output").textContent = tagNames.join(", ");
```

### Result

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

| Specification |
| --- |
| DOM Standard # dom-xpathresult-snapshotitem-index-index |

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

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

 The read-only **`invalidIteratorState`** property of the
 `XPathResult` interface signifies that the iterator has become invalid. It
 is `true` if `XPathResult.resultType` is
 `UNORDERED_NODE_ITERATOR_TYPE` or `ORDERED_NODE_ITERATOR_TYPE` and
 the document has been modified since this result was returned.

**Note:** This feature is available in Web Workers

Value
-----

A boolean value indicating whether the iterator has become invalid.

Examples
--------

The following example shows the use of the `invalidIteratorState` property.

### HTML


```html
<div>XPath example</div>
<p>Iterator state: <output></output></p>
```

### JavaScript


```js
const xpath = "//div";
const result = document.evaluate(
  xpath,
  document,
  null,
  XPathResult.ANY\_TYPE,
  null,
);
// Invalidates the iterator state
document.querySelector("div").remove();
document.querySelector("output").textContent = result.invalidIteratorState
  ? "invalid"
  : "valid";
```

### Result

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

| Specification |
| --- |
| DOM Standard # dom-xpathresult-invaliditeratorstate |

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

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

 The read-only **`resultType`** property of the
 `XPathResult` interface represents the type of the result, as defined by
 the type constants.

**Note:** This feature is available in Web Workers

Value
-----

An integer value representing the type of the result, as defined by the type constants.

Constants
---------

| Result Type Defined Constant | Value | Description |
| --- | --- | --- |
| `ANY_TYPE` | `0` | 
 A result set containing whatever type naturally results from evaluation
 of the expression. Note that if the result is a node-set then
 `UNORDERED_NODE_ITERATOR_TYPE` is always the resulting type.
  |
| `NUMBER_TYPE` | `1` | 
 A result containing a single number. This is useful for example, in an
 XPath expression using the `count()` function.
  |
| `STRING_TYPE` | `2` | A result containing a single string. |
| `BOOLEAN_TYPE` | `3` | 
 A result containing a single boolean value. This is useful for example,
 in an XPath expression using the `not()` function.
  |
| `UNORDERED_NODE_ITERATOR_TYPE` | `4` | 
 A result node-set containing all the nodes matching the expression. The
 nodes may not necessarily be in the same order that they appear in the
 document.
  |
| `ORDERED_NODE_ITERATOR_TYPE` | `5` | 
 A result node-set containing all the nodes matching the expression. The
 nodes in the result set are in the same order that they appear in the
 document.
  |
| `UNORDERED_NODE_SNAPSHOT_TYPE` | `6` | 
 A result node-set containing snapshots of all the nodes matching the
 expression. The nodes may not necessarily be in the same order that they
 appear in the document.
  |
| `ORDERED_NODE_SNAPSHOT_TYPE` | `7` | 
 A result node-set containing snapshots of all the nodes matching the
 expression. The nodes in the result set are in the same order that they
 appear in the document.
  |
| `ANY_UNORDERED_NODE_TYPE` | `8` | 
 A result node-set containing any single node that matches the
 expression. The node is not necessarily the first node in the document
 that matches the expression.
  |
| `FIRST_ORDERED_NODE_TYPE` | `9` | 
 A result node-set containing the first node in the document that matches
 the expression.
  |

Examples
--------

The following example shows the use of the `resultType` property.

### HTML


```html
<div>XPath example</div>
<div>Is XPath result a node set: <output></output></div>
```

### JavaScript


```js
const xpath = "//div";
const result = document.evaluate(
  xpath,
  document,
  null,
  XPathResult.ANY\_TYPE,
  null,
);
document.querySelector("output").textContent =
  result.resultType >= XPathResult.UNORDERED\_NODE\_ITERATOR\_TYPE &&
  result.resultType <= XPathResult.FIRST\_ORDERED\_NODE\_TYPE;
```

### Result

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

| Specification |
| --- |
| DOM Standard # dom-xpathresult-resulttype |

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

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

 The read-only **`stringValue`** property of the
 `XPathResult` interface returns the string value of a result with
 `XPathResult.resultType` being `STRING_TYPE`.

**Note:** This feature is available in Web Workers

Value
-----

 The return value is the string value of the `XPathResult` returned by
 `Document.evaluate()`.

### Exceptions

#### TYPE\_ERR

 In case `XPathResult.resultType` is not `STRING_TYPE`, an
 `XPathException` of type `TYPE_ERR` is thrown.

Examples
--------

The following example shows the use of the `stringValue` property.

### HTML


```html
<div>XPath example</div>
<div>Text content of the &lt;div&gt; above: <output></output></div>
```

### JavaScript


```js
const xpath = "//div/text()";
const result = document.evaluate(
  xpath,
  document,
  null,
  XPathResult.STRING\_TYPE,
  null,
);
document.querySelector("output").textContent = result.stringValue;
```

### Result

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

| Specification |
| --- |
| DOM Standard # dom-xpathresult-stringvalue |

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

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

 The read-only **`snapshotLength`** property of the
 `XPathResult` interface represents the number of nodes in the result
 snapshot.

**Note:** This feature is available in Web Workers

Value
-----

An integer value representing the number of nodes in the result snapshot.

### Exceptions

#### TYPE\_ERR

 In case `XPathResult.resultType` is not
 `UNORDERED_NODE_SNAPSHOT_TYPE` or `ORDERED_NODE_SNAPSHOT_TYPE`, an
 `XPathException` of type `TYPE_ERR` is thrown.

Examples
--------

The following example shows the use of the `snapshotLength` property.

### HTML


```html
<div>XPath example</div>
<div>Number of matched nodes: <output></output></div>
```

### JavaScript


```js
const xpath = "//div";
const result = document.evaluate(
  xpath,
  document,
  null,
  XPathResult.ORDERED\_NODE\_SNAPSHOT\_TYPE,
  null,
);
document.querySelector("output").textContent = result.snapshotLength;
```

### Result

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

| Specification |
| --- |
| DOM Standard # dom-xpathresult-snapshotlength |

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

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

 The read-only **`numberValue`** property of the
 `XPathResult` interface returns the numeric value of a result with
 `XPathResult.resultType` being `NUMBER_TYPE`.

**Note:** This feature is available in Web Workers

Value
-----

 The return value is the numeric value of the `XPathResult` returned by
 `Document.evaluate()`.

### Exceptions

#### TYPE\_ERR

 In case `XPathResult.resultType` is not `NUMBER_TYPE`, an
 `XPathException` of type `TYPE_ERR` is thrown.

Examples
--------

The following example shows the use of the `numberValue` property.

### HTML


```html
<div>XPath example</div>
<div>Number of &lt;div&gt;s: <output></output></div>
```

### JavaScript


```js
const xpath = "count(//div)";
const result = document.evaluate(
  xpath,
  document,
  null,
  XPathResult.NUMBER\_TYPE,
  null,
);
document.querySelector("output").textContent = result.numberValue;
```

### Result

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

| Specification |
| --- |
| DOM Standard # dom-xpathresult-numbervalue |

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

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

 The **`iterateNext()`** method of the
 `XPathResult` interface iterates over a node set result and returns the
 next node from it or `null` if there are no more nodes.

Syntax
------


```js
iterateNext()
```

### Parameters

None.

### Return value

The next `Node` within the node set of the `XPathResult`.

### Exceptions

#### TYPE\_ERR

 In case `XPathResult.resultType` is not
 `UNORDERED_NODE_ITERATOR_TYPE` or `ORDERED_NODE_ITERATOR_TYPE`, an
 `XPathException` of type `TYPE_ERR` is thrown.

#### INVALID\_STATE\_ERR

 If the document is mutated since the result was returned, an
 `XPathException` of type `INVALID_STATE_ERR` is thrown.

Examples
--------

The following example shows the use of the `iterateNext()` method.

### HTML


```html
<div>XPath example</div>
<div>Tag names of the matched nodes: <output></output></div>
```

### JavaScript


```js
const xpath = "//div";
const result = document.evaluate(
  xpath,
  document,
  null,
  XPathResult.ANY\_TYPE,
  null,
);
let node = null;
const tagNames = [];
while ((node = result.iterateNext())) {
  tagNames.push(node.localName);
}
document.querySelector("output").textContent = tagNames.join(", ");
```

### Result

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

| Specification |
| --- |
| DOM Standard # dom-xpathresult-iteratenext |

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

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
WakeLockSentinel: 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 `WakeLockSentinel` interface returns a string representation of the currently acquired `WakeLockSentinel` type.

Value
-----

 A string representation of the currently acquired wake lock type.
 Currently, the value is always `screen`, which represents a screen wake lock.
 It prevents devices from dimming or locking the screen.

Examples
--------

This example shows an asynchronous function that acquires a `WakeLockSentinel`, then logs the type to the console.


```js
const requestWakeLock = async () => {
  wakeLock = await navigator.wakeLock.request("screen");
  console.log(wakeLock.type); // logs 'screen'
};

requestWakeLock();
```

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

| Specification |
| --- |
| Screen Wake Lock API # the-type-attribute |

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

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

See also
--------

* Stay awake with the Screen Wake Lock API
WakeLockSentinel: released property
===================================

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

The **`released`** read-only property of the `WakeLockSentinel` interface returns a boolean that indicates whether a `WakeLockSentinel` has been released.

 The `WakeLockSentinel` is released when the associated platform screen wake lock is revoked; afterwards `released` will always return `true`.
 If a subsequent screen wake lock is required, the application will need to request a new screen wake lock (the current `WakeLockSentinel` cannot be reused).

Value
-----

A boolean value that is `false` until the `WakeLockSentinel` has been released (either through a call to `WakeLockSentinel.release()` or because the lock has been released automatically) and the `release` event has been emitted, after which it becomes `true` and no longer changes.

Examples
--------

This example shows how the value of the `released` property changes within a `WakeLockSentinel`'s life cycle.


```js
const sentinel = await navigator.wakeLock.request("screen");
console.log(sentinel.released); // Logs "false"

sentinel.onrelease = () => {
  console.log(sentinel.released); // Logs "true"
};

await sentinel.release();
```

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

| Specification |
| --- |
| Screen Wake Lock API # dom-wakelocksentinel-released |

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

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

See also
--------

* Stay awake with the Screen Wake Lock API