# weak-value **Repository Path**: mirrors_WebReflection/weak-value ## Basic Information - **Project Name**: weak-value - **Description**: A Map with weakly referenced values, instead of keys - **Primary Language**: Unknown - **License**: ISC - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-19 - **Last Updated**: 2025-12-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # WeakValue 📣 Check out [not-so-weak](https://github.com/WebReflection/not-so-weak) module for better and faster `WValue` alternative - - - [![Build Status](https://travis-ci.com/WebReflection/weak-value.svg?branch=master)](https://travis-ci.com/WebReflection/weak-value) [![Coverage Status](https://coveralls.io/repos/github/WebReflection/weak-value/badge.svg?branch=master)](https://coveralls.io/github/WebReflection/weak-value?branch=master) A Map with weakly referenced values, instead of keys, with an optional *onValueCollected* callback to pass aslong. In Node.js, it requires [V8 release v8.4](https://v8.dev/blog/v8-release-84) or greater. ```js import WeakValue from 'weak-value'; // const WeakValue = require('weak-value'); const wv = new WeakValue; (() => { const value = {}; wv.set('any-key', value, /* optional */ (key, map) => { // will log "any-key value collected" once GC kicks in console.log(key, 'value collected'); console.log(map === wv); // true }); })(); ``` Please note that explicit `wv.delete(key)` will *NOT* invoke *onValueCollected*, as deleting a key does not mean its referenced value has been collected.