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

Execute a function n-times per second, on requestAnimationFrame

  • 1.0.34
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
decreased by-37.5%
Maintainers
1
Weekly downloads
 
Created
Source

frame-interval

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

yarn add frame-interval

Usage

import { FrameInterval } from "frame-interval";

const FPS = 24;

// 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}`;
});

fi.start();
// ...
fi.stop();

Keywords

FAQs

Package last updated on 11 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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