Huge News!Announcing our $40M Series B led by Abstract Ventures.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.1 to 0.0.2

9

index.js
module.exports = function(raf) {
return function(fps, tick) {
var delta;
var now;
return function(fps, tick, stop) {
var delta, now;
var then = Date.now();

@@ -9,4 +8,8 @@ var frame = 0;

stop = stop || function() { return false; };
function draw() {
raf(function() {
if (stop()) return;
return draw(tick);

@@ -13,0 +16,0 @@ });

{
"name": "frame-interval",
"version": "0.0.1",
"version": "0.0.2",
"description": "Execute a function n-times per second, on requestAnimationFrame",

@@ -5,0 +5,0 @@ "main": "index.js",

# frame-interval
Execute a function n-times per second, on requestAnimationFrame
## Installation
```
npm i frame-interval --save
```
## Usage
```javascript
import fps from 'frame-interval';
const start = fps(requestAnimationFrame)(30, draw);
const FPS = 30;
start();
fps(requestAnimationFrame)(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)();
```
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