sbrm

1.0.0 • Public • Published

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 */ }
);

Package Sidebar

Install

npm i sbrm

Weekly Downloads

7

Version

1.0.0

License

unlicense

Unpacked Size

4.49 kB

Total Files

7

Last publish

Collaborators

  • diasbruno