Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cleanup-util

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cleanup-util

A utility for cleaning up event handlers in nodejs.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

cleanup-util · GitHub license

Utility for cleaning up event handlers

cleanup-util is a small, utility for tracking and cleaning up event handlers. I find this utility useful when I have classes derived from EventHandler that are used throughout the life of my applications and those EventHandlers frequently have event handlers added and removed. It helps me catch memory leaks from dangling event listeners early in the development process. I hope you find it useful.

Installing / Getting started

cleanup-util is installed using npm:

npm install -S cleanup-util

In the above command we install cleanup-util into the local project, updating the dependencies in the project.json file.

API

cleanupPropagationEvent

function cleanupPropagationEvent<T extends EventEmitter>(
  sender: T,
  event: string,
  listener: Listener,
  target: EventEmitter,
  reciprocal?: string,
): void;

Attaches the specified listener to the specified sender, wrapping the listener to track it's cleanup.

If reciprocal is specified, it is the name of an event on target, cleanup-util will attach an event handler to the target to cleanup in the background if necessary.

addCleanupTask

function addCleanupTask<S extends EventEmitter, T>(
  sender: S,
  target: T,
  task: Task,
): void;

Adds a task to be run when the cleanup propagation event occurs.

iid(target)

Associates an instance Id with a target object.

getIid(target)

Gets the instance Id associated with an object.

clearId

Clears the instance Id associated with an object.

Tests

Tests are built using Jest; we're near 100%!

npm test

Licensing

This project is licensed by the MIT license found in this repository's root.

Keywords

FAQs

Package last updated on 30 Jan 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc