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

awilix

Package Overview
Dependencies
Maintainers
1
Versions
92
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

awilix - npm Package Compare versions

Comparing version 10.0.2 to 11.0.0

13

lib/awilix.browser.js

@@ -15,3 +15,3 @@ /******************************************************************************

***************************************************************************** */
/* global Reflect, Promise, SuppressedError, Symbol */
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */

@@ -45,4 +45,4 @@ var extendStatics = function(d, b) {

function __generator(thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }

@@ -328,3 +328,2 @@ function step(op) {

type = 'EOF';
// eslint-disable-next-line no-constant-condition
while (true) {

@@ -590,5 +589,4 @@ if (pos >= end) {

function isClass(
// eslint-disable-next-line @typescript-eslint/ban-types
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
fn) {
/*tslint:disable-next-line*/
if (typeof fn !== 'function') {

@@ -764,3 +762,3 @@ return false;

// We parse the signature of any `Function`, so we want to allow `Function` types.
/* eslint-disable @typescript-eslint/ban-types */
/* eslint-disable @typescript-eslint/no-unsafe-function-type */
/**

@@ -1231,3 +1229,2 @@ * RESOLVER symbol can be used by modules loaded by

/* removed in browser build */
// tslint:disable-next-line
_a[ROLL_UP_REGISTRATIONS] = rollUpRegistrations,

@@ -1234,0 +1231,0 @@ Object.defineProperty(_a, "registrations", {

@@ -21,3 +21,3 @@ (function (global, factory) {

***************************************************************************** */
/* global Reflect, Promise, SuppressedError, Symbol */
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */

@@ -51,4 +51,4 @@ var extendStatics = function(d, b) {

function __generator(thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }

@@ -334,3 +334,2 @@ function step(op) {

type = 'EOF';
// eslint-disable-next-line no-constant-condition
while (true) {

@@ -596,5 +595,4 @@ if (pos >= end) {

function isClass(
// eslint-disable-next-line @typescript-eslint/ban-types
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
fn) {
/*tslint:disable-next-line*/
if (typeof fn !== 'function') {

@@ -770,3 +768,3 @@ return false;

// We parse the signature of any `Function`, so we want to allow `Function` types.
/* eslint-disable @typescript-eslint/ban-types */
/* eslint-disable @typescript-eslint/no-unsafe-function-type */
/**

@@ -1237,3 +1235,2 @@ * RESOLVER symbol can be used by modules loaded by

/* removed in browser build */
// tslint:disable-next-line
_a[ROLL_UP_REGISTRATIONS] = rollUpRegistrations,

@@ -1240,0 +1237,0 @@ Object.defineProperty(_a, "registrations", {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createContainer = void 0;
exports.createContainer = createContainer;
const util = require("util");

@@ -41,5 +41,8 @@ const errors_1 = require("./errors");

}
exports.createContainer = createContainer;
function createContainerInternal(options, parentContainer, parentResolutionStack) {
options = Object.assign({ injectionMode: injection_mode_1.InjectionMode.PROXY, strict: false }, options);
options = {
injectionMode: injection_mode_1.InjectionMode.PROXY,
strict: false,
...options,
};
/**

@@ -49,3 +52,3 @@ * Tracks the names and lifetimes of the modules being resolved. Used to detect circular

*/
const resolutionStack = parentResolutionStack !== null && parentResolutionStack !== void 0 ? parentResolutionStack : [];
const resolutionStack = parentResolutionStack ?? [];
// Internal registration store for this container.

@@ -118,3 +121,2 @@ const registrations = {};

[util.inspect.custom]: inspect,
// tslint:disable-next-line
[ROLL_UP_REGISTRATIONS]: rollUpRegistrations,

@@ -154,3 +156,6 @@ get registrations() {

function rollUpRegistrations() {
return Object.assign(Object.assign({}, (parentContainer && parentContainer[ROLL_UP_REGISTRATIONS]())), registrations);
return {
...(parentContainer && parentContainer[ROLL_UP_REGISTRATIONS]()),
...registrations,
};
}

@@ -378,2 +383,3 @@ /**

function (uri) {
// eslint-disable-next-line @typescript-eslint/no-require-imports
return require(uri);

@@ -384,3 +390,3 @@ },

};
if (opts === null || opts === void 0 ? void 0 : opts.esModules) {
if (opts?.esModules) {
_loadModulesDeps.require = load_module_native_js_1.importModule;

@@ -387,0 +393,0 @@ return (0, load_modules_1.loadModules)(_loadModulesDeps, globPatterns, opts).then(() => container);

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createTokenizer = void 0;
exports.createTokenizer = createTokenizer;
/**

@@ -37,3 +37,2 @@ * Creates a tokenizer for the specified source.

type = 'EOF';
// eslint-disable-next-line no-constant-condition
while (true) {

@@ -213,3 +212,2 @@ if (pos >= end) {

}
exports.createTokenizer = createTokenizer;
/**

@@ -216,0 +214,0 @@ * Determines if the given character is a whitespace character.

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isLifetimeLonger = exports.Lifetime = void 0;
exports.Lifetime = void 0;
exports.isLifetimeLonger = isLifetimeLonger;
/**

@@ -31,3 +32,2 @@ * Lifetime types.

}
exports.isLifetimeLonger = isLifetimeLonger;
//# sourceMappingURL=lifetime.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.listModules = void 0;
exports.listModules = listModules;
const glob = require("fast-glob");

@@ -25,3 +25,3 @@ const path = require("path");

function _listModules(globPattern, opts) {
opts = Object.assign({ cwd: process.cwd(), glob: glob.sync }, opts);
opts = { cwd: process.cwd(), glob: glob.sync, ...opts };
let patternOpts = null;

@@ -63,3 +63,2 @@ if (Array.isArray(globPattern)) {

}
exports.listModules = listModules;
//# sourceMappingURL=list-modules.js.map
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.loadModules = void 0;
exports.loadModules = loadModules;
const camel_case_1 = require("camel-case");

@@ -51,3 +42,3 @@ const url_1 = require("url");

function loadModules(dependencies, globPatterns, opts) {
opts !== null && opts !== void 0 ? opts : (opts = {});
opts ??= {};
const container = dependencies.container;

@@ -67,3 +58,2 @@ opts = optsWithDefaults(opts);

}
exports.loadModules = loadModules;
/**

@@ -75,16 +65,14 @@ * Loads the modules using native ES6 modules and the async import()

*/
function loadEsModules(dependencies, container, modules, opts) {
return __awaiter(this, void 0, void 0, function* () {
const importPromises = [];
for (const m of modules) {
const fileUrl = (0, url_1.pathToFileURL)(m.path).toString();
importPromises.push(dependencies.require(fileUrl));
}
const imports = yield Promise.all(importPromises);
const result = [];
for (let i = 0; i < modules.length; i++) {
result.push(parseLoadedModule(imports[i], modules[i]));
}
return registerModules(result, container, modules, opts);
});
async function loadEsModules(dependencies, container, modules, opts) {
const importPromises = [];
for (const m of modules) {
const fileUrl = (0, url_1.pathToFileURL)(m.path).toString();
importPromises.push(dependencies.require(fileUrl));
}
const imports = await Promise.all(importPromises);
const result = [];
for (let i = 0; i < modules.length; i++) {
result.push(parseLoadedModule(imports[i], modules[i]));
}
return registerModules(result, container, modules, opts);
}

@@ -161,5 +149,10 @@ /**

function optsWithDefaults(opts) {
return Object.assign({
return {
// Does a somewhat-deep merge on the registration options.
resolverOptions: Object.assign({ lifetime: lifetime_1.Lifetime.TRANSIENT }, (opts && opts.resolverOptions)) }, opts);
resolverOptions: {
lifetime: lifetime_1.Lifetime.TRANSIENT,
...(opts && opts.resolverOptions),
},
...opts,
};
}

@@ -192,4 +185,8 @@ /**

}
const regOpts = Object.assign(Object.assign(Object.assign({}, opts.resolverOptions), moduleDescriptorOpts), inlineConfig);
// eslint-disable-next-line @typescript-eslint/ban-types
const regOpts = {
...opts.resolverOptions,
...moduleDescriptorOpts,
...inlineConfig,
};
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
const reg = regOpts.register

@@ -196,0 +193,0 @@ ? regOpts.register

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseParameterList = void 0;
exports.parseParameterList = parseParameterList;
const function_tokenizer_1 = require("./function-tokenizer");

@@ -130,3 +130,2 @@ /*

}
exports.parseParameterList = parseParameterList;
//# sourceMappingURL=param-parser.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createDisposableResolver = exports.createBuildResolver = exports.aliasTo = exports.asClass = exports.asFunction = exports.asValue = exports.RESOLVER = void 0;
exports.RESOLVER = void 0;
exports.asValue = asValue;
exports.asFunction = asFunction;
exports.asClass = asClass;
exports.aliasTo = aliasTo;
exports.createBuildResolver = createBuildResolver;
exports.createDisposableResolver = createDisposableResolver;
const errors_1 = require("./errors");

@@ -10,3 +16,3 @@ const injection_mode_1 = require("./injection-mode");

// We parse the signature of any `Function`, so we want to allow `Function` types.
/* eslint-disable @typescript-eslint/ban-types */
/* eslint-disable @typescript-eslint/no-unsafe-function-type */
/**

@@ -34,3 +40,2 @@ * RESOLVER symbol can be used by modules loaded by

}
exports.asValue = asValue;
/**

@@ -61,6 +66,8 @@ * Creates a factory resolver, where the given factory function

const resolve = generateResolve(fn);
const result = Object.assign({ resolve }, opts);
const result = {
resolve,
...opts,
};
return createDisposableResolver(createBuildResolver(result));
}
exports.asFunction = asFunction;
/**

@@ -94,5 +101,7 @@ * Like a factory resolver, but for classes that require `new`.

const resolve = generateResolve(newClass, Type);
return createDisposableResolver(createBuildResolver(Object.assign(Object.assign({}, opts), { resolve })));
return createDisposableResolver(createBuildResolver({
...opts,
resolve,
}));
}
exports.asClass = asClass;
/**

@@ -110,3 +119,2 @@ * Resolves to the specified registration. Marked as leak-safe since the alias target is what should

}
exports.aliasTo = aliasTo;
/**

@@ -124,9 +132,18 @@ * Given an options object, creates a fluid interface

function setLifetime(value) {
return createBuildResolver(Object.assign(Object.assign({}, this), { lifetime: value }));
return createBuildResolver({
...this,
lifetime: value,
});
}
function setInjectionMode(value) {
return createBuildResolver(Object.assign(Object.assign({}, this), { injectionMode: value }));
return createBuildResolver({
...this,
injectionMode: value,
});
}
function inject(injector) {
return createBuildResolver(Object.assign(Object.assign({}, this), { injector }));
return createBuildResolver({
...this,
injector,
});
}

@@ -144,3 +161,2 @@ return updateResolver(obj, {

}
exports.createBuildResolver = createBuildResolver;
/**

@@ -153,3 +169,6 @@ * Given a resolver, returns an object with methods to manage the disposer

function disposer(dispose) {
return createDisposableResolver(Object.assign(Object.assign({}, this), { dispose }));
return createDisposableResolver({
...this,
dispose,
});
}

@@ -160,3 +179,2 @@ return updateResolver(obj, {

}
exports.createDisposableResolver = createDisposableResolver;
/**

@@ -191,3 +209,6 @@ * Partially apply arguments to the given function.

function updateResolver(source, target) {
const result = Object.assign(Object.assign({}, source), target);
const result = {
...source,
...target,
};
return result;

@@ -194,0 +215,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.uniq = exports.isFunction = exports.isClass = exports.last = exports.nameValueToObject = exports.flatten = void 0;
exports.flatten = flatten;
exports.nameValueToObject = nameValueToObject;
exports.last = last;
exports.isClass = isClass;
exports.isFunction = isFunction;
exports.uniq = uniq;
const function_tokenizer_1 = require("./function-tokenizer");

@@ -23,3 +28,2 @@ /**

}
exports.flatten = flatten;
/**

@@ -43,3 +47,2 @@ * Creates a { name: value } object if the input isn't already in that format.

}
exports.nameValueToObject = nameValueToObject;
/**

@@ -57,3 +60,2 @@ * Returns the last item in the array.

}
exports.last = last;
/**

@@ -66,5 +68,4 @@ * Determines if the given function is a class.

function isClass(
// eslint-disable-next-line @typescript-eslint/ban-types
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
fn) {
/*tslint:disable-next-line*/
if (typeof fn !== 'function') {

@@ -87,3 +88,2 @@ return false;

}
exports.isClass = isClass;
/**

@@ -101,3 +101,2 @@ * Determines if the given value is a function.

}
exports.isFunction = isFunction;
/**

@@ -115,3 +114,2 @@ * Returns the unique items in the array.

}
exports.uniq = uniq;
//# sourceMappingURL=utils.js.map
{
"name": "awilix",
"version": "10.0.2",
"version": "11.0.0",
"description": "Extremely powerful dependency injection container.",

@@ -13,3 +13,3 @@ "main": "lib/awilix.js",

"engines": {
"node": ">=14.0.0"
"node": ">=16.3.0"
},

@@ -53,19 +53,16 @@ "scripts": {

"devDependencies": {
"@babel/core": "^7.23.7",
"@babel/plugin-transform-runtime": "^7.23.7",
"@babel/preset-env": "^7.23.7",
"@babel/runtime": "^7.23.7",
"@types/jest": "^29.5.11",
"@types/node": "^20.10.7",
"@typescript-eslint/eslint-plugin": "^6.18.0",
"@typescript-eslint/parser": "^6.18.0",
"@babel/core": "^7.25.2",
"@babel/plugin-transform-runtime": "^7.25.4",
"@babel/preset-env": "^7.25.4",
"@babel/runtime": "^7.25.4",
"@types/jest": "^29.5.12",
"@types/node": "^22.5.0",
"babel-jest": "^29.7.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"husky": "^8.0.3",
"eslint": "^9.9.1",
"husky": "^9.1.5",
"jest": "^29.7.0",
"lint-staged": "^13.2.0",
"prettier": "^3.1.1",
"rimraf": "^5.0.5",
"rollup": "^3.20.2",
"lint-staged": "^15.2.9",
"prettier": "^3.3.3",
"rimraf": "^6.0.1",
"rollup": "^4.21.0",
"rollup-plugin-commonjs": "^10.1.0",

@@ -77,5 +74,6 @@ "rollup-plugin-copy": "^3.5.0",

"smid": "^0.1.1",
"ts-jest": "^29.1.1",
"tslib": "^2.6.2",
"typescript": "^5.3.3"
"ts-jest": "^29.2.5",
"tslib": "^2.7.0",
"typescript": "^5.5.4",
"typescript-eslint": "^8.2.0"
},

@@ -82,0 +80,0 @@ "dependencies": {

@@ -1413,2 +1413,3 @@ # Awilix

- [`fastify-awilix`](https://github.com/fastify/fastify-awilix): Bindings for the Fastify framework.
- [`awilix-vite`](https://github.com/kvist-no/awilix-vite): Use Awilix in Vite projects.

@@ -1415,0 +1416,0 @@ # Contributing

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