npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

resource-tracker

v0.0.1

Published

A squint port of tech.resource.

Downloads

676

Readme

resource-tracker

This is a squint port of tech.resource, to provide parallel functionality in an ES module.

Cross-platform RAII (stack-scoped) and GC-based cleanup for opaque JavaScript resources. Distributed as a single squint-compiled ES module for managing resources that have no implicit JS garbage-collection story of their own (native pointers held by WASM modules, worker-scoped handles, etc.).

Installation

npm install resource-tracker

Requires Node 18.18+, the floor for Symbol.dispose / Symbol.asyncDispose.

Usage from JavaScript

Deterministic cleanup at scope exit:

import * as resource from 'resource-tracker';

resource.releasing_fn(() => {
  const ptr = allocateNativePointer();
  resource.track(ptr, { tracktype: 'stack', disposefn: () => freePointer(ptr) });
  // ...use ptr...
});  // dispose fires LIFO here

GC-backed cleanup for resources that escape their creating scope:

resource.track(ptr, { tracktype: 'gc', disposefn: () => freePointer(ptr) });
// dispose fires after the runtime collects ptr

Combined first-wins (release no later than scope exit, GC-cleanup as a safety net):

resource.track(ptr, {
  tracktype: ['gc', 'stack'],
  disposefn: () => freePointer(ptr),
});

auto (the default) picks stack if a context is bound and gc otherwise.

ES2023 Explicit Resource Management integration. The native using keyword needs Node 24+ or a transpiler; the make_closeable_context, .close(), and [Symbol.dispose] APIs it builds on work on any supported Node:

using ctx = resource.make_closeable_context(() => {
  resource.stack_track(someFileHandle);  // anything with .close() works
  return computeValue();
});
console.log(ctx.value);
// ctx[Symbol.dispose]() fires at scope exit; releases entries LIFO
using ctx = resource.make_closeable_context(() => {
  resource.stack_track({ [Symbol.dispose]() { shutdownNetworkSync(); } });
});
// closes synchronously; async-dispose flushing is a consumer concern
// (see clj-native's pool/flush-pending-disposes! for that path).

Usage from Squint or ClojureScript

Require it by package name. Squint and ClojureScript both munge hyphenated names to the compiled exports, so you write idiomatic Clojure (releasing-fn, in-stack-resource-context?) rather than the releasing_fn / in_stack_resource_context_QMARK_ JS spellings:

(ns my.app
  (:require ["resource-tracker" :as resource]))

(resource/releasing-fn
  (fn []
    (resource/track ptr #js {:tracktype "stack"
                             :disposefn #(free-pointer! ptr)})))
;; dispose fires LIFO when releasing-fn returns

Options are JS objects with string values, the same shape as the JavaScript API above, not tech.resource's {:track-type :stack} keyword maps:

(resource/track ptr #js {:tracktype "gc" :disposefn f})
(resource/track ptr #js {:tracktype #js ["gc" "stack"] :disposefn f})

The interop form with the literal export name, (.releasing_fn resource (fn [] ...)), works identically and is what the test suite uses.

License

Distributed under the Eclipse Public License 1.0 (EPL-1.0), the same license as tech.resource. See LICENSE.