recursal/MDN huggingface dataset:
Geolocation: clearWatch() method
================================

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

The **`clearWatch()`** method of the `Geolocation` interface is used to unregister location/error monitoring handlers previously installed using `Geolocation.watchPosition()`.

Syntax
------


```js
clearWatch(id)
```

### Parameters

`id`

 The ID number returned by the `Geolocation.watchPosition()` method when
 installing the handler you wish to remove.


### Return value

None (`undefined`).

Examples
--------


```js
let id;
let target;
let options;

function success(pos) {
  const crd = pos.coords;

  if (target.latitude === crd.latitude && target.longitude === crd.longitude) {
    console.log("Congratulations, you've reached the target!");
    navigator.geolocation.clearWatch(id);
  }
}

function error(err) {
  console.error(`ERROR(${err.code}): ${err.message}`);
}

target = {
  latitude: 0,
  longitude: 0,
};

options = {
  enableHighAccuracy: false,
  timeout: 5000,
  maximumAge: 0,
};

id = navigator.geolocation.watchPosition(success, error, options);
```

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

| Specification |
| --- |
| Geolocation API # clearwatch-method |

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

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

See also
--------

* Using geolocation
* `Geolocation`
* `Geolocation.watchPosition()`
* `Geolocation.getCurrentPosition()`
Geolocation: watchPosition() method
===================================

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

 The **`watchPosition()`** method of the `Geolocation` interface is used to register a handler function that will be called automatically each time the position of the device changes.
 You can also, optionally, specify an error handling callback function.

Syntax
------


```js
watchPosition(success)
watchPosition(success, error)
watchPosition(success, error, options)
```

### Parameters

`success`

A callback function that takes a `GeolocationPosition` object as an input parameter.

`error` Optional

An optional callback function that takes a `GeolocationPositionError` object as an input parameter.

`options` Optional

 An optional object that provides configuration options for the location watch.
 See `Geolocation.getCurrentPosition()` for more details on possible options.


### Return value

 An integer ID that identifies the registered handler.
 The ID can be passed to the `Geolocation.clearWatch()` to unregister the handler.

Examples
--------


```js
let id;
let target;
let options;

function success(pos) {
  const crd = pos.coords;

  if (target.latitude === crd.latitude && target.longitude === crd.longitude) {
    console.log("Congratulations, you reached the target");
    navigator.geolocation.clearWatch(id);
  }
}

function error(err) {
  console.error(`ERROR(${err.code}): ${err.message}`);
}

target = {
  latitude: 0,
  longitude: 0,
};

options = {
  enableHighAccuracy: false,
  timeout: 5000,
  maximumAge: 0,
};

id = navigator.geolocation.watchPosition(success, error, options);
```

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

| Specification |
| --- |
| Geolocation API # watchposition-method |

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

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

See also
--------

* Using the Geolocation API
* The interface it belongs to, `Geolocation`, and the way to access it —
 `Navigator.geolocation`.
* The opposite operation: `Geolocation.clearWatch()`
* A similar method: `Geolocation.getCurrentPosition()`
Geolocation: getCurrentPosition() method
========================================

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

The **`getCurrentPosition()`** method of the `Geolocation` interface is used to get the current position of the device.

Syntax
------


```js
getCurrentPosition(success)
getCurrentPosition(success, error)
getCurrentPosition(success, error, options)
```

### Parameters

`success`

 A callback function that takes a `GeolocationPosition` object as its
 sole input parameter.


`error` Optional

 An optional callback function that takes a `GeolocationPositionError`
 object as its sole input parameter.


`options` Optional

An optional object including the following parameters:

`maximumAge` Optional

A positive `long` value indicating the maximum age in milliseconds of a possible cached position that is acceptable to return. If set to `0`, it means that the device cannot use a cached position and must attempt to retrieve the real current position. If set to `Infinity` the device must return a cached position regardless of its age. Default: `0`.

`timeout` Optional

A positive `long` value representing the maximum length of time (in milliseconds) the device is allowed to take in order to return a position. The default value is `Infinity`, meaning that `getCurrentPosition()` won't return until the position is available.

`enableHighAccuracy` Optional

A boolean value that indicates the application would like to receive the best possible results. If `true` and if the device is able to provide a more accurate position, it will do so. Note that this can result in slower response times or increased power consumption (with a GPS chip on a mobile device for example). On the other hand, if `false`, the device can take the liberty to save resources by responding more quickly and/or using less power. Default: `false`.


### Return value

None (`undefined`).

Examples
--------


```js
const options = {
  enableHighAccuracy: true,
  timeout: 5000,
  maximumAge: 0,
};

function success(pos) {
  const crd = pos.coords;

  console.log("Your current position is:");
  console.log(`Latitude : ${crd.latitude}`);
  console.log(`Longitude: ${crd.longitude}`);
  console.log(`More or less ${crd.accuracy} meters.`);
}

function error(err) {
  console.warn(`ERROR(${err.code}): ${err.message}`);
}

navigator.geolocation.getCurrentPosition(success, error, options);
```

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

| Specification |
| --- |
| Geolocation API # getcurrentposition-method |

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

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

See also
--------

* Using the Geolocation API
* `Navigator.geolocation`
DeviceMotionEventRotationRate: alpha property
=============================================

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

The **`alpha`** read-only property of the `DeviceMotionEventRotationRate` interface indicates the rate of rotation around the Z axis, in degrees per second.

Value
-----

 A `double` indicating the rate of rotation around the Z axis, in degrees per second.
 See Accelerometer values explained for details.

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

| Specification |
| --- |
| DeviceOrientation Event Specification # dom-devicemotioneventrotationrate-alpha |

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

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

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

The **`beta`** read-only property of the `DeviceMotionEventRotationRate` interface indicates the rate of rotation around the X axis, in degrees per second.

Value
-----

 A `double` indicating the rate of rotation around the X axis, in degrees per second.
 See Accelerometer values explained for details.

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

| Specification |
| --- |
| DeviceOrientation Event Specification # dom-devicemotioneventrotationrate-beta |

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

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

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

The **`gamma`** read-only property of the `DeviceMotionEventRotationRate` interface indicates the rate of rotation around the Y axis, in degrees per second.

Value
-----

 A `double` indicating the rate of rotation around the Y axis, in degrees per second.
 See Accelerometer values explained for details.

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

| Specification |
| --- |
| DeviceOrientation Event Specification # dom-devicemotioneventrotationrate-gamma |

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

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

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

 The **`messages`** read-only property of the
 `GPUCompilationInfo` interface is an array of `GPUCompilationMessage` objects, each one containing the details of an individual shader compilation message. Messages can be informational, warnings, or errors.

Value
-----

An array of `GPUCompilationMessage` objects.

Examples
--------

See the main `GPUCompilationInfo` page for an example.

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

| Specification |
| --- |
| WebGPU # dom-gpucompilationinfo-messages |

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

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

See also
--------

* The WebGPU API
FileSystemWritableFileStream: seek() method
===========================================

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

The **`seek()`** method of the `FileSystemWritableFileStream` interface updates the current file cursor offset to the position (in bytes) specified when calling the method.

Syntax
------


```js
seek(position)
```

### Parameters

`position`

A number specifying the byte position from the beginning of the file.

### Return value

A `Promise` that returns `undefined`.

### Exceptions

`NotAllowedError` `DOMException`

Thrown if `PermissionStatus.state` is not `granted`.

`TypeError`

Thrown if `position` is not a number or not defined.

Examples
--------

The following asynchronous function opens the 'Save File' picker, which returns a `FileSystemFileHandle` once a file is selected. From this, a writable stream is created using the `FileSystemFileHandle.createWritable()` method.

Next, we write to the stream:

1. A text string is written to the stream.
2. The `seek()` method is used to put the cursor at the start of the stream.
3. A second text string is written to the start of the stream, overwriting the first write.

The stream is then closed.


```js
async function saveFile() {
  try {
    // create a new handle
    const newHandle = await window.showSaveFilePicker();

    // create a FileSystemWritableFileStream to write to
    const writableStream = await newHandle.createWritable();

    // write our file
    await writableStream.write("My first file content");
    await writableStream.seek(0);
    await writableStream.write("My second file content");

    // close the file and write the contents to disk.
    await writableStream.close();
  } catch (err) {
    console.error(err.name, err.message);
  }
}
```


If you run the above function and then open the resulting file created on disk, you should see the text "My second file content".

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

| Specification |
| --- |
| File System Standard # api-filesystemwritablefilestream-seek |

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

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

See also
--------

* File System API
* The File System Access API: simplifying access to local files
FileSystemWritableFileStream: truncate() method
===============================================

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

The **`truncate()`** method of the `FileSystemWritableFileStream` interface resizes the file associated with the stream to the specified size in bytes.

If the size specified is larger than the current file size the file is padded with `0x00` bytes.

 The file cursor is also updated when `truncate()` is called.
 If the offset is smaller than the size, it remains unchanged.
 If the offset is larger than size, the offset is set to that size.
 This ensures that subsequent writes do not error.

 No changes are written to the actual file on disk until the stream has been closed.
 Changes are typically written to a temporary file instead.

Syntax
------


```js
truncate(size)
```

### Parameters

`size`

A number specifying the number of bytes to resize the stream to.

### Return value

A `Promise` that returns `undefined`.

### Exceptions

`NotAllowedError` `DOMException`

Thrown if `PermissionStatus.state` is not `granted`.

`QuotaExceededError` `DOMException`

Thrown if the new size of the file is larger than the original size of the file, and exceeds the browser's storage quota.

`TypeError`

Thrown if `size` is not a number or not defined.

Examples
--------

The following asynchronous function opens the 'Save File' picker, which returns a `FileSystemFileHandle` once a file is selected. From this, a writable stream is created using the `FileSystemFileHandle.createWritable()` method.

Next, we write to the stream:

1. A text string is written to the stream.
2. The `truncate()` method is used to resize the file to 8 bytes.
3. A second text string is written to the start of the stream, overwriting the first write.

The stream is then closed.


```js
async function saveFile() {
  try {
    // create a new handle
    const newHandle = await window.showSaveFilePicker();

    // create a FileSystemWritableFileStream to write to
    const writableStream = await newHandle.createWritable();

    // write our file
    await writableStream.write("This is my first file content");
    await writableStream.truncate(8);
    await writableStream.write("my second file content");

    // close the file and write the contents to disk.
    await writableStream.close();
  } catch (err) {
    console.error(err.name, err.message);
  }
}
```


If you run the above function and then open the resulting file created on disk, you should see the text "This is my second file content".

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

| Specification |
| --- |
| File System Standard # api-filesystemwritablefilestream-truncate |

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

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

See also
--------

* File System API
* The File System Access API: simplifying access to local files
Performance: mark() method
==========================

The **`mark()`** method creates a named `PerformanceMark` object representing a high resolution timestamp marker in the browser's performance timeline.

Syntax
------


```js
mark(name)
mark(name, markOptions)
```

### Parameters

`name`

A string representing the name of the mark. Must not be the same name as one of the properties of the deprecated `PerformanceTiming` interface.

`markOptions` Optional

An object for specifying a timestamp and additional metadata for the mark.

`detail` Optional

Arbitrary metadata to include in the mark. Defaults to `null`. Must be structured-cloneable.

`startTime` Optional

`DOMHighResTimeStamp` to use as the mark time. Defaults to `performance.now()`.


### Return value

The `PerformanceMark` entry that was created.

### Exceptions

* `SyntaxError`: Thrown if the `name` is one of the properties of the deprecated `PerformanceTiming` interface. See the example below.
* `TypeError`: Thrown if `startTime` is negative.
Examples
--------

### Creating named markers

The following example uses `mark()` to create named `PerformanceMark` entries. You can create several marks with the same name. You can also assign them, to have a reference to the `PerformanceMark` object that has been created.


```js
performance.mark("login-started");
performance.mark("login-started");
performance.mark("login-finished");
performance.mark("form-sent");

const videoMarker = performance.mark("video-loaded");
```

### Creating markers with details

The performance mark is configurable using the `markOptions` object where you can put additional information in the `detail` property, which can be of any type.


```js
performance.mark("login-started", {
  detail: "Login started using the login button in the top menu.",
});

performance.mark("login-started", {
  detail: { htmlElement: myElement.id },
});
```

### Creating markers with a different start time

The default timestamp of the `mark()` method is `performance.now()`. You can set it to a different time using the `startTime` option in `markOptions`.


```js
performance.mark("start-checkout", {
  startTime: 20.0,
});

performance.mark("login-button-pressed", {
  startTime: myEvent.timeStamp,
});
```

### Reserved names

Note in order to maintain backwards compatibility, names that are part of the deprecated `PerformanceTiming` interface can't be used. The following example throws:


```js
performance.mark("navigationStart");
// SyntaxError: "navigationStart" is part of
// the PerformanceTiming interface,
// and cannot be used as a mark name
```

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

| Specification |
| --- |
| User Timing # dom-performance-mark |

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

BCD tables only load in the browser with JavaScript enabled. Enable JavaScript to view data.
Performance: navigation 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.

 The legacy
 **`Performance.navigation`**
 read-only property returns a `PerformanceNavigation` object representing
 the type of navigation that occurs in the given browsing context, such as the number of
 redirections needed to fetch the resource.

This property is not available in workers.

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


Value
-----

A `PerformanceNavigation` object.

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 `Performance` interface it belongs to.
Performance: getEntriesByName() method
======================================

The **`getEntriesByName()`** method returns an array of `PerformanceEntry` objects currently present in the performance timeline with the given *name* and *type*.

If you are interested in performance entries of certain types, see `getEntriesByType()`. For all performance entries, see `getEntries()`.

**Note:** This method does not notify you about new performance entries; you will only get entries that are present in the performance timeline at the time you call this method.
 To receive notifications about entries as they become available, use a `PerformanceObserver`.


The following entry types are not supported by this method at all and won't be returned even if entries for these types might exist:

* `"element"` (`PerformanceElementTiming`)
* `"event"` (`PerformanceEventTiming`)
* `"largest-contentful-paint"` (`LargestContentfulPaint`)
* `"layout-shift"` (`LayoutShift`)
* `"longtask"` (`PerformanceLongTaskTiming`)

To access entries of these types, you must use a `PerformanceObserver` instead.

Syntax
------


```js
getEntriesByName(name)
getEntriesByName(name, type)
```

### Parameters

`name`

The name of the entries to retrieve.

`type` Optional

 The type of entries to retrieve such as "`mark`". The valid entry types are
 listed in `PerformanceEntry.entryType`.


### Return value

 An `Array` of `PerformanceEntry` objects that have the specified `name` and `type`.
 The items will be in chronological order based on the entries' `startTime`. If no objects meet the
 specified criteria, an empty array is returned.

Examples
--------

### Logging performance markers

The following example logs all `PerformanceMark` objects named "`debug-mark`".


```js
const debugMarks = performance.getEntriesByName("debug-mark", "mark");
debugMarks.forEach((entry) => {
  console.log(`${entry.name}'s startTime: ${entry.startTime}`);
});
```

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

| Specification |
| --- |
| Performance Timeline # dom-performance-getentriesbyname |

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

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

See also
--------

* `Performance.getEntries()`
* `Performance.getEntriesByType()`
Performance: clearMeasures() method
===================================

The **`clearMeasures()`** method removes all or specific `PerformanceMeasure` objects from the browser's performance timeline.

Syntax
------


```js
clearMeasures()
clearMeasures(name)
```

### Parameters

`name` Optional

A string representing the `name` of the `PerformanceMeasure` object. If this argument is omitted, all entries with an `entryType` of "`measure`" will be removed.

### Return value

None (`undefined`).

Examples
--------

### Removing measures

To clean up all performance measure, or just specific entries, use the `clearMeasures()` method like this:


```js
// Create a bunch of measures
performance.measure("from navigation");
performance.mark("a");
performance.measure("from mark a", "a");
performance.measure("from navigation");
performance.measure("from mark a", "a");
performance.mark("b");
performance.measure("between a and b", "a", "b");

performance.getEntriesByType("measure").length; // 5

// Delete just the "from navigation" measure entries
performance.clearMeasures("from navigation");
performance.getEntriesByType("measure").length; // 3

// Delete all of the measure entries
performance.clearMeasures();
performance.getEntriesByType("measure").length; // 0
```

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

| Specification |
| --- |
| User Timing # dom-performance-clearmeasures |

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

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

See also
--------

* `PerformanceMeasure`