destruction-notifiable

Node.js destruction notifiable types (N-API).

Usage no npm install needed!

<script type="module">
  import destructionNotifiable from 'https://cdn.skypack.dev/destruction-notifiable';
</script>

README

destruction-notifiable-js

Node.js destruction notifiable types (N-API).

Usage:

// test.js
var dn = require('destruction-notifiable');

function forceGC() {
    if (global.gc) {
        global.gc();
    } else {
        console.warn('No GC hook! Start your program as `node --expose-gc ./test.js`.');
    }
}

function test() {
    var obj = new dn.Destructible(42, function(id) {
        console.log("object destructed " + id);
    });
}

test();
forceGC();

Run:

node --expose-gc ./test.js

Expected output:

object destructed 42