Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Typed EventEmitter implemented with tsargs, based on nodejs EventEmitter.
Fully implements NodeJS.EventEmitter
type, provides interface & proxy class.
npm i tsee
Simple usage:
import { EventEmitter } from 'tsee';
const events = new EventEmitter<{
foo: (a: number, b: string) => void,
}>();
// foo's arguments is fully type checked
events.emit('foo', 123, 'hello world');
Cast any other compatible to NodeJS.EventEmitter
to typed:
import { asTypedEventEmitter } from 'tsee';
const typedEmitter = asTypedEventEmitter<{
foo: (a: number, b: string) => void,
boo: (a: number, b: string) => void,
}>(myEmitter);
typedEmitter.emit('foo', 123, 'hello world');
If you use custom EventEmitter implementation, you can simply cast it to tsee.IEventEmitter
interface:
import { CustomEventEmitter } from 'my-event-emitter';
import * as tsee from 'tsee';
// Simple type case
const typed = new CustomEventEmitter() as any as tsee.IEventEmitter<{ ... }>;
// Functional cast with `NodeJS.EventEmitter` type constraints
const typed = asTypedEventEmitter<{ ... }>(new CustomEventEmitter());
tsee.EventEmitter
class is implemented EventEmitter from 'events' package.
EventEmitter<T>
where T
extends { [eventName]: Call signature }
.
EventEmitter.emit
's args is fully typed based on events map.
For foo
event in example above, signature is: emit(eventName: 'foo', a: number, b: string)
.
FAQs
Typed EventEmitter implemented with typed args
The npm package tsee receives a total of 2,840 weekly downloads. As such, tsee popularity was classified as popular.
We found that tsee 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
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.