Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Coordinate requestAnimationFrame
calls across your app and/or libraries.
ReactDOM.unstable_batchedUpdates
)
import { raf } from 'rafz'
// Schedule an update
raf(dt => {})
// Start an update loop
raf(dt => true)
// Cancel an update
raf.cancel(fn)
// Schedule a mutation
raf.write(() => {})
// Before any updates
raf.onStart(() => {})
// Before any mutations
raf.onFrame(() => {})
// After any mutations
raf.onFinish(() => {})
// Set a timeout that runs on nearest frame
raf.setTimeout(() => {}, 1000)
// Use a polyfill
raf.use(require('@essentials/raf').raf)
// Get the current time
raf.now() // => number
update
phase is for updating JS state (eg: advancing an animation).write
phase is for updating native state (eg: mutating the DOM).write
phase.onFrame
phase.true
to run again next frame.raf.cancel
function only works with raf
handlers.raf.sync
to disable scheduling in its callback.raf.batchedUpdates
to avoid excessive re-rendering in React.
raf.throttle
Wrap a function to limit its execution to once per frame. If called more than once in a single frame, the last arguments are used.
let log = raf.throttle(console.log)
log(1)
log(2) // nothing logged yet
raf.onStart(() => {
// "2" is logged by now
})
// Cancel a pending call.
log.cancel()
// Access the wrapped function.
log.handler
FAQs
requestAnimationFrame for libraries
The npm package rafz receives a total of 22,797 weekly downloads. As such, rafz popularity was classified as popular.
We found that rafz demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.