
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
@adoratorio/medusa
Advanced tools
Medusa is a lightweight, SSR-friendly utility for managing multiple IntersectionObservers with flexible event emission, fine-grained control, native once support, and memory-safe cleanup. Ideal for lazy loading, animations, and viewport-based triggers in
A lightweight utility for managing multiple IntersectionObserver instances with TypeScript support.
npm install @adoratorio/medusa
import Medusa from '@adoratorio/medusa';
const medusa = new Medusa({ debug: true });
Parameter | Type | Default | Description |
---|---|---|---|
observers | MedusaObserverConfig[] | [] | Array of observer configurations |
debug | boolean | false | Enable console debugging |
interface MedusaObserverConfig {
id: string;
root?: Element | null;
rootMargin?: string;
threshold?: number | number[];
nodes?: Element | Element[];
mode?: MODE;
emit?: boolean;
callback?: MedusaCallback;
}
type MedusaCallback = (
entry: IntersectionObserverEntry,
observer: IntersectionObserver | null,
) => void;
Parameter | Type | Default | Description |
---|---|---|---|
id | string | required | Unique observer identifier |
root | Element | null | Viewport element for intersection checking |
rootMargin | string | '0px' | Margin around root (CSS format) |
threshold | number|number[] | 0 | Intersection threshold(s) |
mode | MODE | DEFAULT | Observer behavior mode |
emit | boolean | false | Emit custom events on intersection |
callback | MedusaCallback | undefined | Intersection callback function |
enum MODE {
DEFAULT = 'DEFAULT', // Trigger on every intersection
ONCE = 'ONCE', // Trigger only once
BYPIXELS = 'BYPIXELS', // Trigger per pixel in viewport
}
// Add single observer
medusa.addObserver({
id: 'myObserver',
threshold: 0.5,
callback: (entry, observer) => console.log('Intersecting:', entry.isIntersecting),
});
// Add multiple observers
medusa.addObserver([
{ id: 'observer1', mode: Medusa.MODE.ONCE },
{ id: 'observer2', mode: Medusa.MODE.BYPIXELS },
]);
// Observe single element
const element = document.querySelector('.target');
medusa.observe('myObserver', element);
// Observe with custom callback
medusa.observe('myObserver', element, (entry, observer) => {
console.log('Custom callback for this element');
});
// Observe multiple elements
const elements = document.querySelectorAll('.targets');
medusa.observe('myObserver', Array.from(elements));
// Get observer instance
const observer = medusa.getObserver('myObserver');
// Clear specific observer
medusa.clearObserver('myObserver');
// Clear all observers
medusa.clearAllObservers();
// Remove specific observer
medusa.removeObserver('myObserver');
// Remove all observers
medusa.removeAllObservers();
// Unobserve elements
medusa.unobserve('myObserver', element);
// Destroy instance
medusa.destroy();
When emit: true
is set, Medusa emits custom events on intersecting elements:
// Event name format: medusa-${observerId}
element.addEventListener('medusa-myObserver', (event: CustomEvent) => {
const entry: IntersectionObserverEntry = event.detail;
console.log('Intersection ratio:', entry.intersectionRatio);
});
The event.detail contains the IntersectionObserverEntry:
{
time: number;
rootBounds: DOMRectReadOnly;
boundingClientRect: DOMRectReadOnly;
intersectionRect: DOMRectReadOnly;
isIntersecting: boolean;
intersectionRatio: number;
target: Element;
}
Medusa is written in TypeScript and includes full type definitions:
import type {
MedusaOptions,
MedusaObserverConfig,
MedusaCallback,
} from '@adoratorio/medusa';
FAQs
Medusa is a lightweight, SSR-friendly utility for managing multiple IntersectionObservers with flexible event emission, fine-grained control, native once support, and memory-safe cleanup. Ideal for lazy loading, animations, and viewport-based triggers in
We found that @adoratorio/medusa demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers 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
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.