
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
optimized-resize-observer
Advanced tools
ResizeObservers can be tricky to throttle and debounce. This package delivers both in a very easy to use format!
ResizeObservers can be tricky to throttle and debounce. This package delivers both in a very easy to use format!
Debouncing is delaying the execution of a function until a long enough gap in time (the debounce time) has elapsed without any additional interactions.
Usage of the debouncedResizeObserver:
import { debouncedResizeObserver } from 'optimized-resize-observer';
const resizeObserver = debouncedResizeObserver({
singleEntryCallback: ({ entry }) => console.log('ResizeObserverEntry', entry),
debounceTimeInMs: 250
});
resizeObserver.observe(document.querySelector('#my-element-id'));
Throttling is limiting the number of times a function is executed for a given time interval (throttle time).
For the throttledResizeObserver we will execute on both the leading edge of the throttling window, and the trailing edge. In other words, the callback will be invoked immediately as well as at the end of the throttleTimeInMs.
There are a few reasons for this:
Invoking on both the leading and trailing edge solves both of these issues.
Usage of the throttledResizeObserver:
import { throttledResizeObserver } from 'optimized-resize-observer';
const resizeObserver = throttledResizeObserver({
singleEntryCallback: ({ entry }) => console.log('ResizeObserverEntry', entry),
throttleTimeInMs: 250
});
resizeObserver.observe(document.querySelector('#my-element-id'));
Until the ResizeObserver class is supported by jsdom, here's an option for testing:
beforeEach(() => {
Object.defineProperty(global, "ResizeObserver", {
writable: true,
value: jest.fn().mockImplementation(() => ({
observe: jest.fn(),
unobserve: jest.fn(),
disconnect: jest.fn(),
})),
});
});
FAQs
ResizeObservers can be tricky to throttle and debounce. This package delivers both in a very easy to use format!
We found that optimized-resize-observer 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.