Skip to content

⇢ A zero-dependency lightweight library for iterable weak collections and proxies

Notifications You must be signed in to change notification settings

Thundercraft5/weak-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

weak-utils

weak-utils is a zero-dependency lightweight library written in TypeScript that provides weak reference utilities.

What does this do?

weak-utils has 3 components:

Usage

Use as you would a regular Map or WeakMap. Has all methods of Map.

Use as you would a regular Set or WeakSet. Has all methods of Set.

Use as you would a regular a regular proxy, supports revocable proxies as well.

This object works by registering a finalizer for the target value via FinalizationRegistry(), then, when the target value is collected, the proxy is revoked.

The use cases for weak proxies are currently unknown in JS, I added this feature as the result of an experiment. To register a finalizer method, pass a finalize() method in the handler object.

About

⇢ A zero-dependency lightweight library for iterable weak collections and proxies

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published