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

@matrixai/async-init

Package Overview
Dependencies
Maintainers
3
Versions
25
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 1.8.4 to 2.0.0

jest.config.mjs

4

dist/CreateDestroy.d.ts

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

import type { Status } from './types';
import type { Status } from './types.js';
import { RWLockWriter } from '@matrixai/async-locks';
import { _destroyed, destroyed, _status, status, initLock } from './utils';
import { _destroyed, destroyed, _status, status, initLock } from './utils.js';
interface CreateDestroy<DestroyReturn = unknown> {

@@ -5,0 +5,0 @@ get [destroyed](): boolean;

@@ -1,27 +0,21 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.initLock = exports.status = exports.destroyed = exports.ready = exports.CreateDestroy = void 0;
const async_locks_1 = require("@matrixai/async-locks");
const utils_1 = require("./utils");
Object.defineProperty(exports, "destroyed", { enumerable: true, get: function () { return utils_1.destroyed; } });
Object.defineProperty(exports, "status", { enumerable: true, get: function () { return utils_1.status; } });
Object.defineProperty(exports, "initLock", { enumerable: true, get: function () { return utils_1.initLock; } });
const errors_1 = require("./errors");
import { RWLockWriter } from '@matrixai/async-locks';
import { _destroyed, destroyed, _status, status, initLock, AsyncFunction, GeneratorFunction, AsyncGeneratorFunction, resetStackTrace, } from './utils.js';
import { ErrorAsyncInitDestroyed } from './errors.js';
function CreateDestroy() {
return (constructor) => {
const constructor_ = class extends constructor {
[utils_1._destroyed] = false;
[utils_1._status] = null;
[utils_1.initLock] = new async_locks_1.RWLockWriter();
get [utils_1.destroyed]() {
return this[utils_1._destroyed];
[_destroyed] = false;
[_status] = null;
[initLock] = new RWLockWriter();
get [destroyed]() {
return this[_destroyed];
}
get [utils_1.status]() {
return this[utils_1._status];
get [status]() {
return this[_status];
}
async destroy(...args) {
return this[utils_1.initLock].withWriteF(async () => {
this[utils_1._status] = 'destroying';
return this[initLock].withWriteF(async () => {
this[_status] = 'destroying';
try {
if (this[utils_1._destroyed]) {
if (this[_destroyed]) {
return;

@@ -33,7 +27,7 @@ }

}
this[utils_1._destroyed] = true;
this[_destroyed] = true;
return result;
}
finally {
this[utils_1._status] = null;
this[_status] = null;
}

@@ -48,4 +42,3 @@ });

}
exports.CreateDestroy = CreateDestroy;
function ready(errorDestroyed = new errors_1.ErrorAsyncInitDestroyed(), block = false, allowedStatuses = []) {
function ready(errorDestroyed = new ErrorAsyncInitDestroyed(), block = false, allowedStatuses = []) {
return (target, key, descriptor) => {

@@ -66,11 +59,11 @@ let kind;

}
if (f instanceof utils_1.AsyncFunction) {
if (f instanceof AsyncFunction) {
descriptor[kind] = async function (...args) {
if (allowedStatuses.includes(this[utils_1._status])) {
if (allowedStatuses.includes(this[_status])) {
return f.apply(this, args);
}
if (block) {
return this[utils_1.initLock].withReadF(async () => {
if (this[utils_1._destroyed]) {
(0, utils_1.resetStackTrace)(errorDestroyed, descriptor[kind]);
return this[initLock].withReadF(async () => {
if (this[_destroyed]) {
resetStackTrace(errorDestroyed, descriptor[kind]);
throw errorDestroyed;

@@ -82,4 +75,4 @@ }

else {
if (this[utils_1.initLock].isLocked('write') || this[utils_1._destroyed]) {
(0, utils_1.resetStackTrace)(errorDestroyed, descriptor[kind]);
if (this[initLock].isLocked('write') || this[_destroyed]) {
resetStackTrace(errorDestroyed, descriptor[kind]);
throw errorDestroyed;

@@ -91,9 +84,9 @@ }

}
else if (f instanceof utils_1.GeneratorFunction) {
else if (f instanceof GeneratorFunction) {
descriptor[kind] = function* (...args) {
if (allowedStatuses.includes(this[utils_1._status])) {
if (allowedStatuses.includes(this[_status])) {
return yield* f.apply(this, args);
}
if (this[utils_1.initLock].isLocked('write') || this[utils_1._destroyed]) {
(0, utils_1.resetStackTrace)(errorDestroyed, descriptor[kind]);
if (this[initLock].isLocked('write') || this[_destroyed]) {
resetStackTrace(errorDestroyed, descriptor[kind]);
throw errorDestroyed;

@@ -104,11 +97,11 @@ }

}
else if (f instanceof utils_1.AsyncGeneratorFunction) {
else if (f instanceof AsyncGeneratorFunction) {
descriptor[kind] = async function* (...args) {
if (allowedStatuses.includes(this[utils_1._status])) {
if (allowedStatuses.includes(this[_status])) {
return yield* f.apply(this, args);
}
if (block) {
return yield* this[utils_1.initLock].withReadG(() => {
if (this[utils_1._destroyed]) {
(0, utils_1.resetStackTrace)(errorDestroyed, descriptor[kind]);
return yield* this[initLock].withReadG(() => {
if (this[_destroyed]) {
resetStackTrace(errorDestroyed, descriptor[kind]);
throw errorDestroyed;

@@ -120,4 +113,4 @@ }

else {
if (this[utils_1.initLock].isLocked('write') || this[utils_1._destroyed]) {
(0, utils_1.resetStackTrace)(errorDestroyed, descriptor[kind]);
if (this[initLock].isLocked('write') || this[_destroyed]) {
resetStackTrace(errorDestroyed, descriptor[kind]);
throw errorDestroyed;

@@ -131,7 +124,7 @@ }

descriptor[kind] = function (...args) {
if (allowedStatuses.includes(this[utils_1._status])) {
if (allowedStatuses.includes(this[_status])) {
return f.apply(this, args);
}
if (this[utils_1.initLock].isLocked('write') || this[utils_1._destroyed]) {
(0, utils_1.resetStackTrace)(errorDestroyed, descriptor[kind]);
if (this[initLock].isLocked('write') || this[_destroyed]) {
resetStackTrace(errorDestroyed, descriptor[kind]);
throw errorDestroyed;

@@ -147,3 +140,3 @@ }

}
exports.ready = ready;
export { CreateDestroy, ready, destroyed, status, initLock };
//# sourceMappingURL=CreateDestroy.js.map

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

import type { Status } from './types';
import type { Status } from './types.js';
import { RWLockWriter } from '@matrixai/async-locks';
import { _running, running, _destroyed, destroyed, _status, status, initLock } from './utils';
import { _running, running, _destroyed, destroyed, _status, status, initLock } from './utils.js';
interface CreateDestroyStartStop<StartReturn = unknown, StopReturn = unknown, DestroyReturn = unknown> {

@@ -5,0 +5,0 @@ get [running](): boolean;

@@ -1,37 +0,30 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.initLock = exports.status = exports.destroyed = exports.running = exports.ready = exports.CreateDestroyStartStop = void 0;
const async_locks_1 = require("@matrixai/async-locks");
const utils_1 = require("./utils");
Object.defineProperty(exports, "running", { enumerable: true, get: function () { return utils_1.running; } });
Object.defineProperty(exports, "destroyed", { enumerable: true, get: function () { return utils_1.destroyed; } });
Object.defineProperty(exports, "status", { enumerable: true, get: function () { return utils_1.status; } });
Object.defineProperty(exports, "initLock", { enumerable: true, get: function () { return utils_1.initLock; } });
const errors_1 = require("./errors");
function CreateDestroyStartStop(errorRunning = new errors_1.ErrorAsyncInitRunning(), errorDestroyed = new errors_1.ErrorAsyncInitDestroyed()) {
import { RWLockWriter } from '@matrixai/async-locks';
import { _running, running, _destroyed, destroyed, _status, status, initLock, AsyncFunction, GeneratorFunction, AsyncGeneratorFunction, resetStackTrace, } from './utils.js';
import { ErrorAsyncInitRunning, ErrorAsyncInitNotRunning, ErrorAsyncInitDestroyed, } from './errors.js';
function CreateDestroyStartStop(errorRunning = new ErrorAsyncInitRunning(), errorDestroyed = new ErrorAsyncInitDestroyed()) {
return (constructor) => {
const constructor_ = class extends constructor {
[utils_1._running] = false;
[utils_1._destroyed] = false;
[utils_1._status] = null;
[utils_1.initLock] = new async_locks_1.RWLockWriter();
get [utils_1.running]() {
return this[utils_1._running];
[_running] = false;
[_destroyed] = false;
[_status] = null;
[initLock] = new RWLockWriter();
get [running]() {
return this[_running];
}
get [utils_1.destroyed]() {
return this[utils_1._destroyed];
get [destroyed]() {
return this[_destroyed];
}
get [utils_1.status]() {
return this[utils_1._status];
get [status]() {
return this[_status];
}
async destroy(...args) {
return this[utils_1.initLock].withWriteF(async () => {
this[utils_1._status] = 'destroying';
return this[initLock].withWriteF(async () => {
this[_status] = 'destroying';
try {
if (this[utils_1._destroyed]) {
if (this[_destroyed]) {
return;
}
if (this[utils_1._running]) {
if (this[_running]) {
// Unfortunately `this.destroy` doesn't work as the decorated function
(0, utils_1.resetStackTrace)(errorRunning);
resetStackTrace(errorRunning);
throw errorRunning;

@@ -43,7 +36,7 @@ }

}
this[utils_1._destroyed] = true;
this[_destroyed] = true;
return result;
}
finally {
this[utils_1._status] = null;
this[_status] = null;
}

@@ -53,11 +46,11 @@ });

async start(...args) {
return this[utils_1.initLock].withWriteF(async () => {
this[utils_1._status] = 'starting';
return this[initLock].withWriteF(async () => {
this[_status] = 'starting';
try {
if (this[utils_1._running]) {
if (this[_running]) {
return;
}
if (this[utils_1._destroyed]) {
if (this[_destroyed]) {
// Unfortunately `this.start` doesn't work as the decorated function
(0, utils_1.resetStackTrace)(errorDestroyed);
resetStackTrace(errorDestroyed);
throw errorDestroyed;

@@ -69,7 +62,7 @@ }

}
this[utils_1._running] = true;
this[_running] = true;
return result;
}
finally {
this[utils_1._status] = null;
this[_status] = null;
}

@@ -79,13 +72,13 @@ });

async stop(...args) {
return this[utils_1.initLock].withWriteF(async () => {
this[utils_1._status] = 'stopping';
return this[initLock].withWriteF(async () => {
this[_status] = 'stopping';
try {
if (!this[utils_1._running]) {
if (!this[_running]) {
return;
}
if (this[utils_1._destroyed]) {
if (this[_destroyed]) {
// It is not possible to be running and destroyed
// however this line is here for completion
// Unfortunately `this.stop` doesn't work as the decorated function
(0, utils_1.resetStackTrace)(errorDestroyed);
resetStackTrace(errorDestroyed);
throw errorDestroyed;

@@ -97,7 +90,7 @@ }

}
this[utils_1._running] = false;
this[_running] = false;
return result;
}
finally {
this[utils_1._status] = null;
this[_status] = null;
}

@@ -112,4 +105,3 @@ });

}
exports.CreateDestroyStartStop = CreateDestroyStartStop;
function ready(errorNotRunning = new errors_1.ErrorAsyncInitNotRunning(), block = false, allowedStatuses = []) {
function ready(errorNotRunning = new ErrorAsyncInitNotRunning(), block = false, allowedStatuses = []) {
return (target, key, descriptor) => {

@@ -130,11 +122,11 @@ let kind;

}
if (f instanceof utils_1.AsyncFunction) {
if (f instanceof AsyncFunction) {
descriptor[kind] = async function (...args) {
if (allowedStatuses.includes(this[utils_1._status])) {
if (allowedStatuses.includes(this[_status])) {
return f.apply(this, args);
}
if (block) {
return this[utils_1.initLock].withReadF(async () => {
if (!this[utils_1._running]) {
(0, utils_1.resetStackTrace)(errorNotRunning, descriptor[kind]);
return this[initLock].withReadF(async () => {
if (!this[_running]) {
resetStackTrace(errorNotRunning, descriptor[kind]);
throw errorNotRunning;

@@ -146,4 +138,4 @@ }

else {
if (this[utils_1.initLock].isLocked('write') || !this[utils_1._running]) {
(0, utils_1.resetStackTrace)(errorNotRunning, descriptor[kind]);
if (this[initLock].isLocked('write') || !this[_running]) {
resetStackTrace(errorNotRunning, descriptor[kind]);
throw errorNotRunning;

@@ -155,9 +147,9 @@ }

}
else if (f instanceof utils_1.GeneratorFunction) {
else if (f instanceof GeneratorFunction) {
descriptor[kind] = function* (...args) {
if (allowedStatuses.includes(this[utils_1._status])) {
if (allowedStatuses.includes(this[_status])) {
return yield* f.apply(this, args);
}
if (this[utils_1.initLock].isLocked('write') || !this[utils_1._running]) {
(0, utils_1.resetStackTrace)(errorNotRunning, descriptor[kind]);
if (this[initLock].isLocked('write') || !this[_running]) {
resetStackTrace(errorNotRunning, descriptor[kind]);
throw errorNotRunning;

@@ -168,11 +160,11 @@ }

}
else if (f instanceof utils_1.AsyncGeneratorFunction) {
else if (f instanceof AsyncGeneratorFunction) {
descriptor[kind] = async function* (...args) {
if (allowedStatuses.includes(this[utils_1._status])) {
if (allowedStatuses.includes(this[_status])) {
return yield* f.apply(this, args);
}
if (block) {
return yield* this[utils_1.initLock].withReadG(() => {
if (!this[utils_1._running]) {
(0, utils_1.resetStackTrace)(errorNotRunning, descriptor[kind]);
return yield* this[initLock].withReadG(() => {
if (!this[_running]) {
resetStackTrace(errorNotRunning, descriptor[kind]);
throw errorNotRunning;

@@ -184,4 +176,4 @@ }

else {
if (this[utils_1.initLock].isLocked('write') || !this[utils_1._running]) {
(0, utils_1.resetStackTrace)(errorNotRunning, descriptor[kind]);
if (this[initLock].isLocked('write') || !this[_running]) {
resetStackTrace(errorNotRunning, descriptor[kind]);
throw errorNotRunning;

@@ -195,7 +187,7 @@ }

descriptor[kind] = function (...args) {
if (allowedStatuses.includes(this[utils_1._status])) {
if (allowedStatuses.includes(this[_status])) {
return f.apply(this, args);
}
if (this[utils_1.initLock].isLocked('write') || !this[utils_1._running]) {
(0, utils_1.resetStackTrace)(errorNotRunning, descriptor[kind]);
if (this[initLock].isLocked('write') || !this[_running]) {
resetStackTrace(errorNotRunning, descriptor[kind]);
throw errorNotRunning;

@@ -211,3 +203,3 @@ }

}
exports.ready = ready;
export { CreateDestroyStartStop, ready, running, destroyed, status, initLock };
//# sourceMappingURL=CreateDestroyStartStop.js.map

@@ -1,21 +0,15 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ErrorAsyncInitDestroyed = exports.ErrorAsyncInitNotRunning = exports.ErrorAsyncInitRunning = exports.ErrorAsyncInit = void 0;
const errors_1 = require("@matrixai/errors");
class ErrorAsyncInit extends errors_1.AbstractError {
import { AbstractError } from '@matrixai/errors';
class ErrorAsyncInit extends AbstractError {
static description = 'Async init error';
}
exports.ErrorAsyncInit = ErrorAsyncInit;
class ErrorAsyncInitRunning extends ErrorAsyncInit {
static description = 'Async init is running';
}
exports.ErrorAsyncInitRunning = ErrorAsyncInitRunning;
class ErrorAsyncInitNotRunning extends ErrorAsyncInit {
static description = 'Async init is not running';
}
exports.ErrorAsyncInitNotRunning = ErrorAsyncInitNotRunning;
class ErrorAsyncInitDestroyed extends ErrorAsyncInit {
static description = 'Async init is destroyed';
}
exports.ErrorAsyncInitDestroyed = ErrorAsyncInitDestroyed;
export { ErrorAsyncInit, ErrorAsyncInitRunning, ErrorAsyncInitNotRunning, ErrorAsyncInitDestroyed, };
//# sourceMappingURL=errors.js.map

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

export * as types from './types';
export * as createDestroyStartStop from './CreateDestroyStartStop';
export * as createDestroy from './CreateDestroy';
export * as startStop from './StartStop';
export * as errors from './errors';
export { running, destroyed, status, initLock } from './utils';
export * as types from './types.js';
export * as createDestroyStartStop from './CreateDestroyStartStop.js';
export * as createDestroy from './CreateDestroy.js';
export * as startStop from './StartStop.js';
export * as errors from './errors.js';
export { running, destroyed, status, initLock } from './utils.js';

@@ -1,37 +0,7 @@

"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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
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.types = __importStar(require("./types"));
exports.createDestroyStartStop = __importStar(require("./CreateDestroyStartStop"));
exports.createDestroy = __importStar(require("./CreateDestroy"));
exports.startStop = __importStar(require("./StartStop"));
exports.errors = __importStar(require("./errors"));
var utils_1 = require("./utils");
Object.defineProperty(exports, "running", { enumerable: true, get: function () { return utils_1.running; } });
Object.defineProperty(exports, "destroyed", { enumerable: true, get: function () { return utils_1.destroyed; } });
Object.defineProperty(exports, "status", { enumerable: true, get: function () { return utils_1.status; } });
Object.defineProperty(exports, "initLock", { enumerable: true, get: function () { return utils_1.initLock; } });
export * as types from './types.js';
export * as createDestroyStartStop from './CreateDestroyStartStop.js';
export * as createDestroy from './CreateDestroy.js';
export * as startStop from './StartStop.js';
export * as errors from './errors.js';
export { running, destroyed, status, initLock } from './utils.js';
//# sourceMappingURL=index.js.map

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

import type { Status } from './types';
import type { Status } from './types.js';
import { RWLockWriter } from '@matrixai/async-locks';
import { _running, running, _status, status, initLock } from './utils';
import { _running, running, _status, status, initLock } from './utils.js';
interface StartStop<StartReturn = unknown, StopReturn = unknown> {

@@ -5,0 +5,0 @@ get [running](): boolean;

@@ -1,27 +0,21 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.initLock = exports.status = exports.running = exports.ready = exports.StartStop = void 0;
const async_locks_1 = require("@matrixai/async-locks");
const utils_1 = require("./utils");
Object.defineProperty(exports, "running", { enumerable: true, get: function () { return utils_1.running; } });
Object.defineProperty(exports, "status", { enumerable: true, get: function () { return utils_1.status; } });
Object.defineProperty(exports, "initLock", { enumerable: true, get: function () { return utils_1.initLock; } });
const errors_1 = require("./errors");
import { RWLockWriter } from '@matrixai/async-locks';
import { _running, running, _status, status, initLock, AsyncFunction, GeneratorFunction, AsyncGeneratorFunction, resetStackTrace, } from './utils.js';
import { ErrorAsyncInitNotRunning } from './errors.js';
function StartStop() {
return (constructor) => {
const constructor_ = class extends constructor {
[utils_1._running] = false;
[utils_1._status] = null;
[utils_1.initLock] = new async_locks_1.RWLockWriter();
get [utils_1.running]() {
return this[utils_1._running];
[_running] = false;
[_status] = null;
[initLock] = new RWLockWriter();
get [running]() {
return this[_running];
}
get [utils_1.status]() {
return this[utils_1._status];
get [status]() {
return this[_status];
}
async start(...args) {
return this[utils_1.initLock].withWriteF(async () => {
this[utils_1._status] = 'starting';
return this[initLock].withWriteF(async () => {
this[_status] = 'starting';
try {
if (this[utils_1._running]) {
if (this[_running]) {
return;

@@ -33,7 +27,7 @@ }

}
this[utils_1._running] = true;
this[_running] = true;
return result;
}
finally {
this[utils_1._status] = null;
this[_status] = null;
}

@@ -43,6 +37,6 @@ });

async stop(...args) {
return this[utils_1.initLock].withWriteF(async () => {
this[utils_1._status] = 'stopping';
return this[initLock].withWriteF(async () => {
this[_status] = 'stopping';
try {
if (!this[utils_1._running]) {
if (!this[_running]) {
return;

@@ -54,7 +48,7 @@ }

}
this[utils_1._running] = false;
this[_running] = false;
return result;
}
finally {
this[utils_1._status] = null;
this[_status] = null;
}

@@ -69,4 +63,3 @@ });

}
exports.StartStop = StartStop;
function ready(errorNotRunning = new errors_1.ErrorAsyncInitNotRunning(), block = false, allowedStatuses = []) {
function ready(errorNotRunning = new ErrorAsyncInitNotRunning(), block = false, allowedStatuses = []) {
return (target, key, descriptor) => {

@@ -87,11 +80,11 @@ let kind;

}
if (f instanceof utils_1.AsyncFunction) {
if (f instanceof AsyncFunction) {
descriptor[kind] = async function (...args) {
if (allowedStatuses.includes(this[utils_1._status])) {
if (allowedStatuses.includes(this[_status])) {
return f.apply(this, args);
}
if (block) {
return this[utils_1.initLock].withReadF(async () => {
if (!this[utils_1._running]) {
(0, utils_1.resetStackTrace)(errorNotRunning, descriptor[kind]);
return this[initLock].withReadF(async () => {
if (!this[_running]) {
resetStackTrace(errorNotRunning, descriptor[kind]);
throw errorNotRunning;

@@ -103,4 +96,4 @@ }

else {
if (this[utils_1.initLock].isLocked('write') || !this[utils_1._running]) {
(0, utils_1.resetStackTrace)(errorNotRunning, descriptor[kind]);
if (this[initLock].isLocked('write') || !this[_running]) {
resetStackTrace(errorNotRunning, descriptor[kind]);
throw errorNotRunning;

@@ -112,9 +105,9 @@ }

}
else if (f instanceof utils_1.GeneratorFunction) {
else if (f instanceof GeneratorFunction) {
descriptor[kind] = function* (...args) {
if (allowedStatuses.includes(this[utils_1._status])) {
if (allowedStatuses.includes(this[_status])) {
return yield* f.apply(this, args);
}
if (this[utils_1.initLock].isLocked('write') || !this[utils_1._running]) {
(0, utils_1.resetStackTrace)(errorNotRunning, descriptor[kind]);
if (this[initLock].isLocked('write') || !this[_running]) {
resetStackTrace(errorNotRunning, descriptor[kind]);
throw errorNotRunning;

@@ -125,11 +118,11 @@ }

}
else if (f instanceof utils_1.AsyncGeneratorFunction) {
else if (f instanceof AsyncGeneratorFunction) {
descriptor[kind] = async function* (...args) {
if (allowedStatuses.includes(this[utils_1._status])) {
if (allowedStatuses.includes(this[_status])) {
return yield* f.apply(this, args);
}
if (block) {
return yield* this[utils_1.initLock].withReadG(() => {
if (!this[utils_1._running]) {
(0, utils_1.resetStackTrace)(errorNotRunning, descriptor[kind]);
return yield* this[initLock].withReadG(() => {
if (!this[_running]) {
resetStackTrace(errorNotRunning, descriptor[kind]);
throw errorNotRunning;

@@ -141,4 +134,4 @@ }

else {
if (this[utils_1.initLock].isLocked('write') || !this[utils_1._running]) {
(0, utils_1.resetStackTrace)(errorNotRunning, descriptor[kind]);
if (this[initLock].isLocked('write') || !this[_running]) {
resetStackTrace(errorNotRunning, descriptor[kind]);
throw errorNotRunning;

@@ -152,7 +145,7 @@ }

descriptor[kind] = function (...args) {
if (allowedStatuses.includes(this[utils_1._status])) {
if (allowedStatuses.includes(this[_status])) {
return f.apply(this, args);
}
if (this[utils_1.initLock].isLocked('write') || !this[utils_1._running]) {
(0, utils_1.resetStackTrace)(errorNotRunning, descriptor[kind]);
if (this[initLock].isLocked('write') || !this[_running]) {
resetStackTrace(errorNotRunning, descriptor[kind]);
throw errorNotRunning;

@@ -168,3 +161,3 @@ }

}
exports.ready = ready;
export { StartStop, ready, running, status, initLock };
//# sourceMappingURL=StartStop.js.map

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

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

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.resetStackTrace = exports.hasCaptureStackTrace = exports.AsyncGeneratorFunction = exports.GeneratorFunction = exports.AsyncFunction = exports.initLock = exports.status = exports._status = exports.destroyed = exports._destroyed = exports.running = exports._running = void 0;
/**

@@ -8,23 +5,12 @@ * Symbols prevents name clashes with decorated classes

const _running = Symbol('_running');
exports._running = _running;
const running = Symbol('running');
exports.running = running;
const _destroyed = Symbol('_destroyed');
exports._destroyed = _destroyed;
const destroyed = Symbol('destroyed');
exports.destroyed = destroyed;
const _status = Symbol('_status');
exports._status = _status;
const status = Symbol('status');
exports.status = status;
const initLock = Symbol('initLock');
exports.initLock = initLock;
const AsyncFunction = (async () => { }).constructor;
exports.AsyncFunction = AsyncFunction;
const GeneratorFunction = function* () { }.constructor;
exports.GeneratorFunction = GeneratorFunction;
const AsyncGeneratorFunction = async function* () { }.constructor;
exports.AsyncGeneratorFunction = AsyncGeneratorFunction;
const hasCaptureStackTrace = 'captureStackTrace' in Error;
exports.hasCaptureStackTrace = hasCaptureStackTrace;
/**

@@ -53,3 +39,3 @@ * Ready wrappers take exception objects

}
exports.resetStackTrace = resetStackTrace;
export { _running, running, _destroyed, destroyed, _status, status, initLock, AsyncFunction, GeneratorFunction, AsyncGeneratorFunction, hasCaptureStackTrace, resetStackTrace, };
//# sourceMappingURL=utils.js.map
{
"name": "@matrixai/async-init",
"version": "1.8.4",
"version": "2.0.0",
"author": "Roger Qiu",

@@ -11,4 +11,18 @@ "description": "Asynchronous Initialisation and Deinitialisation Decorators",

},
"main": "dist/index.js",
"types": "dist/index.d.ts",
"type": "module",
"exports": {
"./package.json": "./package.json",
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
},
"./*.js": {
"types": "./dist/*.d.ts",
"import": "./dist/*.js"
},
"./*": "./dist/*"
},
"imports": {
"#*": "./dist/*"
},
"scripts": {

@@ -18,6 +32,6 @@ "prepare": "tsc -p ./tsconfig.build.json",

"postversion": "npm install --package-lock-only --ignore-scripts --silent",
"ts-node": "ts-node",
"test": "jest",
"lint": "eslint '{src,tests,scripts,benches}/**/*.{js,ts}'",
"lintfix": "eslint '{src,tests,scripts,benches}/**/*.{js,ts}' --fix",
"tsx": "tsx",
"test": "node ./scripts/test.mjs",
"lint": "eslint '{src,tests,scripts,benches}/**/*.{js,mjs,ts,mts,jsx,tsx}'",
"lintfix": "eslint '{src,tests,scripts,benches}/**/*.{js,mjs,ts,mts,jsx,tsx}' --fix",
"lint-shell": "find ./src ./tests ./scripts -type f -regextype posix-extended -regex '.*\\.(sh)' -exec shellcheck {} +",

@@ -27,28 +41,26 @@ "docs": "shx rm -rf ./docs && typedoc --gitRevision master --tsconfig ./tsconfig.build.json --out ./docs src"

"dependencies": {
"@matrixai/async-locks": "^4.0.0",
"@matrixai/errors": "^1.1.7"
"@matrixai/async-locks": "^5.0.1",
"@matrixai/errors": "^2.0.1"
},
"devDependencies": {
"@swc/core": "^1.3.62",
"@swc/jest": "^0.2.26",
"@types/jest": "^28.1.3",
"@swc/core": "^1.3.76",
"@swc/jest": "^0.2.29",
"@types/jest": "^29.5.2",
"@types/node": "^18.15.0",
"@typescript-eslint/eslint-plugin": "^5.45.1",
"@typescript-eslint/parser": "^5.45.1",
"@typescript-eslint/eslint-plugin": "^5.61.0",
"@typescript-eslint/parser": "^5.61.0",
"async-mutex": "^0.3.2",
"eslint": "^8.15.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-prettier": "^4.0.0",
"jest": "^28.1.1",
"jest-extended": "^3.0.1",
"jest-junit": "^14.0.0",
"prettier": "^2.6.2",
"eslint": "^8.44.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-prettier": "^5.0.0-alpha.2",
"jest": "^29.6.2",
"jest-extended": "^4.0.0",
"jest-junit": "^16.0.0",
"prettier": "^3.0.0",
"shx": "^0.3.4",
"ts-jest": "^28.0.5",
"ts-node": "^10.9.1",
"tsconfig-paths": "^3.9.0",
"typedoc": "^0.23.21",
"typescript": "^4.9.3"
"tsx": "^3.12.7",
"typedoc": "^0.24.8",
"typescript": "^5.1.6"
}
}

@@ -114,3 +114,3 @@ # js-async-init

# run the repl (this allows you to import from ./src)
npm run ts-node
npm run tsx
# run the tests

@@ -117,0 +117,0 @@ npm run test

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