frame-interval
Advanced tools
Comparing version 0.0.2 to 0.0.3-canary.14.1.0
{ | ||
"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(); | ||
``` |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
11402
2
17
181
43
1