🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@matrixai/async-init

Package Overview
Dependencies
Maintainers
3
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@matrixai/async-init - npm Package Compare versions

Comparing version

to
1.9.1

dist/events.d.ts

23

dist/CreateDestroy.d.ts

@@ -1,5 +0,6 @@

import type { Status } from './types';
import type { Status, Class } from './types';
import { Evented } from '@matrixai/events';
import { RWLockWriter } from '@matrixai/async-locks';
import { _destroyed, destroyed, _status, status, initLock } from './utils';
interface CreateDestroy<DestroyReturn = unknown> {
import { destroyed, status, initLock } from './utils';
interface CreateDestroy<DestroyReturn = unknown> extends Evented {
get [destroyed](): boolean;

@@ -10,15 +11,9 @@ get [status](): Status;

}
declare function CreateDestroy<DestroyReturn = unknown>(): <T extends new (...args: any[]) => {
declare function CreateDestroy<DestroyReturn = unknown>({ eventDestroy, eventDestroyed, }?: {
eventDestroy?: Class<Event>;
eventDestroyed?: Class<Event>;
}): <T extends new (...args: any[]) => {
destroy?(...args: Array<any>): Promise<DestroyReturn | void>;
}>(constructor: T) => {
new (...args: any[]): {
destroy(...args: Array<any>): Promise<DestroyReturn | void>;
[_destroyed]: boolean;
[_status]: Status;
readonly [initLock]: RWLockWriter;
readonly [destroyed]: boolean;
readonly [status]: Status;
};
} & T;
}>(constructor: T) => (new (...args: Array<any>) => CreateDestroy<DestroyReturn>) & T;
declare function ready(errorDestroyed?: Error, block?: boolean, allowedStatuses?: Array<Status>): (target: any, key: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
export { CreateDestroy, ready, destroyed, status, initLock };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.initLock = exports.status = exports.destroyed = exports.ready = exports.CreateDestroy = void 0;
const events_1 = require("@matrixai/events");
const async_locks_1 = require("@matrixai/async-locks");

@@ -9,6 +10,7 @@ const utils_1 = require("./utils");

Object.defineProperty(exports, "initLock", { enumerable: true, get: function () { return utils_1.initLock; } });
const events_2 = require("./events");
const errors_1 = require("./errors");
function CreateDestroy() {
function CreateDestroy({ eventDestroy = events_2.EventAsyncInitDestroy, eventDestroyed = events_2.EventAsyncInitDestroyed, } = {}) {
return (constructor) => {
const constructor_ = class extends constructor {
const constructor_ = class extends (0, events_1.Evented)()(constructor) {
[utils_1._destroyed] = false;

@@ -30,2 +32,3 @@ [utils_1._status] = null;

}
this.dispatchEvent(new eventDestroy());
let result;

@@ -36,2 +39,3 @@ if (typeof super['destroy'] === 'function') {

this[utils_1._destroyed] = true;
this.dispatchEvent(new eventDestroyed());
return result;

@@ -38,0 +42,0 @@ }

@@ -1,5 +0,6 @@

import type { Status } from './types';
import type { Status, Class } from './types';
import { Evented } from '@matrixai/events';
import { RWLockWriter } from '@matrixai/async-locks';
import { _running, running, _destroyed, destroyed, _status, status, initLock } from './utils';
interface CreateDestroyStartStop<StartReturn = unknown, StopReturn = unknown, DestroyReturn = unknown> {
import { running, destroyed, status, initLock } from './utils';
interface CreateDestroyStartStop<StartReturn = unknown, StopReturn = unknown, DestroyReturn = unknown> extends Evented {
get [running](): boolean;

@@ -13,21 +14,15 @@ get [destroyed](): boolean;

}
declare function CreateDestroyStartStop<StartReturn = unknown, StopReturn = unknown, DestroyReturn = unknown>(errorRunning?: Error, errorDestroyed?: Error): <T extends new (...args: any[]) => {
declare function CreateDestroyStartStop<StartReturn = unknown, StopReturn = unknown, DestroyReturn = unknown>(errorRunning?: Error, errorDestroyed?: Error, { eventStart, eventStarted, eventStop, eventStopped, eventDestroy, eventDestroyed, }?: {
eventStart?: Class<Event>;
eventStarted?: Class<Event>;
eventStop?: Class<Event>;
eventStopped?: Class<Event>;
eventDestroy?: Class<Event>;
eventDestroyed?: Class<Event>;
}): <T extends new (...args: any[]) => {
start?(...args: Array<any>): Promise<StartReturn | void>;
stop?(...args: Array<any>): Promise<StopReturn | void>;
destroy?(...args: Array<any>): Promise<DestroyReturn | void>;
}>(constructor: T) => {
new (...args: any[]): {
destroy(...args: Array<any>): Promise<DestroyReturn | void>;
start(...args: Array<any>): Promise<StartReturn | void>;
stop(...args: Array<any>): Promise<StopReturn | void>;
[_running]: boolean;
[_destroyed]: boolean;
[_status]: Status;
readonly [initLock]: RWLockWriter;
readonly [running]: boolean;
readonly [destroyed]: boolean;
readonly [status]: Status;
};
} & T;
}>(constructor: T) => (new (...args: Array<any>) => CreateDestroyStartStop<StartReturn, StopReturn, DestroyReturn>) & T;
declare function ready(errorNotRunning?: Error, block?: boolean, allowedStatuses?: Array<Status>): (target: any, key: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
export { CreateDestroyStartStop, ready, running, destroyed, status, initLock };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.initLock = exports.status = exports.destroyed = exports.running = exports.ready = exports.CreateDestroyStartStop = void 0;
const events_1 = require("@matrixai/events");
const async_locks_1 = require("@matrixai/async-locks");

@@ -10,6 +11,7 @@ const utils_1 = require("./utils");

Object.defineProperty(exports, "initLock", { enumerable: true, get: function () { return utils_1.initLock; } });
const events_2 = require("./events");
const errors_1 = require("./errors");
function CreateDestroyStartStop(errorRunning = new errors_1.ErrorAsyncInitRunning(), errorDestroyed = new errors_1.ErrorAsyncInitDestroyed()) {
function CreateDestroyStartStop(errorRunning = new errors_1.ErrorAsyncInitRunning(), errorDestroyed = new errors_1.ErrorAsyncInitDestroyed(), { eventStart = events_2.EventAsyncInitStart, eventStarted = events_2.EventAsyncInitStarted, eventStop = events_2.EventAsyncInitStop, eventStopped = events_2.EventAsyncInitStopped, eventDestroy = events_2.EventAsyncInitDestroy, eventDestroyed = events_2.EventAsyncInitDestroyed, } = {}) {
return (constructor) => {
const constructor_ = class extends constructor {
const constructor_ = class extends (0, events_1.Evented)()(constructor) {
[utils_1._running] = false;

@@ -40,2 +42,3 @@ [utils_1._destroyed] = false;

}
this.dispatchEvent(new eventDestroy());
let result;

@@ -46,2 +49,3 @@ if (typeof super['destroy'] === 'function') {

this[utils_1._destroyed] = true;
this.dispatchEvent(new eventDestroyed());
return result;

@@ -66,2 +70,3 @@ }

}
this.dispatchEvent(new eventStart());
let result;

@@ -72,2 +77,3 @@ if (typeof super['start'] === 'function') {

this[utils_1._running] = true;
this.dispatchEvent(new eventStarted());
return result;

@@ -94,2 +100,3 @@ }

}
this.dispatchEvent(new eventStop());
let result;

@@ -100,2 +107,3 @@ if (typeof super['stop'] === 'function') {

this[utils_1._running] = false;
this.dispatchEvent(new eventStopped());
return result;

@@ -102,0 +110,0 @@ }

@@ -5,3 +5,4 @@ export * as types from './types';

export * as startStop from './StartStop';
export * as events from './events';
export * as errors from './errors';
export { running, destroyed, status, initLock } from './utils';

@@ -26,3 +26,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.initLock = exports.status = exports.destroyed = exports.running = exports.errors = exports.startStop = exports.createDestroy = exports.createDestroyStartStop = exports.types = void 0;
exports.initLock = exports.status = exports.destroyed = exports.running = exports.errors = exports.events = exports.startStop = exports.createDestroy = exports.createDestroyStartStop = exports.types = void 0;
exports.types = __importStar(require("./types"));

@@ -32,2 +32,3 @@ exports.createDestroyStartStop = __importStar(require("./CreateDestroyStartStop"));

exports.startStop = __importStar(require("./StartStop"));
exports.events = __importStar(require("./events"));
exports.errors = __importStar(require("./errors"));

@@ -34,0 +35,0 @@ var utils_1 = require("./utils");

@@ -1,5 +0,6 @@

import type { Status } from './types';
import type { Status, Class } from './types';
import { Evented } from '@matrixai/events';
import { RWLockWriter } from '@matrixai/async-locks';
import { _running, running, _status, status, initLock } from './utils';
interface StartStop<StartReturn = unknown, StopReturn = unknown> {
import { running, status, initLock } from './utils';
interface StartStop<StartReturn = unknown, StopReturn = unknown> extends Evented {
get [running](): boolean;

@@ -11,17 +12,12 @@ get [status](): Status;

}
declare function StartStop<StartReturn = unknown, StopReturn = unknown>(): <T extends new (...args: any[]) => {
declare function StartStop<StartReturn = unknown, StopReturn = unknown>({ eventStart, eventStarted, eventStop, eventStopped, }?: {
eventStart?: Class<Event>;
eventStarted?: Class<Event>;
eventStop?: Class<Event>;
eventStopped?: Class<Event>;
}): <T extends new (...args: Array<any>) => {
start?(...args: Array<any>): Promise<StartReturn | void>;
stop?(...args: Array<any>): Promise<StopReturn | void>;
}>(constructor: T) => {
new (...args: any[]): {
start(...args: Array<any>): Promise<StartReturn | void>;
stop(...args: Array<any>): Promise<StopReturn | void>;
[_running]: boolean;
[_status]: Status;
readonly [initLock]: RWLockWriter;
readonly [running]: boolean;
readonly [status]: Status;
};
} & T;
}>(constructor: T) => (new (...args: Array<any>) => StartStop<StartReturn, StopReturn>) & T;
declare function ready(errorNotRunning?: Error, block?: boolean, allowedStatuses?: Array<Status>): (target: any, key: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
export { StartStop, ready, running, status, initLock };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.initLock = exports.status = exports.running = exports.ready = exports.StartStop = void 0;
const events_1 = require("@matrixai/events");
const async_locks_1 = require("@matrixai/async-locks");

@@ -9,6 +10,7 @@ const utils_1 = require("./utils");

Object.defineProperty(exports, "initLock", { enumerable: true, get: function () { return utils_1.initLock; } });
const events_2 = require("./events");
const errors_1 = require("./errors");
function StartStop() {
function StartStop({ eventStart = events_2.EventAsyncInitStart, eventStarted = events_2.EventAsyncInitStarted, eventStop = events_2.EventAsyncInitStop, eventStopped = events_2.EventAsyncInitStopped, } = {}) {
return (constructor) => {
const constructor_ = class extends constructor {
const constructor_ = class extends (0, events_1.Evented)()(constructor) {
[utils_1._running] = false;

@@ -30,2 +32,3 @@ [utils_1._status] = null;

}
this.dispatchEvent(new eventStart());
let result;

@@ -36,2 +39,3 @@ if (typeof super['start'] === 'function') {

this[utils_1._running] = true;
this.dispatchEvent(new eventStarted());
return result;

@@ -51,2 +55,3 @@ }

}
this.dispatchEvent(new eventStop());
let result;

@@ -57,2 +62,3 @@ if (typeof super['stop'] === 'function') {

this[utils_1._running] = false;
this.dispatchEvent(new eventStopped());
return result;

@@ -59,0 +65,0 @@ }

type Status = 'destroying' | 'starting' | 'stopping' | null;
export type { Status };
type Class<T> = new (...args: any[]) => T;
export type { Status, Class };
{
"name": "@matrixai/async-init",
"version": "1.8.4",
"version": "1.9.1",
"author": "Roger Qiu",

@@ -26,3 +26,4 @@ "description": "Asynchronous Initialisation and Deinitialisation Decorators",

"@matrixai/async-locks": "^4.0.0",
"@matrixai/errors": "^1.1.7"
"@matrixai/errors": "^1.2.0",
"@matrixai/events": "^3.0.2"
},

@@ -29,0 +30,0 @@ "devDependencies": {

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