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.
A simple mock for requestAnimationFrame testing with fake timers and request IDs.
A simple mock for requestAnimationFrame
testing with fake timers. This is a fork of the
mock-raf package provided by Alex Lande which can be found
here
. This fork implements request IDs, which
can be used e.g. to test if the right animation frames are cancelled.
var createMockRaf = require('mock-raf');
var mockRaf = createMockRaf();
// Stub out your `requestAnimationFrame` method
sinon.stub(window, 'requestAnimationFrame', mockRaf.raf);
// Take 10 `requestAnimationFrame` steps (your callback will fire 10 times)
mockRaf.step(10);
createMockRaf()
Creates a mockRaf
instance, exposing the functions you'll use to interact with the mock.
Returns:
var mockRaf = createMockRaf();
now()
Returns the current now
value of the mock. Starts at 0 and increases with each step()
taken. Useful for stubbing out performance.now()
or a polyfill when using requestAnimationFrame
with timers.
raf()
Replacement for requestAnimationFrame
or a polyfill. Adds a callback to be fired on the next step
and returns an id
which may be used with cancel()
.
cancel([id])
Replacement for cancelAnimationFrame
or a polyfill. If provided with an id
, it removes the
requestAnimationFrame
callback associated with this id
if it exists.
If no argument is provided,
all queued requestAnimationFrame
callbacks are removed.
step(options)
Takes requestAnimationFrame
steps. Fires currently queued callbacks for each step and increments now
time for each step. The primary way to interact with a mockRaf
instance for testing.
step()
takes an optional options
object:
time
Type: Number
Default: 1000 / 60
The time that should pass during each requestAnimationFrame
step in milliseconds. Default is roughly equivalent to default browser behavior.
count
Type: Number
Default: 1
The number of steps to take.
FAQs
A simple mock for requestAnimationFrame testing with fake timers and request IDs.
The npm package mockraf receives a total of 3 weekly downloads. As such, mockraf popularity was classified as not popular.
We found that mockraf 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.