Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bunt/unit

Package Overview
Dependencies
Maintainers
1
Versions
94
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bunt/unit - npm Package Compare versions

Comparing version 0.29.12 to 0.29.13

6

dist/esm/Action.js

@@ -1,2 +0,5 @@

export class Action {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Action = void 0;
class Action {
state;

@@ -12,2 +15,3 @@ context;

}
exports.Action = Action;
//# sourceMappingURL=Action.js.map

20

dist/esm/Context/Context.js

@@ -1,11 +0,14 @@

import { Logger } from "@bunt/util";
import { isDisposable } from "../Runtime/index.js";
import { isService, Service } from "../Service/index.js";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Context = void 0;
const util_1 = require("@bunt/util");
const index_js_1 = require("../Runtime/index.js");
const index_js_2 = require("../Service/index.js");
const cache = new WeakMap();
const services = new WeakMap();
export class Context {
static logger = Logger.factory(Context);
class Context {
static logger = util_1.Logger.factory(Context);
static disposables = new Set();
static async resolve(value) {
if (isService(value)) {
if ((0, index_js_2.isService)(value)) {
const resolved = services.get(value) ?? value.resolve();

@@ -31,3 +34,3 @@ if (!services.has(value)) {

const descriptionMap = Object.getOwnPropertyDescriptors(context);
for (const key of Service.getReferences(context, Context)) {
for (const key of index_js_2.Service.getReferences(context, Context)) {
if (Reflect.has(context, key)) {

@@ -44,3 +47,3 @@ const service = Reflect.get(context, key);

});
if (isDisposable(value)) {
if ((0, index_js_1.isDisposable)(value)) {
this.disposables.add(value);

@@ -64,2 +67,3 @@ }

}
exports.Context = Context;
//# sourceMappingURL=Context.js.map

@@ -1,4 +0,20 @@

export * from "./Context.js";
export * from "./interfaces.js";
export * from "./ShadowState.js";
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./Context.js"), exports);
__exportStar(require("./interfaces.js"), exports);
__exportStar(require("./ShadowState.js"), exports);
//# sourceMappingURL=index.js.map

@@ -1,2 +0,3 @@

export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=interfaces.js.map

@@ -0,3 +1,6 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ShadowState = void 0;
const weakState = new WeakMap();
export class ShadowState {
class ShadowState {
static get(state) {

@@ -10,2 +13,3 @@ return weakState.get(state);

}
exports.ShadowState = ShadowState;
//# sourceMappingURL=ShadowState.js.map

@@ -1,3 +0,7 @@

export class Disposable {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Disposable = void 0;
class Disposable {
}
exports.Disposable = Disposable;
//# sourceMappingURL=Disposable.js.map

@@ -0,1 +1,2 @@

"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

@@ -7,5 +8,7 @@ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;

};
import { logger, safeMap } from "@bunt/util";
import { dispose } from "./functions.js";
export class Disposer {
Object.defineProperty(exports, "__esModule", { value: true });
exports.Disposer = void 0;
const util_1 = require("@bunt/util");
const functions_js_1 = require("./functions.js");
class Disposer {
#disposables = [];

@@ -19,8 +22,9 @@ onDispose(disposable) {

this.logger.debug("dispose(%o)", this.#disposables.map(({ constructor: { name } }) => name));
await safeMap(this.#disposables.splice(0), dispose);
await (0, util_1.safeMap)(this.#disposables.splice(0), functions_js_1.dispose);
}
}
exports.Disposer = Disposer;
__decorate([
logger
util_1.logger
], Disposer.prototype, "logger", void 0);
//# sourceMappingURL=Disposer.js.map

@@ -1,2 +0,5 @@

export var DisposeState;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DisposeState = void 0;
var DisposeState;
(function (DisposeState) {

@@ -6,3 +9,3 @@ DisposeState[DisposeState["READY"] = 0] = "READY";

DisposeState[DisposeState["DISPOSED"] = 2] = "DISPOSED";
})(DisposeState || (DisposeState = {}));
})(DisposeState || (exports.DisposeState = DisposeState = {}));
//# sourceMappingURL=enum.js.map

@@ -1,7 +0,10 @@

import { safeMap } from "@bunt/util";
import { isFunction } from "@bunt/is";
import { toError } from "@bunt/assert";
import { isRunnable, SystemLogger } from "../Runtime/index.js";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.disposeAll = exports.dispose = void 0;
const util_1 = require("@bunt/util");
const is_1 = require("@bunt/is");
const assert_1 = require("@bunt/assert");
const index_js_1 = require("../Runtime/index.js");
const disposed = new WeakSet();
export async function dispose(disposable) {
async function dispose(disposable) {
if (disposed.has(disposable)) {

@@ -12,18 +15,18 @@ return;

const { constructor: { name } } = disposable;
const perf = SystemLogger.perf("disposed %s", name);
const perf = index_js_1.SystemLogger.perf("disposed %s", name);
try {
if (isFunction(disposable)) {
SystemLogger.debug("dispose %s()", name);
if ((0, is_1.isFunction)(disposable)) {
index_js_1.SystemLogger.debug("dispose %s()", name);
return Promise.resolve(disposable());
}
if (isRunnable(disposable)) {
SystemLogger.debug("destroy %s().getHeartbeat()", name);
if ((0, index_js_1.isRunnable)(disposable)) {
index_js_1.SystemLogger.debug("destroy %s().getHeartbeat()", name);
const heartbeat = disposable.getHeartbeat();
await dispose(heartbeat);
}
SystemLogger.debug("%s.dispose()", name);
index_js_1.SystemLogger.debug("%s.dispose()", name);
await disposable.dispose();
}
catch (error) {
SystemLogger.error(toError(error, "Unexpected error").message, error);
index_js_1.SystemLogger.error((0, assert_1.toError)(error, "Unexpected error").message, error);
}

@@ -34,5 +37,7 @@ finally {

}
export async function disposeAll(disposables) {
await safeMap(disposables, (disposable) => dispose(disposable));
exports.dispose = dispose;
async function disposeAll(disposables) {
await (0, util_1.safeMap)(disposables, (disposable) => dispose(disposable));
}
exports.disposeAll = disposeAll;
//# sourceMappingURL=functions.js.map

@@ -1,4 +0,20 @@

export * from "./Disposer.js";
export * from "./Disposable.js";
export * from "./functions.js";
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./Disposer.js"), exports);
__exportStar(require("./Disposable.js"), exports);
__exportStar(require("./functions.js"), exports);
//# sourceMappingURL=index.js.map

@@ -1,8 +0,13 @@

import { Unit } from "./Unit.js";
export function asyncify(factory) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.unit = exports.asyncify = void 0;
const Unit_js_1 = require("./Unit.js");
function asyncify(factory) {
return { factory };
}
export function unit(context) {
return Unit.factory(context);
exports.asyncify = asyncify;
function unit(context) {
return Unit_js_1.Unit.factory(context);
}
exports.unit = unit;
//# sourceMappingURL=fn.js.map

@@ -1,9 +0,25 @@

export * from "./interfaces.js";
export * from "./Unit.js";
export * from "./Action.js";
export * from "./Context/index.js";
export * from "./Service/index.js";
export * from "./Runtime/index.js";
export * from "./Dispose/index.js";
export * from "./fn.js";
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./interfaces.js"), exports);
__exportStar(require("./Unit.js"), exports);
__exportStar(require("./Action.js"), exports);
__exportStar(require("./Context/index.js"), exports);
__exportStar(require("./Service/index.js"), exports);
__exportStar(require("./Runtime/index.js"), exports);
__exportStar(require("./Dispose/index.js"), exports);
__exportStar(require("./fn.js"), exports);
//# sourceMappingURL=index.js.map

@@ -1,2 +0,3 @@

export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=interfaces.js.map

@@ -1,4 +0,7 @@

import { assert } from "@bunt/assert";
import { isDefined, isFunction } from "@bunt/is";
export class EnvReader {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EnvReader = void 0;
const assert_1 = require("@bunt/assert");
const is_1 = require("@bunt/is");
class EnvReader {
#map;

@@ -17,4 +20,4 @@ constructor(config) {

const value = this.#map.get(key);
assert(value, `The ${key} property should be defined`);
return isFunction(parse) ? parse(value) : value;
(0, assert_1.assert)(value, `The ${key} property should be defined`);
return (0, is_1.isFunction)(parse) ? parse(value) : value;
}

@@ -26,3 +29,3 @@ has(key) {

const value = this.#map.get(key);
if (isDefined(value) && isFunction(opt)) {
if ((0, is_1.isDefined)(value) && (0, is_1.isFunction)(opt)) {
return opt(value);

@@ -33,2 +36,3 @@ }

}
exports.EnvReader = EnvReader;
//# sourceMappingURL=EnvReader.js.map

@@ -0,1 +1,2 @@

"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

@@ -7,11 +8,13 @@ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;

};
import { logger } from "@bunt/util";
import { Defer } from "@bunt/async";
import { Disposer } from "../Dispose/index.js";
import { isRunnable } from "./internal.js";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Heartbeat = void 0;
const util_1 = require("@bunt/util");
const async_1 = require("@bunt/async");
const index_js_1 = require("../Dispose/index.js");
const internal_js_1 = require("./internal.js");
const registry = new WeakMap();
export class Heartbeat extends Disposer {
class Heartbeat extends index_js_1.Disposer {
name;
#running = new Set();
#life = new Defer();
#life = new async_1.Defer();
constructor(target) {

@@ -35,3 +38,3 @@ super();

static async watch(runnable) {
if (isRunnable(runnable)) {
if ((0, internal_js_1.isRunnable)(runnable)) {
return runnable

@@ -75,5 +78,6 @@ .getHeartbeat()

}
exports.Heartbeat = Heartbeat;
__decorate([
logger
util_1.logger
], Heartbeat.prototype, "logger", void 0);
//# sourceMappingURL=Heartbeat.js.map

@@ -1,6 +0,22 @@

export * from "./Runtime.js";
export * from "./Heartbeat.js";
export * from "./EnvReader.js";
export * from "./internal.js";
export * from "./interfaces.js";
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./Runtime.js"), exports);
__exportStar(require("./Heartbeat.js"), exports);
__exportStar(require("./EnvReader.js"), exports);
__exportStar(require("./internal.js"), exports);
__exportStar(require("./interfaces.js"), exports);
//# sourceMappingURL=index.js.map

@@ -1,2 +0,3 @@

export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=interfaces.js.map

@@ -1,16 +0,22 @@

import { isObject } from "@bunt/is";
import { Logger } from "@bunt/util";
import { Runtime } from "./Runtime.js";
export const Signals = ["SIGINT", "SIGQUIT", "SIGTERM"];
export function isDisposable(target) {
return isObject(target) && "dispose" in target;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SystemLogger = exports.main = exports.isRunnable = exports.isDisposable = exports.Signals = void 0;
const is_1 = require("@bunt/is");
const util_1 = require("@bunt/util");
const Runtime_js_1 = require("./Runtime.js");
exports.Signals = ["SIGINT", "SIGQUIT", "SIGTERM"];
function isDisposable(target) {
return (0, is_1.isObject)(target) && "dispose" in target;
}
export function isRunnable(target) {
return isObject(target) && "getHeartbeat" in target;
exports.isDisposable = isDisposable;
function isRunnable(target) {
return (0, is_1.isObject)(target) && "getHeartbeat" in target;
}
export function main(...tasks) {
Runtime.run(tasks)
exports.isRunnable = isRunnable;
function main(...tasks) {
Runtime_js_1.Runtime.run(tasks)
.watch();
}
export const SystemLogger = new Logger("System");
exports.main = main;
exports.SystemLogger = new util_1.Logger("System");
//# sourceMappingURL=internal.js.map

@@ -0,1 +1,2 @@

"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

@@ -7,11 +8,13 @@ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;

};
import { logger, Logger, SingleRef } from "@bunt/util";
import { toError } from "@bunt/assert";
import { isNull, isUndefined } from "@bunt/is";
import { Disposer, dispose } from "../Dispose/index.js";
import { isDisposable, isRunnable, Signals } from "./internal.js";
const ref = new SingleRef();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Runtime = void 0;
const util_1 = require("@bunt/util");
const assert_1 = require("@bunt/assert");
const is_1 = require("@bunt/is");
const index_js_1 = require("../Dispose/index.js");
const internal_js_1 = require("./internal.js");
const ref = new util_1.SingleRef();
const DEBUG = !!process.env.DEBUG;
const ENV = process.env.NODE_ENV || "production";
export class Runtime extends Disposer {
class Runtime extends index_js_1.Disposer {
#running = [];

@@ -24,3 +27,3 @@ #pending = [];

this.logger.info("run", { ENV, DEBUG, date: this.created });
for (const signal of Signals) {
for (const signal of internal_js_1.Signals) {
this.logger.debug("watch", signal);

@@ -64,4 +67,4 @@ process.on(signal, async () => Runtime.kill(0, `Signal ${signal} has been received`));

await Promise.allSettled(this.#running.map((heartbeat) => heartbeat.dispose()));
await dispose(this);
await dispose(Logger);
await (0, index_js_1.dispose)(this);
await (0, index_js_1.dispose)(util_1.Logger);
if (!Runtime.isTest()) {

@@ -84,3 +87,3 @@ process.exit(code);

catch (error) {
this.logger.alert(toError(error).message, error);
this.logger.alert((0, assert_1.toError)(error).message, error);
await this.kill(1, "Some tasks were rejected");

@@ -92,6 +95,6 @@ }

const object = await task();
if (isUndefined(object) || isNull(object)) {
if ((0, is_1.isUndefined)(object) || (0, is_1.isNull)(object)) {
return;
}
if (isRunnable(object)) {
if ((0, internal_js_1.isRunnable)(object)) {
const heartbeat = object.getHeartbeat();

@@ -101,3 +104,3 @@ this.onDispose(heartbeat);

}
if (isDisposable(object)) {
if ((0, internal_js_1.isDisposable)(object)) {
this.onDispose(object);

@@ -107,5 +110,6 @@ }

}
exports.Runtime = Runtime;
__decorate([
logger
util_1.logger
], Runtime.prototype, "logger", void 0);
//# sourceMappingURL=Runtime.js.map

@@ -1,5 +0,8 @@

import { assert } from "@bunt/assert";
import { isArray, isDefined } from "@bunt/is";
import { XMap } from "@bunt/util";
export class DSN {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DSN = void 0;
const assert_1 = require("@bunt/assert");
const is_1 = require("@bunt/is");
const util_1 = require("@bunt/util");
class DSN {
#dsn;

@@ -48,3 +51,3 @@ #connection;

return parts
.filter((sub) => sub.every(isDefined))
.filter((sub) => sub.every(is_1.isDefined))
.map((sub) => sub.join(""))

@@ -66,5 +69,5 @@ .join("");

const result = dsn.match(re);
assert(result, "DSN string is invalid", dsn);
(0, assert_1.assert)(result, "DSN string is invalid", dsn);
const { groups = {} } = result;
assert(groups.host, "DSN host should contain host string");
(0, assert_1.assert)(groups.host, "DSN host should contain host string");
const options = this.parseOptions(groups.query);

@@ -83,4 +86,4 @@ return new DSN(dsn, {

const parsed = +port;
assert(!isNaN(parsed), "DSN has an incorrect port value");
assert(parsed >= 0 && parsed <= 65535, "DSN port should be in the valid port range (0-65535)");
(0, assert_1.assert)(!isNaN(parsed), "DSN has an incorrect port value");
(0, assert_1.assert)(parsed >= 0 && parsed <= 65535, "DSN port should be in the valid port range (0-65535)");
return parsed;

@@ -92,3 +95,3 @@ }

const params = new URLSearchParams(query);
const entries = new XMap();
const entries = new util_1.XMap();
const initializer = () => [];

@@ -110,3 +113,3 @@ for (const [key, value] of params) {

for (const [key, value] of entries) {
query.push(isArray(value)
query.push((0, is_1.isArray)(value)
? value.map((v) => [`${key}[]`, v].join("=")).join("&")

@@ -122,2 +125,3 @@ : [key, value].join("="));

}
exports.DSN = DSN;
//# sourceMappingURL=DSN.js.map

@@ -1,12 +0,17 @@

import { isInstanceOf, isObject } from "@bunt/is";
import { Service } from "./Service.js";
export function isService(maybe) {
if (!isObject(maybe)) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.resolve = exports.isService = void 0;
const is_1 = require("@bunt/is");
const Service_js_1 = require("./Service.js");
function isService(maybe) {
if (!(0, is_1.isObject)(maybe)) {
return false;
}
return isInstanceOf(maybe, Service);
return (0, is_1.isInstanceOf)(maybe, Service_js_1.Service);
}
export const resolve = (p, k) => {
Service.resolve()(p, k);
exports.isService = isService;
const resolve = (p, k) => {
Service_js_1.Service.resolve()(p, k);
};
exports.resolve = resolve;
//# sourceMappingURL=fn.js.map

@@ -1,5 +0,21 @@

export * from "./DSN.js";
export * from "./Service.js";
export * from "./ServiceFactory.js";
export * from "./fn.js";
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./DSN.js"), exports);
__exportStar(require("./Service.js"), exports);
__exportStar(require("./ServiceFactory.js"), exports);
__exportStar(require("./fn.js"), exports);
//# sourceMappingURL=index.js.map

@@ -1,7 +0,10 @@

import { ServiceRef } from "./ServiceRef.js";
export class Service {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Service = void 0;
const ServiceRef_js_1 = require("./ServiceRef.js");
class Service {
static getReferences(target, base = null) {
const references = [];
for (const proto of this.getPrototypes(target, base)) {
references.push(...ServiceRef.get(proto));
references.push(...ServiceRef_js_1.ServiceRef.get(proto));
}

@@ -12,3 +15,3 @@ return references;

const fn = (target, key) => {
ServiceRef.set(target, key);
ServiceRef_js_1.ServiceRef.set(target, key);
};

@@ -26,2 +29,3 @@ return fn;

}
exports.Service = Service;
//# sourceMappingURL=Service.js.map

@@ -1,4 +0,7 @@

import { isFunction } from "@bunt/is";
import { Service } from "./Service.js";
export class ServiceFactory extends Service {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ServiceFactory = void 0;
const is_1 = require("@bunt/is");
const Service_js_1 = require("./Service.js");
class ServiceFactory extends Service_js_1.Service {
resolver;

@@ -13,3 +16,3 @@ constructor(resolver) {

async resolve() {
if (isFunction(this.resolver)) {
if ((0, is_1.isFunction)(this.resolver)) {
return this.resolver();

@@ -20,2 +23,3 @@ }

}
exports.ServiceFactory = ServiceFactory;
//# sourceMappingURL=ServiceFactory.js.map

@@ -0,4 +1,7 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ServiceRef = void 0;
// eslint-disable-next-line @typescript-eslint/ban-types
const refs = new WeakMap();
export class ServiceRef {
class ServiceRef {
target;

@@ -32,2 +35,3 @@ properties = new Set();

}
exports.ServiceRef = ServiceRef;
//# sourceMappingURL=ServiceRef.js.map

@@ -0,1 +1,2 @@

"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {

@@ -7,9 +8,11 @@ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;

};
import { isFunction, isInstanceOf } from "@bunt/is";
import { asyncCall } from "@bunt/async";
import { logger } from "@bunt/util";
import { assert } from "@bunt/assert";
import { Context } from "./Context/index.js";
import { Action } from "./Action.js";
export class Unit {
Object.defineProperty(exports, "__esModule", { value: true });
exports.Unit = void 0;
const is_1 = require("@bunt/is");
const async_1 = require("@bunt/async");
const util_1 = require("@bunt/util");
const assert_1 = require("@bunt/assert");
const index_js_1 = require("./Context/index.js");
const Action_js_1 = require("./Action.js");
class Unit {
#context;

@@ -37,11 +40,11 @@ #handlers = {};

static isActionFactory(action) {
return !Action.isPrototypeOf(action);
return !Action_js_1.Action.isPrototypeOf(action);
}
static async getContext(context) {
if (isFunction(context)) {
if ((0, is_1.isFunction)(context)) {
return this.getContext(context());
}
const syncContext = await context;
assert(isInstanceOf(syncContext, Context), "Wrong context type");
return Context.apply(syncContext);
(0, assert_1.assert)((0, is_1.isInstanceOf)(syncContext, index_js_1.Context), "Wrong context type");
return index_js_1.Context.apply(syncContext);
}

@@ -54,3 +57,3 @@ on(handlers) {

const ctor = await Unit.getAction(factory);
assert(Action.isPrototypeOf(ctor), "The 'ctor' hasn't prototype of the Action class");
(0, assert_1.assert)(Action_js_1.Action.isPrototypeOf(ctor), "The 'ctor' hasn't prototype of the Action class");
return ctor;

@@ -61,3 +64,3 @@ });

const wrapper = this.getTransactionWrapper(start?.(ctor.name, this.context));
return asyncCall(() => new ctor(this.#context, state).run())
return (0, async_1.asyncCall)(() => new ctor(this.#context, state).run())
.then(...wrapper)

@@ -95,5 +98,6 @@ .finally(perf);

}
exports.Unit = Unit;
__decorate([
logger
util_1.logger
], Unit.prototype, "logger", void 0);
//# sourceMappingURL=Unit.js.map
{
"name": "@bunt/unit",
"version": "0.29.12",
"version": "0.29.13",
"keywords": [

@@ -36,10 +36,10 @@ "typescript"

"dependencies": {
"@bunt/assert": "^0.29.0",
"@bunt/async": "^0.29.6",
"@bunt/is": "^0.29.0",
"@bunt/type": "^0.29.0",
"@bunt/util": "^0.29.0"
"@bunt/assert": "^0.29.13",
"@bunt/async": "^0.29.13",
"@bunt/is": "^0.29.13",
"@bunt/type": "^0.29.13",
"@bunt/util": "^0.29.13"
},
"license": "MIT",
"gitHead": "ef609c37de1e92e40c73feb89f0427faacb24480"
"gitHead": "8eb5e57f43cfb71c79b4b5183207b2894ec4726d"
}

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

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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc