@cardano-sdk/util
Advanced tools
Comparing version 0.6.1-nightly.0 to 0.7.0-nightly.0
@@ -43,2 +43,3 @@ "use strict"; | ||
_ManagedFreeableScope_scopeStack = new WeakMap(), _ManagedFreeableScope_disposed = new WeakMap(); | ||
const isPromise = (obj) => typeof obj === 'object' && typeof obj.then === 'function'; | ||
class AutoFree { | ||
@@ -52,7 +53,22 @@ constructor(cb) { | ||
execute() { | ||
let result; | ||
try { | ||
return __classPrivateFieldGet(this, _AutoFree_callback, "f").call(this, __classPrivateFieldGet(this, _AutoFree_scope, "f")); | ||
result = __classPrivateFieldGet(this, _AutoFree_callback, "f").call(this, __classPrivateFieldGet(this, _AutoFree_scope, "f")); | ||
if (isPromise(result)) { | ||
return result | ||
.then((value) => { | ||
__classPrivateFieldGet(this, _AutoFree_scope, "f").dispose(); | ||
return value; | ||
}) | ||
.catch((error) => { | ||
__classPrivateFieldGet(this, _AutoFree_scope, "f").dispose(); | ||
throw error; | ||
}); | ||
} | ||
__classPrivateFieldGet(this, _AutoFree_scope, "f").dispose(); | ||
return result; | ||
} | ||
finally { | ||
catch (error) { | ||
__classPrivateFieldGet(this, _AutoFree_scope, "f").dispose(); | ||
throw error; | ||
} | ||
@@ -59,0 +75,0 @@ } |
@@ -39,2 +39,3 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { | ||
_ManagedFreeableScope_scopeStack = new WeakMap(), _ManagedFreeableScope_disposed = new WeakMap(); | ||
const isPromise = (obj) => typeof obj === 'object' && typeof obj.then === 'function'; | ||
class AutoFree { | ||
@@ -48,7 +49,22 @@ constructor(cb) { | ||
execute() { | ||
let result; | ||
try { | ||
return __classPrivateFieldGet(this, _AutoFree_callback, "f").call(this, __classPrivateFieldGet(this, _AutoFree_scope, "f")); | ||
result = __classPrivateFieldGet(this, _AutoFree_callback, "f").call(this, __classPrivateFieldGet(this, _AutoFree_scope, "f")); | ||
if (isPromise(result)) { | ||
return result | ||
.then((value) => { | ||
__classPrivateFieldGet(this, _AutoFree_scope, "f").dispose(); | ||
return value; | ||
}) | ||
.catch((error) => { | ||
__classPrivateFieldGet(this, _AutoFree_scope, "f").dispose(); | ||
throw error; | ||
}); | ||
} | ||
__classPrivateFieldGet(this, _AutoFree_scope, "f").dispose(); | ||
return result; | ||
} | ||
finally { | ||
catch (error) { | ||
__classPrivateFieldGet(this, _AutoFree_scope, "f").dispose(); | ||
throw error; | ||
} | ||
@@ -55,0 +71,0 @@ } |
{ | ||
"name": "@cardano-sdk/util", | ||
"version": "0.6.1-nightly.0", | ||
"version": "0.7.0-nightly.0", | ||
"description": "General, not cardano-specific utils", | ||
@@ -76,3 +76,3 @@ "engines": { | ||
], | ||
"gitHead": "01489cd2e4a1a1c8863fd654de4efc1ccf4db1d4" | ||
"gitHead": "ed865b11749dab31502dc09e7cc76446ad268d2b" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
337855
892