Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
weak-ref-cache
Advanced tools
Readme
The weak-ref-cache
package is a utility module designed to help you manage and reuse weak references to objects in JavaScript. With this package, you can retrieve weak references to objects and compare them using the same equality comparison as you would use for the objects themselves. Furthermore, it ensures that only one WeakRef
instance is created per object, promoting memory efficiency.
npm install weak-ref-cache
Here's how you can use the weak-ref-cache
package:
getWeakRef
function from the package.getWeakRef
function to get a weak reference to an object.getWeakRef
function just like you would compare the objects themselves.import getWeakRef from "weak-ref-cache";
const obj = { foo: "bar" };
const weakRef = getWeakRef(obj);
console.log(weakRef === getWeakRef(obj)); // true
console.log(weakRef === new WeakRef(obj)); // false
getWeakRef(obj: object): WeakRef
obj
(Object): The object for which you want to get a weak reference.WeakRef
instance representing a weak reference to the obj
. If a weak reference to the obj
was previously created by getWeakRef
, it returns the same WeakRef
instance.FAQs
Returns the same unique WeakRef instance per object.
The npm package weak-ref-cache receives a total of 0 weekly downloads. As such, weak-ref-cache popularity was classified as not popular.
We found that weak-ref-cache demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.