JSPM

sbrm

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q28859F
  • License unlicense

Scope bound resource management (lisp's with pattern, c++'s raii)

Package Exports

  • sbrm
  • sbrm/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sbrm) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

sbrm - scoped bound resource management

lisp has the with pattern which is also present in python. c++ has RAII (resource acquisition is instantiation).

there are 2 versions:

  • scoped
scope(
  () => new $class(),
  (instance) => instance.release()
)(
  (instance) => { /* use the instance */ }
);
  • scopedClass
class A {
  // acquire the object
  static acquire() { return new A; }
  // release object
  static release(i) { i.release(); }

  constructor() { /* acquire resources */ }
  work() { return 1; }
  release() { /* release stuff */ };
}

scopedClass(A)(
  (instance) => { /* use the instance */ }
);