Research
Security News
Malicious PyPI Package ‘pycord-self’ Targets Discord Developers with Token Theft and Backdoor Exploit
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
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.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.