3 ms·
Those seem like things you'd do multiple places and it would be a good idea to make them into a function. If you have a one-off, defer is nicer looking but usi
by Dylan16807 3y ago
Those seem like things you'd do multiple places and it would be a good idea to make them into a function.
If you have a one-off, defer is nicer looking but using is perfectly capable of doing the job:
function defer_it(callback) {
return { [Symbol.dispose]: callback };
}
// will look better with using void
using _ = defer_it(()=>logger.log("exit"));
Or use DisposableStack() as another comment in this thread mentions.