New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

frame-interval

Package Overview
Dependencies
Maintainers
1
Versions
111
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

frame-interval - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3-canary.14.1.0

.travis.yml

30

package.json
{
"name": "frame-interval",
"version": "0.0.2",
"version": "0.0.3-canary.14.1.0",
"description": "Execute a function n-times per second, on requestAnimationFrame",
"main": "index.js",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"test": "mocha test"
"clean": "rm -rf dist",
"compile": "yarn clean && tsc -p .",
"build": "yarn compile",
"prepublishOnly": "yarn build",
"release": "auto shipit",
"watch": "tsc -w -p ."
},

@@ -14,12 +20,14 @@ "keywords": [

"author": "Damon Zucconi",
"license": "ISC",
"license": "MIT",
"devDependencies": {
"eslint": "^3.8.1",
"eslint-config-standard": "^6.2.0",
"eslint-plugin-promise": "^3.3.0",
"eslint-plugin-standard": "^2.0.1",
"mocha": "^3.1.2",
"should": "^11.1.1",
"sinon": "^1.17.6"
"auto": "^9.30.3",
"typescript": "^3.8.3"
},
"repository": "dzucconi/frame-interval",
"auto": {
"plugins": [
"npm",
"released"
]
}
}
# frame-interval
Execute a function n-times per second, on requestAnimationFrame
## What is this?
A library that allows you to limit the execution of `requestAnimationFrame` to n-frames per second for some value of n.
## Why should I use this?
- You want a `requestAnimationFrame` interface which runs at a lower speed or is bounded at some upper limit.
## Installation
```bash
yarn add frame-interval
```
npm i frame-interval --save
```
## Usage
```javascript
import fps from 'frame-interval';
```ts
import { frameInterval } from "frame-interval";
const FPS = 30;
const FPS = 24;
fps(requestAnimationFrame)(FPS, frame => {
// constructor FrameInterval(fps: number, callback: FrameIntervalCallback): FrameInterval
// type FrameIntervalCallback = (
// props?:
// | {
// time: number;
// frame: number;
// }
// | undefined
// ) => void;
const fi = new FrameInterval(FPS, ({ frame }) => {
document.body.innerHTML = `${Math.floor(frame / FPS)} ${frame}`;
})();
```
});
```javascript
let stopped = false;
fps(requestAnimationFrame)(24, () => {
if (someStopCondition) {
stopped = true;
console.log('Logs a single time');
} else {
console.log('Logs 24 times per-second until someStopCondition is met');
}
}, () => stopped)();
fi.start();
// ...
fi.stop();
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc