Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
weak-ref-collections
Advanced tools
Iterable WeakMaps and WeakSets. Provides WeakRefMap and WeakRefSet which store values using WeakRefs and clean themselves up when garbage collected.
Iterable WeakMaps and WeakSets. Provides WeakRefMap and WeakRefSet which store object values using WeakRefs and clean themselves up when garbage collected. Supports both objects and primitives simultaneously. Behaves like normal Map and Set for primitives.
npm install weak-ref-collections
Unlike WeakMap which stores keys weakly, WeakRefMap stores keys strongly but stores values using WeakRefs. Is fully iterable. Works just like a normal Map object but holds its values weakly and cleans itself up when its values are garbage collected. Follows the Map API
const { WeakRefMap } = require("weak-ref-collections");
weakRefMap = new WeakRefMap();
weakRefMap.set("foo", {"bar": 1});
weakRefMap.get("foo"); // {"bar":1}
weakRefMap.has("foo"); // true
weakRefMap.delete("foo"); // true
weakRefMap.clear(); // undefined
weakRefMap.forEach((value, key, map) => {});
// Supports iteration
for (const [key, value] of weakRefMap) {}
for (const [key, value] of weakRefMap.entries()) {}
for (const key of weakRefMap.keys()) {}
for (const value of weakRefMap.values()) {}
Similarly for WeakRefSet is fully iterable unlike WeakSet. Works just like a normal Set object but holds its values weakly and cleans itself up when its values are garbage collected. Follows the Set API
const { WeakRefSet } = require("weak-ref-set");
weakRefSet = new WeakRefSet();
const element = {"bar": 1};
weakRefSet.add(element);
weakRefSet.has(element); // true
weakRefSet.delete(element); // true
weakRefSet.clear(); // undefined
weakRefSet.forEach((value, alsoValue, set) => {});
// Supports iteration
for (const [value, alsoValue] of weakRefSet) {}
for (const [value, alsoValue] of weakRefSet.entries()) {}
for (const value of weakRefSet.keys()) {}
for (const value of weakRefSet.values()) {}
FAQs
Iterable WeakMaps and WeakSets. Provides WeakRefMap and WeakRefSet which store values using WeakRefs and clean themselves up when garbage collected.
We found that weak-ref-collections 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.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.