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

@matrixai/contexts

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@matrixai/contexts - npm Package Compare versions

Comparing version 1.2.0 to 2.0.1

env.schema.json

33

dist/decorators/cancellable.js

@@ -1,28 +0,3 @@

"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 });
const cancellable_1 = require("../functions/cancellable");
const utils = __importStar(require("../utils"));
import { setupCancellable } from '../functions/cancellable.js';
import * as utils from '../utils.js';
function cancellable(lazy = false) {

@@ -50,3 +25,3 @@ return (target, key, descriptor) => {

utils.checkContextCancellable(ctx, key, targetName);
return (0, cancellable_1.setupCancellable)((_, ...args) => f.apply(this, args), lazy, ctx, args);
return setupCancellable((_, ...args) => f.apply(this, args), lazy, ctx, args);
};

@@ -60,3 +35,3 @@ // Preserve the name

}
exports.default = cancellable;
export default cancellable;
//# sourceMappingURL=cancellable.js.map

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

"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 });
const contextsUtils = __importStar(require("../utils"));
import * as contextsUtils from '../utils.js';
/**

@@ -39,3 +14,3 @@ * Context parameter decorator

}
exports.default = context;
export default context;
//# sourceMappingURL=context.js.map

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

export { default as context } from './context';
export { default as cancellable } from './cancellable';
export { default as timed } from './timed';
export { default as timedCancellable } from './timedCancellable';
export { default as context } from './context.js';
export { default as cancellable } from './cancellable.js';
export { default as timed } from './timed.js';
export { default as timedCancellable } from './timedCancellable.js';

@@ -1,15 +0,5 @@

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.timedCancellable = exports.timed = exports.cancellable = exports.context = void 0;
var context_1 = require("./context");
Object.defineProperty(exports, "context", { enumerable: true, get: function () { return __importDefault(context_1).default; } });
var cancellable_1 = require("./cancellable");
Object.defineProperty(exports, "cancellable", { enumerable: true, get: function () { return __importDefault(cancellable_1).default; } });
var timed_1 = require("./timed");
Object.defineProperty(exports, "timed", { enumerable: true, get: function () { return __importDefault(timed_1).default; } });
var timedCancellable_1 = require("./timedCancellable");
Object.defineProperty(exports, "timedCancellable", { enumerable: true, get: function () { return __importDefault(timedCancellable_1).default; } });
export { default as context } from './context.js';
export { default as cancellable } from './cancellable.js';
export { default as timed } from './timed.js';
export { default as timedCancellable } from './timedCancellable.js';
//# sourceMappingURL=index.js.map

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

"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 });
const timed_1 = require("../functions/timed");
const utils = __importStar(require("../utils"));
const errors = __importStar(require("../errors"));
import { setupTimedContext } from '../functions/timed.js';
import * as utils from '../utils.js';
import * as errors from '../errors.js';
/**

@@ -56,3 +31,3 @@ * Timed method decorator

utils.checkContextTimed(ctx, key, targetName);
const teardownContext = (0, timed_1.setupTimedContext)(delay, errorTimeoutConstructor, ctx);
const teardownContext = setupTimedContext(delay, errorTimeoutConstructor, ctx);
try {

@@ -80,3 +55,3 @@ return await f.apply(this, args);

utils.checkContextTimed(ctx, key, targetName);
const teardownContext = (0, timed_1.setupTimedContext)(delay, errorTimeoutConstructor, ctx);
const teardownContext = setupTimedContext(delay, errorTimeoutConstructor, ctx);
try {

@@ -104,3 +79,3 @@ return yield* f.apply(this, args);

utils.checkContextTimed(ctx, key, targetName);
const teardownContext = (0, timed_1.setupTimedContext)(delay, errorTimeoutConstructor, ctx);
const teardownContext = setupTimedContext(delay, errorTimeoutConstructor, ctx);
try {

@@ -128,3 +103,3 @@ return yield* f.apply(this, args);

utils.checkContextTimed(ctx, key, targetName);
const teardownContext = (0, timed_1.setupTimedContext)(delay, errorTimeoutConstructor, ctx);
const teardownContext = setupTimedContext(delay, errorTimeoutConstructor, ctx);
const result = f.apply(this, args);

@@ -173,3 +148,3 @@ if (utils.isPromiseLike(result)) {

}
exports.default = timed;
export default timed;
//# sourceMappingURL=timed.js.map

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

"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 });
const timedCancellable_1 = require("../functions/timedCancellable");
const utils = __importStar(require("../utils"));
const errors = __importStar(require("../errors"));
import { setupTimedCancellable } from '../functions/timedCancellable.js';
import * as utils from '../utils.js';
import * as errors from '../errors.js';
function timedCancellable(lazy = false, delay = Infinity, errorTimeoutConstructor = errors.ErrorContextsTimedTimeOut) {

@@ -54,3 +29,3 @@ return (target, key, descriptor) => {

const delay_ = typeof delay === 'number' ? delay : delay(this);
return (0, timedCancellable_1.setupTimedCancellable)((_, ...args) => f.apply(this, args), lazy_, delay_, errorTimeoutConstructor, ctx, args);
return setupTimedCancellable((_, ...args) => f.apply(this, args), lazy_, delay_, errorTimeoutConstructor, ctx, args);
};

@@ -64,3 +39,3 @@ // Preserve the name

}
exports.default = timedCancellable;
export default timedCancellable;
//# sourceMappingURL=timedCancellable.js.map

@@ -1,13 +0,9 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ErrorContextsTimedTimeOut = exports.ErrorContexts = void 0;
const errors_1 = require("@matrixai/errors");
class ErrorContexts extends errors_1.AbstractError {
import { AbstractError } from '@matrixai/errors';
class ErrorContexts extends AbstractError {
static description = 'Contexts error';
}
exports.ErrorContexts = ErrorContexts;
class ErrorContextsTimedTimeOut extends ErrorContexts {
static description = 'Aborted due to timer expiration';
}
exports.ErrorContextsTimedTimeOut = ErrorContextsTimedTimeOut;
export { ErrorContexts, ErrorContextsTimedTimeOut };
//# sourceMappingURL=errors.js.map

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

import type { ContextCancellable } from '../types';
import type { ContextCancellable } from '../types.js';
import { PromiseCancellable } from '@matrixai/async-cancellable';

@@ -3,0 +3,0 @@ type ContextRemaining<C> = Omit<C, keyof ContextCancellable>;

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setupCancellable = void 0;
const async_cancellable_1 = require("@matrixai/async-cancellable");
import { PromiseCancellable } from '@matrixai/async-cancellable';
function setupCancellable(f, lazy, ctx, args) {

@@ -10,3 +7,3 @@ if (ctx.signal === undefined) {

const result = f(ctx, ...args);
return new async_cancellable_1.PromiseCancellable((resolve, reject, signal) => {
return new PromiseCancellable((resolve, reject, signal) => {
if (!lazy) {

@@ -40,3 +37,3 @@ signal.addEventListener('abort', () => {

// function's signal
return new async_cancellable_1.PromiseCancellable((resolve, reject, signal) => {
return new PromiseCancellable((resolve, reject, signal) => {
if (!lazy) {

@@ -58,3 +55,2 @@ if (signal.aborted) {

}
exports.setupCancellable = setupCancellable;
function cancellable(f, lazy = false) {

@@ -67,3 +63,4 @@ return (...params) => {

}
exports.default = cancellable;
export default cancellable;
export { setupCancellable };
//# sourceMappingURL=cancellable.js.map

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

export { default as cancellable } from './cancellable';
export { default as timed } from './timed';
export { default as timedCancellable } from './timedCancellable';
export { default as cancellable } from './cancellable.js';
export { default as timed } from './timed.js';
export { default as timedCancellable } from './timedCancellable.js';

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

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.timedCancellable = exports.timed = exports.cancellable = void 0;
var cancellable_1 = require("./cancellable");
Object.defineProperty(exports, "cancellable", { enumerable: true, get: function () { return __importDefault(cancellable_1).default; } });
var timed_1 = require("./timed");
Object.defineProperty(exports, "timed", { enumerable: true, get: function () { return __importDefault(timed_1).default; } });
var timedCancellable_1 = require("./timedCancellable");
Object.defineProperty(exports, "timedCancellable", { enumerable: true, get: function () { return __importDefault(timedCancellable_1).default; } });
export { default as cancellable } from './cancellable.js';
export { default as timed } from './timed.js';
export { default as timedCancellable } from './timedCancellable.js';
//# sourceMappingURL=index.js.map

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

import type { ContextTimed, ContextTimedInput } from '../types';
import type { ContextTimed, ContextTimedInput } from '../types.js';
type ContextRemaining<C> = Omit<C, keyof ContextTimedInput>;

@@ -3,0 +3,0 @@ type ContextAndParameters<C, P extends Array<any>> = keyof ContextRemaining<C> extends never ? [Partial<ContextTimedInput>?, ...P] : [Partial<ContextTimedInput> & ContextRemaining<C>, ...P];

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

"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.setupTimedContext = void 0;
const timer_1 = require("@matrixai/timer");
const errors = __importStar(require("../errors"));
const utils = __importStar(require("../utils"));
import { Timer } from '@matrixai/timer';
import * as errors from '../errors.js';
import * as utils from '../utils.js';
function setupTimedContext(delay, errorTimeoutConstructor, ctx) {

@@ -55,3 +29,3 @@ // There are 3 properties of timer and signal:

// Property A
const timer = new timer_1.Timer(() => void abortController.abort(e), ctx.timer ?? delay);
const timer = new Timer(() => void abortController.abort(e), ctx.timer ?? delay);
abortController.signal.addEventListener('abort', () => {

@@ -73,3 +47,3 @@ // Property B

// Property A
const timer = new timer_1.Timer(() => void abortController.abort(e), ctx.timer ?? delay);
const timer = new Timer(() => void abortController.abort(e), ctx.timer ?? delay);
const signalUpstream = ctx.signal;

@@ -99,3 +73,3 @@ const signalHandler = () => {

}
else if (ctx.timer instanceof timer_1.Timer && ctx.signal === undefined) {
else if (ctx.timer instanceof Timer && ctx.signal === undefined) {
const abortController = new AbortController();

@@ -128,3 +102,2 @@ const e = new errorTimeoutConstructor();

}
exports.setupTimedContext = setupTimedContext;
function timed(f, delay = Infinity, errorTimeoutConstructor = errors.ErrorContextsTimedTimeOut) {

@@ -212,3 +185,4 @@ if (f instanceof utils.AsyncFunction) {

}
exports.default = timed;
export default timed;
export { setupTimedContext };
//# sourceMappingURL=timed.js.map

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

import type { ContextTimed, ContextTimedInput } from '../types';
import type { ContextTimed, ContextTimedInput } from '../types.js';
import { PromiseCancellable } from '@matrixai/async-cancellable';

@@ -3,0 +3,0 @@ type ContextRemaining<C> = Omit<C, keyof ContextTimedInput>;

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

"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.setupTimedCancellable = void 0;
const async_cancellable_1 = require("@matrixai/async-cancellable");
const timer_1 = require("@matrixai/timer");
const errors = __importStar(require("../errors"));
import { PromiseCancellable } from '@matrixai/async-cancellable';
import { Timer } from '@matrixai/timer';
import * as errors from '../errors.js';
function setupTimedCancellable(f, lazy, delay, errorTimeoutConstructor, ctx, args) {

@@ -57,3 +31,3 @@ // There are 3 properties of timer and signal:

// Property A
const timer = new timer_1.Timer(() => void abortController.abort(e), ctx.timer ?? delay);
const timer = new Timer(() => void abortController.abort(e), ctx.timer ?? delay);
abortController.signal.addEventListener('abort', () => {

@@ -75,3 +49,3 @@ // Property B

// Property A
const timer = new timer_1.Timer(() => void abortController.abort(e), ctx.timer ?? delay);
const timer = new Timer(() => void abortController.abort(e), ctx.timer ?? delay);
const signalUpstream = ctx.signal;

@@ -101,3 +75,3 @@ const signalHandler = () => {

}
else if (ctx.timer instanceof timer_1.Timer && ctx.signal === undefined) {
else if (ctx.timer instanceof Timer && ctx.signal === undefined) {
abortController = new AbortController();

@@ -150,3 +124,3 @@ const e = new errorTimeoutConstructor();

// function's signal
return new async_cancellable_1.PromiseCancellable((resolve, reject, signal) => {
return new PromiseCancellable((resolve, reject, signal) => {
if (!lazy) {

@@ -167,3 +141,2 @@ if (signal.aborted) {

}
exports.setupTimedCancellable = setupTimedCancellable;
function timedCancellable(f, lazy = false, delay = Infinity, errorTimeoutConstructor = errors.ErrorContextsTimedTimeOut) {

@@ -176,3 +149,4 @@ return (...params) => {

}
exports.default = timedCancellable;
export default timedCancellable;
export { setupTimedCancellable };
//# sourceMappingURL=timedCancellable.js.map

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

export * as decorators from './decorators';
export * as functions from './functions';
export * as utils from './utils';
export * as errors from './errors';
export * from './types';
export * as decorators from './decorators/index.js';
export * as functions from './functions/index.js';
export * as utils from './utils.js';
export * as errors from './errors.js';
export type * from './types.js';

@@ -1,35 +0,5 @@

"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;
};
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 });
exports.errors = exports.utils = exports.functions = exports.decorators = void 0;
exports.decorators = __importStar(require("./decorators"));
exports.functions = __importStar(require("./functions"));
exports.utils = __importStar(require("./utils"));
exports.errors = __importStar(require("./errors"));
__exportStar(require("./types"), exports);
export * as decorators from './decorators/index.js';
export * as functions from './functions/index.js';
export * as utils from './utils.js';
export * as errors from './errors.js';
//# sourceMappingURL=index.js.map

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

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

@@ -1,14 +0,7 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isAsyncGenerator = exports.isGenerator = exports.isPromiseLike = exports.monitor = exports.timer = exports.checkContextTimed = exports.checkContextCancellable = exports.getContextIndex = exports.contexts = exports.AsyncGeneratorFunction = exports.GeneratorFunction = exports.AsyncFunction = void 0;
const timer_1 = require("@matrixai/timer");
const async_locks_1 = require("@matrixai/async-locks");
import { Timer } from '@matrixai/timer';
import { Monitor } from '@matrixai/async-locks';
const AsyncFunction = (async () => { }).constructor;
exports.AsyncFunction = AsyncFunction;
const GeneratorFunction = function* () { }.constructor;
exports.GeneratorFunction = GeneratorFunction;
const AsyncGeneratorFunction = async function* () { }.constructor;
exports.AsyncGeneratorFunction = AsyncGeneratorFunction;
const contexts = new WeakMap();
exports.contexts = contexts;
function getContextIndex(target, key, targetName) {

@@ -21,3 +14,2 @@ const contextIndex = contexts.get(target[key]);

}
exports.getContextIndex = getContextIndex;
function checkContextCancellable(ctx, key, targetName) {

@@ -31,3 +23,2 @@ if (typeof ctx !== 'object' || ctx === null) {

}
exports.checkContextCancellable = checkContextCancellable;
function checkContextTimed(ctx, key, targetName) {

@@ -41,7 +32,6 @@ if (typeof ctx !== 'object' || ctx === null) {

if (ctx.timer !== undefined &&
!(typeof ctx.timer === 'number' || ctx.timer instanceof timer_1.Timer)) {
!(typeof ctx.timer === 'number' || ctx.timer instanceof Timer)) {
throw new TypeError(`\`${targetName}.${key.toString()}\` decorated \`@context\` parameter's \`timer\` property is not a number nor an instance of \`Timer\``);
}
}
exports.checkContextTimed = checkContextTimed;
/**

@@ -55,6 +45,6 @@ * Timer resource

if (typeof handlerOrOpts === 'function') {
timer = new timer_1.Timer(handlerOrOpts, delay, lazy, controller);
timer = new Timer(handlerOrOpts, delay, lazy, controller);
}
else {
timer = new timer_1.Timer(handlerOrOpts);
timer = new Timer(handlerOrOpts);
}

@@ -69,6 +59,5 @@ return [

}
exports.timer = timer;
function monitor(lockBox, lockConstructor, locksPending) {
return async () => {
const monitor = new async_locks_1.Monitor(lockBox, lockConstructor, locksPending);
const monitor = new Monitor(lockBox, lockConstructor, locksPending);
return [

@@ -82,7 +71,5 @@ async () => {

}
exports.monitor = monitor;
function isPromiseLike(v) {
return v != null && typeof v.then === 'function';
}
exports.isPromiseLike = isPromiseLike;
/**

@@ -99,3 +86,2 @@ * Is generator object

}
exports.isGenerator = isGenerator;
/**

@@ -113,3 +99,3 @@ * Is async generator object

}
exports.isAsyncGenerator = isAsyncGenerator;
export { AsyncFunction, GeneratorFunction, AsyncGeneratorFunction, contexts, getContextIndex, checkContextCancellable, checkContextTimed, timer, monitor, isPromiseLike, isGenerator, isAsyncGenerator, };
//# sourceMappingURL=utils.js.map
{
"name": "@matrixai/contexts",
"version": "1.2.0",
"version": "2.0.1",
"author": "Roger Qiu",

@@ -11,4 +11,18 @@ "description": "Asynchronous contexts",

},
"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,38 +32,43 @@ "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}/**/*.{js,ts}'",
"lintfix": "eslint '{src,tests,scripts}/**/*.{js,ts}' --fix",
"lint-shell": "find ./src ./tests ./scripts -type f -regextype posix-extended -regex '.*\\.(sh)' -exec shellcheck {} +",
"docs": "shx rm -rf ./docs && typedoc --gitRevision master --tsconfig ./tsconfig.build.json --out ./docs src"
"tsx": "tsx",
"test": "node ./scripts/test.mjs",
"lint": "node ./scripts/lint.mjs",
"lintfix": "node ./scripts/lint.mjs --fix",
"docs": "shx rm -rf ./docs && typedoc --gitRevision master --tsconfig ./tsconfig.build.json --out ./docs src",
"bench": "tsc -p ./tsconfig.build.json && shx rm -rf ./benches/results && tsx ./benches/index.ts"
},
"dependencies": {
"@matrixai/async-cancellable": "^1.1.1",
"@matrixai/async-locks": "^4.0.0",
"@matrixai/errors": "^1.1.7",
"@matrixai/resources": "^1.1.5",
"@matrixai/timer": "^1.1.1"
"@matrixai/async-cancellable": "^2.0.0",
"@matrixai/async-locks": "^5.0.1",
"@matrixai/errors": "^2.1.2",
"@matrixai/resources": "^2.0.0",
"@matrixai/timer": "^2.1.0"
},
"devDependencies": {
"@swc/core": "^1.3.62",
"@swc/jest": "^0.2.26",
"@types/jest": "^28.1.3",
"@types/node": "^18.15.0",
"@typescript-eslint/eslint-plugin": "^5.45.1",
"@typescript-eslint/parser": "^5.45.1",
"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",
"@swc/core": "1.3.82",
"@swc/jest": "^0.2.29",
"@types/jest": "^29.5.2",
"@types/node": "^20.5.7",
"@typescript-eslint/eslint-plugin": "^8.18.0",
"@typescript-eslint/parser": "^8.18.0",
"@eslint/compat": "^1.2.4",
"@eslint/eslintrc": "^3.2.0",
"@eslint/js": "^9.16.0",
"benny": "^3.7.1",
"common-tags": "^1.8.2",
"eslint": "^9.16.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-prettier": "^5.2.1",
"globals": "^15.13.0",
"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"
"systeminformation": "^5.18.5",
"tsx": "^3.12.7",
"typedoc": "^0.24.8",
"typescript": "^5.1.6"
}
}
# js-contexts
staging:[![pipeline status](https://gitlab.com/MatrixAI/open-source/js-contexts/badges/staging/pipeline.svg)](https://gitlab.com/MatrixAI/open-source/js-contexts/commits/staging)
master:[![pipeline status](https://gitlab.com/MatrixAI/open-source/js-contexts/badges/master/pipeline.svg)](https://gitlab.com/MatrixAI/open-source/js-contexts/commits/master)
Asynchronous contexts.

@@ -16,3 +13,3 @@

Run `nix-shell`, and once you're inside, you can use:
Run `nix develop`, and once you're inside, you can use:

@@ -25,8 +22,8 @@ ```sh

# run the repl (this allows you to import from ./src)
npm run ts-node
npm run tsx
# run the tests
npm run test
# lint the source code
# lint code, markdown, scripts
npm run lint
# automatically fix the source
# automatically fix linting errors
npm run lintfix

@@ -33,0 +30,0 @@ ```

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