charmander / gc-listen

Calls a function when V8 collects an object as garbage

Home Page:https://www.npmjs.com/package/gc-listen

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gc-listen

A way to attach a JavaScript function with napi_add_finalizer. For debugging.

const gcListen = require('gc-listen');

const obj = {};

const callback = () => {
    // …
};

gcListen(obj, callback);

callback won’t be called as long as obj isn’t eligible for garbage collection. N-API even suggests it will be called when obj is collected. It will always be called asynchronously when called at all.

About

Calls a function when V8 collects an object as garbage

https://www.npmjs.com/package/gc-listen

License:ISC License


Languages

Language:C 97.6%Language:Python 2.4%