MCPcopy Index your code
hub / github.com/WebReflection/weak-value

github.com/WebReflection/weak-value @v1.0.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.0.2 ↗ · + Follow
27 symbols 49 edges 3 files 2 documented · 7%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

WeakValue

Build Status Coverage Status

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 or greater.

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.

Core symbols most depended-on inside this repo

set
called by 6
esm/index.js
delete
called by 5
esm/index.js
get
called by 4
esm/index.js
delete
called by 3
cjs/index.js
get
called by 3
cjs/index.js
has
called by 2
esm/index.js
onValueCollected
called by 2
test/index.js
clear
called by 1
esm/index.js

Shape

Method 20
Class 4
Function 3

Languages

TypeScript100%

Modules by API surface

esm/index.js13 symbols
cjs/index.js13 symbols
test/index.js1 symbols

For agents

$ claude mcp add weak-value \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact