Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
TypeScript definitions for raf
@types/raf is a TypeScript type definition package for the 'raf' library, which provides a polyfill for requestAnimationFrame. This package allows TypeScript developers to use the 'raf' library with type safety.
Polyfill for requestAnimationFrame
This feature provides a polyfill for the requestAnimationFrame function, allowing you to schedule a callback to be called during the next repaint cycle. The code sample demonstrates how to import the 'raf' function and use it to log the timestamp of the animation frame.
import raf from 'raf';
raf((timestamp) => {
console.log(`Animation frame at ${timestamp}`);
});
Cancel animation frame
This feature allows you to cancel a scheduled animation frame callback. The code sample shows how to schedule an animation frame and then cancel it using the 'raf.cancel' method.
import raf from 'raf';
const id = raf((timestamp) => {
console.log(`Animation frame at ${timestamp}`);
});
raf.cancel(id);
The 'requestanimationframe' package provides a polyfill for requestAnimationFrame similar to 'raf'. It also ensures compatibility across different browsers. Compared to '@types/raf', it does not include TypeScript type definitions out of the box.
The 'raf-schd' package is a scheduler for requestAnimationFrame, which helps in debouncing and throttling animations. It provides more advanced scheduling capabilities compared to 'raf', but like 'requestanimationframe', it does not include TypeScript type definitions by default.
npm install --save @types/raf
This package contains type definitions for raf (https://github.com/chrisdickinson/raf#readme).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/raf.
declare const raf: {
(callback: (timestamp: number) => void): number;
cancel: (handle: number) => void;
polyfill: (globalObject?: any) => void;
};
export = raf;
These definitions were written by Ben Lorantfy.
FAQs
TypeScript definitions for raf
The npm package @types/raf receives a total of 1,311,926 weekly downloads. As such, @types/raf popularity was classified as popular.
We found that @types/raf 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
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.