@bunt/unit
Advanced tools
Comparing version 0.19.12 to 0.19.16
@@ -14,3 +14,3 @@ "use strict"; | ||
static async resolve(value) { | ||
if (Service_1.isService(value)) { | ||
if ((0, Service_1.isService)(value)) { | ||
return value.resolve(); | ||
@@ -44,3 +44,3 @@ } | ||
}); | ||
if (Runtime_1.isDisposable(value)) { | ||
if ((0, Runtime_1.isDisposable)(value)) { | ||
this.disposables.add(value); | ||
@@ -47,0 +47,0 @@ } |
@@ -18,3 +18,3 @@ "use strict"; | ||
const finish = (error) => { | ||
if (Runtime_1.isRunnable(target)) { | ||
if ((0, Runtime_1.isRunnable)(target)) { | ||
const heartbeat = target.getHeartbeat(); | ||
@@ -21,0 +21,0 @@ heartbeat.destroy(error); |
@@ -47,3 +47,3 @@ "use strict"; | ||
if (this.disposed) { | ||
functions_1.dispose(disposable); | ||
(0, functions_1.dispose)(disposable); | ||
return; | ||
@@ -69,3 +69,3 @@ } | ||
try { | ||
await functions_1.dispose(disposable); | ||
await (0, functions_1.dispose)(disposable); | ||
this.logger.debug("dispose", { label, target, date, timeout: Date.now() - date.getTime() }); | ||
@@ -72,0 +72,0 @@ __classPrivateFieldGet(this, _Disposer_disposeHistory, "f").push({ label, target, date, timeout: Date.now() - date.getTime() }); |
@@ -7,3 +7,3 @@ "use strict"; | ||
function dispose(disposable) { | ||
if (util_1.isFunction(disposable)) { | ||
if ((0, util_1.isFunction)(disposable)) { | ||
return disposable(); | ||
@@ -10,0 +10,0 @@ } |
@@ -31,4 +31,4 @@ "use strict"; | ||
const value = __classPrivateFieldGet(this, _EnvReader_map, "f").get(key); | ||
util_1.assert(value, `The ${key} property should be defined`); | ||
return util_1.isFunction(parse) ? parse(value) : value; | ||
(0, util_1.assert)(value, `The ${key} property should be defined`); | ||
return (0, util_1.isFunction)(parse) ? parse(value) : value; | ||
} | ||
@@ -40,3 +40,3 @@ has(key) { | ||
const value = __classPrivateFieldGet(this, _EnvReader_map, "f").get(key); | ||
if (util_1.isDefined(value) && util_1.isFunction(opt)) { | ||
if ((0, util_1.isDefined)(value) && (0, util_1.isFunction)(opt)) { | ||
return opt(value); | ||
@@ -43,0 +43,0 @@ } |
@@ -52,3 +52,3 @@ "use strict"; | ||
static async watch(runnable) { | ||
if (internal_1.isRunnable(runnable)) { | ||
if ((0, internal_1.isRunnable)(runnable)) { | ||
const heartbeat = runnable.getHeartbeat(); | ||
@@ -55,0 +55,0 @@ return heartbeat.watch(); |
@@ -10,3 +10,3 @@ import { Promisify } from "@bunt/util"; | ||
export interface IDisposedHistory { | ||
error?: Error; | ||
error?: Error | unknown; | ||
label: string; | ||
@@ -13,0 +13,0 @@ timeout: number; |
@@ -8,7 +8,7 @@ "use strict"; | ||
function isDisposable(target) { | ||
return util_1.isObject(target) && "dispose" in target; | ||
return (0, util_1.isObject)(target) && "dispose" in target; | ||
} | ||
exports.isDisposable = isDisposable; | ||
function isRunnable(target) { | ||
return util_1.isObject(target) && "getHeartbeat" in target; | ||
return (0, util_1.isObject)(target) && "getHeartbeat" in target; | ||
} | ||
@@ -15,0 +15,0 @@ exports.isRunnable = isRunnable; |
@@ -71,3 +71,3 @@ "use strict"; | ||
catch (error) { | ||
this.logger.emergency(error.message, error.stack); | ||
this.logger.emergency("Unexpected error", error); | ||
} | ||
@@ -77,3 +77,3 @@ finally { | ||
} | ||
await Dispose_1.dispose(this); | ||
await (0, Dispose_1.dispose)(this); | ||
} | ||
@@ -83,9 +83,9 @@ async handle(result) { | ||
const object = await result; | ||
if (util_1.isUndefined(object) || util_1.isNull(object)) { | ||
if ((0, util_1.isUndefined)(object) || (0, util_1.isNull)(object)) { | ||
return; | ||
} | ||
if (internal_1.isRunnable(object)) { | ||
if ((0, internal_1.isRunnable)(object)) { | ||
this.queue.push(object.getHeartbeat()); | ||
} | ||
if (internal_1.isDisposable(object)) { | ||
if ((0, internal_1.isDisposable)(object)) { | ||
Dispose_1.Disposable.attach(this, object); | ||
@@ -92,0 +92,0 @@ } |
@@ -8,6 +8,6 @@ "use strict"; | ||
function isService(maybe) { | ||
if (!util_1.isObject(maybe)) { | ||
if (!(0, util_1.isObject)(maybe)) { | ||
return false; | ||
} | ||
return util_1.isInstanceOf(maybe, Service_1.Service) | ||
return (0, util_1.isInstanceOf)(maybe, Service_1.Service) | ||
|| (exports.SERVICE_KIND in maybe && "resolve" in maybe); | ||
@@ -14,0 +14,0 @@ } |
@@ -15,3 +15,3 @@ "use strict"; | ||
async resolve() { | ||
if (util_1.isFunction(this.resolver)) { | ||
if ((0, util_1.isFunction)(this.resolver)) { | ||
return this.resolver(); | ||
@@ -18,0 +18,0 @@ } |
@@ -41,6 +41,6 @@ "use strict"; | ||
static async getContext(context) { | ||
if (util_1.isFunction(context)) { | ||
if ((0, util_1.isFunction)(context)) { | ||
return this.getContext(await context()); | ||
} | ||
util_1.assert(util_1.isInstanceOf(context, Context_1.Context), `Wrong context type`); | ||
(0, util_1.assert)((0, util_1.isInstanceOf)(context, Context_1.Context), `Wrong context type`); | ||
return Context_1.Context.apply(await context); | ||
@@ -51,3 +51,3 @@ } | ||
for (const ctor of actions) { | ||
util_1.fails(util_1.isUndefined(ctor), "Wrong the Action type"); | ||
(0, util_1.fails)((0, util_1.isUndefined)(ctor), "Wrong the Action type"); | ||
if (!__classPrivateFieldGet(this, _Unit_registry, "f").has(ctor)) { | ||
@@ -63,3 +63,3 @@ __classPrivateFieldGet(this, _Unit_registry, "f").add(ctor); | ||
for (const ctor of actions) { | ||
util_1.fails(util_1.isUndefined(ctor), "Wrong the Action type"); | ||
(0, util_1.fails)((0, util_1.isUndefined)(ctor), "Wrong the Action type"); | ||
if (__classPrivateFieldGet(this, _Unit_registry, "f").has(ctor)) { | ||
@@ -77,4 +77,4 @@ __classPrivateFieldGet(this, _Unit_registry, "f").delete(ctor); | ||
const finish = this.logger.perf("action", { action: ctor.name }); | ||
util_1.assert(util_1.isClass(ctor), "Wrong the Action type"); | ||
util_1.assert(__classPrivateFieldGet(this, _Unit_registry, "f").has(ctor), `Unknown action ${ctor.name}`); | ||
(0, util_1.assert)((0, util_1.isClass)(ctor), "Wrong the Action type"); | ||
(0, util_1.assert)(__classPrivateFieldGet(this, _Unit_registry, "f").has(ctor), `Unknown action ${ctor.name}`); | ||
const action = new ctor(__classPrivateFieldGet(this, _Unit_context, "f"), state); | ||
@@ -81,0 +81,0 @@ return Promise.resolve(action.run()).finally(finish); |
{ | ||
"name": "@bunt/unit", | ||
"version": "0.19.12", | ||
"version": "0.19.16", | ||
"keywords": [ | ||
@@ -29,6 +29,6 @@ "typescript" | ||
"dependencies": { | ||
"@bunt/util": "^0.19.12" | ||
"@bunt/util": "^0.19.16" | ||
}, | ||
"license": "MIT", | ||
"gitHead": "af2ad3c8c543ddc526a1333910f5487d80c84d78" | ||
"gitHead": "4d9fc4fc6414228f9cfb275f9cead9a53bca76c0" | ||
} |
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
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
64583
Updated@bunt/util@^0.19.16