# framerate-history

> An ES6 class for tracking framerate for a given period of time.

Latest version **1.0.20** (published 2025-03-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install framerate-history
pnpm add framerate-history
yarn add framerate-history
bun add framerate-history
```

## Health

**Score 30/100 (F)** — status: maintenance-mode.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.20 |
| Published | 2025-03-23 |
| First published | 2018-12-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 12 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Darren Paul Wright |
| Maintainers | darrenpaulwright |
| Keywords | framerate |

## Links

- npm: https://www.npmjs.com/package/framerate-history
- Repository: https://github.com/DarrenPaulWright/framerate-history
- Homepage: https://github.com/DarrenPaulWright/framerate-history#readme
- Issues: https://github.com/DarrenPaulWright/framerate-history/issues
- npm.io page: https://npm.io/package/framerate-history

## Alternatives

- [@luma.gl/experimental](https://npm.io/package/@luma.gl/experimental.md) — 77.1K weekly downloads
- [persona-harness](https://npm.io/package/persona-harness.md) — 4.7K weekly downloads
- [@tsparticles/effect-bubble](https://npm.io/package/@tsparticles/effect-bubble.md) — 4.6K weekly downloads
- [f3d](https://npm.io/package/f3d.md) — 730 weekly downloads
- [spark-html-motion](https://npm.io/package/spark-html-motion.md) — 298 weekly downloads

## Recent versions

- 1.0.20 (latest) — 2025-03-23
- 1.0.19 — 2025-03-22
- 1.0.18 — 2021-06-10
- 1.0.17 — 2021-05-10
- 1.0.16 — 2020-06-09
- 1.0.15 — 2020-04-06
- 1.0.14 — 2020-03-17
- 1.0.13 — 2019-12-24
- 1.0.12 — 2019-12-06
- 1.0.11 — 2019-08-02
- 1.0.10 — 2019-06-13
- 1.0.9 — 2019-06-12
- 1.0.8 — 2019-06-06
- 1.0.7 — 2019-04-19
- 1.0.6 — 2019-01-07
- … 6 more at https://npm.io/package/framerate-history/versions

## README

# Framerate History

> An ES6 class for tracking framerate for a given period of time.
>
> [![npm][npm]][npm-url]
[![deps][deps]][deps-url]
[![size][size]][size-url]
[![vulnerabilities][vulnerabilities]][vulnerabilities-url]
[![license][license]][license-url]


<br><a name="Installation"></a>

## Installation
```
npm install framerate-history
```

<br><a name="FrameRate"></a>

## FrameRate
``` javascript
import FrameRate from 'framerate-history';
```

* [FrameRate](#FrameRate)
    * [new FrameRate(settings)](#new_FrameRate_new)
    * [.fps](#FrameRate+fps) ⇒ <code>Number</code>
    * [.history](#FrameRate+history) ⇒ <code>Array</code>
    * [.filterStrength([value])](#FrameRate+filterStrength) ⇒ <code>Number</code>
    * [.sampleRate([value])](#FrameRate+sampleRate) ⇒ <code>Number</code>
    * [.onSample([callback])](#FrameRate+onSample) ⇒ <code>function</code>
    * [.historyDuration([value])](#FrameRate+historyDuration) ⇒ <code>Number</code>


<br><a name="new_FrameRate_new"></a>

### new FrameRate(settings)

| Param | Type | Default |
| --- | --- | --- |
| settings | <code>Object</code> |  | 
| [settings.onSample] | <code>function</code> |  | 
| [settings.filterStrength] | <code>Number</code> | <code>5</code> | 
| [settings.historyDuration] | <code>Number</code> | <code>30</code> | 
| [settings.sampleRate] | <code>Number</code> | <code>10</code> | 


<br><a name="FrameRate+fps"></a>

### frameRate.fps ⇒ <code>Number</code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_`🔒 Read only`_

> The last recorded FPS


<br><a name="FrameRate+history"></a>

### frameRate.history ⇒ <code>Array</code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_`🔒 Read only`_

> The FPS recordings over the history duration


<br><a name="FrameRate+filterStrength"></a>

### frameRate.filterStrength([value]) ⇒ <code>Number</code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_`🔗 Chainable`_

> Sets a filter on the frame rate calculation. Setting to 1 will effectively turn off the filter, the higher the
> number the more smooth the curve over time. See this stackoverflow question for details:
> https://stackoverflow.com/questions/4787431/check-fps-in-js

**Default**: <code>5</code>  

| Param | Type |
| --- | --- |
| [value] | <code>Number</code> | 


<br><a name="FrameRate+sampleRate"></a>

### frameRate.sampleRate([value]) ⇒ <code>Number</code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_`🔗 Chainable`_

> The rate to take samples. Setting to 0 will clear the interval. If the interval is prevented from executing at the desired rate, the history will get filled in with the current frame rate in an attempt to keep the history as accurate as possible.

**Default**: <code>10</code>  

| Param | Type | Description |
| --- | --- | --- |
| [value] | <code>Number</code> | Samples per second |


<br><a name="FrameRate+onSample"></a>

### frameRate.onSample([callback]) ⇒ <code>function</code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_`🔗 Chainable`_

> The callback will get called for every sample taken.


| Param | Type | Description |
| --- | --- | --- |
| [callback] | <code>function</code> | The callback is given one param, the FPS history array. |


<br><a name="FrameRate+historyDuration"></a>

### frameRate.historyDuration([value]) ⇒ <code>Number</code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_`🔗 Chainable`_

> Defines the duration of tracked history.

**Default**: <code>30</code>  

| Param | Type | Description |
| --- | --- | --- |
| [value] | <code>Number</code> | Seconds |


[npm]: https://img.shields.io/npm/v/framerate-history.svg
[npm-url]: https://npmjs.com/package/framerate-history
[deps]: https://david-dm.org/darrenpaulwright/framerate-history.svg
[deps-url]: https://david-dm.org/darrenpaulwright/framerate-history
[size]: https://packagephobia.now.sh/badge?p&#x3D;framerate-history
[size-url]: https://packagephobia.now.sh/result?p&#x3D;framerate-history
[vulnerabilities]: https://snyk.io/test/github/DarrenPaulWright/framerate-history/badge.svg?targetFile&#x3D;package.json
[vulnerabilities-url]: https://snyk.io/test/github/DarrenPaulWright/framerate-history?targetFile&#x3D;package.json
[license]: https://img.shields.io/github/license/DarrenPaulWright/framerate-history.svg
[license-url]: https://npmjs.com/package/framerate-history/LICENSE.md

---
_Source: https://npm.io/package/framerate-history · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
