resource-keeper
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published

resource-keeper

A tool for automatically managing and stably recycling unmanaged resources.

Usage

import { ResourceKeeper } from "resource-keeper";

(async () => {
  const foo = await ResourceKeeper.create(async () => {
    const foo = { count: 0 };

    const timer = setInterval(() => foo.count++, 100);

    return [foo, async () => clearInterval(timer)];
  });

  const unretain = foo.retain();
  setInterval(() => {
    if (foo.isDisposed) {
      console.log("disposed");
    } else {
      console.log(foo.resource.count);
    }
  }, 100);
})();

Package Sidebar

Install

npm i resource-keeper

Weekly Downloads

1

Version

0.0.1

License

BSD-3-Clause

Unpacked Size

23.2 kB

Total Files

27

Last publish

Collaborators

  • i-play-lf2