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

cheap-di

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cheap-di - npm Package Compare versions

Comparing version 4.1.2 to 4.1.3-dev.1

24

cjs/ContainerImpl.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.container = exports.ContainerImpl = void 0;
const CircularDependencyError_1 = require("./CircularDependencyError");
const metadata_1 = require("./metadata");
const isSingleton_1 = require("./isSingleton");
const Trace_1 = require("./Trace");
const CircularDependencyError_js_1 = require("./CircularDependencyError.js");
const metadata_js_1 = require("./metadata.js");
const isSingleton_js_1 = require("./isSingleton.js");
const Trace_js_1 = require("./Trace.js");
class ContainerImpl {

@@ -42,4 +42,4 @@ singletons;

}
if (!(0, isSingleton_1.isSingleton)(implementationType)) {
const metadata = (0, metadata_1.findOrCreateMetadata)(implementationType);
if (!(0, isSingleton_js_1.isSingleton)(implementationType)) {
const metadata = (0, metadata_js_1.findOrCreateMetadata)(implementationType);
metadata.modifiedClass = implementationType;

@@ -51,3 +51,3 @@ metadata.singleton = true;

inject: (...injectionParams) => {
const metadata = (0, metadata_1.findOrCreateMetadata)(implementationType);
const metadata = (0, metadata_js_1.findOrCreateMetadata)(implementationType);
metadata.injected = injectionParams;

@@ -100,3 +100,3 @@ return registeredImplementation;

resolve(type, ...args) {
const trace = new Trace_1.Trace(type.name);
const trace = new Trace_js_1.Trace(type.name);
try {

@@ -114,3 +114,3 @@ const resolvedInstance = this.internalResolve(type, trace, ...args);

console.warn('cheap-di, circular dependencies tree', tree);
throw new CircularDependencyError_1.CircularDependencyError(`Circular dependencies during resolve ${type.name}. ${error.message}`);
throw new CircularDependencyError_js_1.CircularDependencyError(`Circular dependencies during resolve ${type.name}. ${error.message}`);
}

@@ -142,3 +142,3 @@ throw error;

}
if ((0, isSingleton_1.isSingleton)(implementation)) {
if ((0, isSingleton_js_1.isSingleton)(implementation)) {
const singletons = this.getSingletons();

@@ -150,3 +150,3 @@ if (singletons.has(implementation)) {

trace.implemented = implementation.name;
const metadata = (0, metadata_1.findMetadata)(implementation);
const metadata = (0, metadata_js_1.findMetadata)(implementation);
let injectableArguments = [];

@@ -259,3 +259,3 @@ const injectionParams = [];

const target = new implementation(...injectableArguments);
if ((0, isSingleton_1.isSingleton)(implementation)) {
if ((0, isSingleton_js_1.isSingleton)(implementation)) {
const singletons = this.getSingletons();

@@ -262,0 +262,0 @@ singletons.set(implementation, target);

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.inject = void 0;
const metadata_1 = require("../metadata");
const metadata_js_1 = require("../metadata.js");
exports.inject = ((...dependencies) => {
return (constructor) => {
(0, metadata_1.saveConstructorMetadata)(constructor, ...dependencies);
(0, metadata_js_1.saveConstructorMetadata)(constructor, ...dependencies);
return constructor;

@@ -9,0 +9,0 @@ };

@@ -17,30 +17,30 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./cheapDiSymbol"), exports);
__exportStar(require("./CircularDependencyError"), exports);
__exportStar(require("./ContainerImpl"), exports);
__exportStar(require("./decorators/inject"), exports);
__exportStar(require("./metadata"), exports);
__exportStar(require("./isSingleton"), exports);
__exportStar(require("./Trace"), exports);
__exportStar(require("./types"), exports);
const cheapDiSymbol_1 = require("./cheapDiSymbol");
const CircularDependencyError_1 = require("./CircularDependencyError");
const ContainerImpl_1 = require("./ContainerImpl");
const inject_1 = require("./decorators/inject");
const metadata_1 = require("./metadata");
const isSingleton_1 = require("./isSingleton");
const Trace_1 = require("./Trace");
__exportStar(require("./cheapDiSymbol.js"), exports);
__exportStar(require("./CircularDependencyError.js"), exports);
__exportStar(require("./ContainerImpl.js"), exports);
__exportStar(require("./decorators/inject.js"), exports);
__exportStar(require("./metadata.js"), exports);
__exportStar(require("./isSingleton.js"), exports);
__exportStar(require("./Trace.js"), exports);
__exportStar(require("./types.js"), exports);
const cheapDiSymbol_js_1 = require("./cheapDiSymbol.js");
const CircularDependencyError_js_1 = require("./CircularDependencyError.js");
const ContainerImpl_js_1 = require("./ContainerImpl.js");
const inject_js_1 = require("./decorators/inject.js");
const metadata_js_1 = require("./metadata.js");
const isSingleton_js_1 = require("./isSingleton.js");
const Trace_js_1 = require("./Trace.js");
exports.default = {
cheapDiSymbol: cheapDiSymbol_1.cheapDiSymbol,
CircularDependencyError: CircularDependencyError_1.CircularDependencyError,
container: ContainerImpl_1.container,
ContainerImpl: ContainerImpl_1.ContainerImpl,
inject: inject_1.inject,
findMetadata: metadata_1.findMetadata,
findOrCreateMetadata: metadata_1.findOrCreateMetadata,
saveConstructorMetadata: metadata_1.saveConstructorMetadata,
createConstructorMetadata: metadata_1.createConstructorMetadata,
isSingleton: isSingleton_1.isSingleton,
Trace: Trace_1.Trace,
cheapDiSymbol: cheapDiSymbol_js_1.cheapDiSymbol,
CircularDependencyError: CircularDependencyError_js_1.CircularDependencyError,
container: ContainerImpl_js_1.container,
ContainerImpl: ContainerImpl_js_1.ContainerImpl,
inject: inject_js_1.inject,
findMetadata: metadata_js_1.findMetadata,
findOrCreateMetadata: metadata_js_1.findOrCreateMetadata,
saveConstructorMetadata: metadata_js_1.saveConstructorMetadata,
createConstructorMetadata: metadata_js_1.createConstructorMetadata,
isSingleton: isSingleton_js_1.isSingleton,
Trace: Trace_js_1.Trace,
};
//# sourceMappingURL=index.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isSingleton = void 0;
const metadata_1 = require("./metadata");
const metadata_js_1 = require("./metadata.js");
function isSingleton(constructor) {
const modifiedConstructor = (0, metadata_1.findMetadata)(constructor)?.modifiedClass;
const modifiedConstructor = (0, metadata_js_1.findMetadata)(constructor)?.modifiedClass;
if (!modifiedConstructor) {

@@ -14,5 +14,5 @@ return false;

const implementationType = constructor;
return (0, metadata_1.findMetadata)(implementationType)?.singleton === true;
return (0, metadata_js_1.findMetadata)(implementationType)?.singleton === true;
}
exports.isSingleton = isSingleton;
//# sourceMappingURL=isSingleton.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createConstructorMetadata = exports.findMetadata = exports.findOrCreateMetadata = exports.saveConstructorMetadata = void 0;
const cheapDiSymbol_1 = require("./cheapDiSymbol");
const cheapDiSymbol_js_1 = require("./cheapDiSymbol.js");
function saveConstructorMetadata(constructor, ...dependencies) {

@@ -23,7 +23,7 @@ if (!constructor) {

function findMetadata(constructor) {
return constructor[cheapDiSymbol_1.cheapDiSymbol];
return constructor[cheapDiSymbol_js_1.cheapDiSymbol];
}
exports.findMetadata = findMetadata;
function createConstructorMetadata(constructor) {
return (constructor[cheapDiSymbol_1.cheapDiSymbol] = {
return (constructor[cheapDiSymbol_js_1.cheapDiSymbol] = {
modifiedClass: constructor,

@@ -30,0 +30,0 @@ });

{
"type": "commonjs",
"version": "4.1.2"
"version": "4.1.3-dev.1"
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const cheapDiSymbol_1 = require("./cheapDiSymbol");
const cheapDiSymbol_js_1 = require("./cheapDiSymbol.js");
//# sourceMappingURL=types.js.map

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

import { CircularDependencyError } from './CircularDependencyError';
import { findMetadata, findOrCreateMetadata } from './metadata';
import { isSingleton } from './isSingleton';
import { Trace } from './Trace';
import { CircularDependencyError } from './CircularDependencyError.js';
import { findMetadata, findOrCreateMetadata } from './metadata.js';
import { isSingleton } from './isSingleton.js';
import { Trace } from './Trace.js';
class ContainerImpl {

@@ -6,0 +6,0 @@ singletons;

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

import { saveConstructorMetadata } from '../metadata';
import { saveConstructorMetadata } from '../metadata.js';
export const inject = ((...dependencies) => {

@@ -3,0 +3,0 @@ return (constructor) => {

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

export * from './cheapDiSymbol';
export * from './CircularDependencyError';
export * from './ContainerImpl';
export * from './decorators/inject';
export * from './metadata';
export * from './isSingleton';
export * from './Trace';
export * from './types';
import { cheapDiSymbol } from './cheapDiSymbol';
import { CircularDependencyError } from './CircularDependencyError';
import { container, ContainerImpl } from './ContainerImpl';
import { inject } from './decorators/inject';
import { findMetadata, findOrCreateMetadata, saveConstructorMetadata, createConstructorMetadata, } from './metadata';
import { isSingleton } from './isSingleton';
import { Trace } from './Trace';
export * from './cheapDiSymbol.js';
export * from './CircularDependencyError.js';
export * from './ContainerImpl.js';
export * from './decorators/inject.js';
export * from './metadata.js';
export * from './isSingleton.js';
export * from './Trace.js';
export * from './types.js';
import { cheapDiSymbol } from './cheapDiSymbol.js';
import { CircularDependencyError } from './CircularDependencyError.js';
import { container, ContainerImpl } from './ContainerImpl.js';
import { inject } from './decorators/inject.js';
import { findMetadata, findOrCreateMetadata, saveConstructorMetadata, createConstructorMetadata, } from './metadata.js';
import { isSingleton } from './isSingleton.js';
import { Trace } from './Trace.js';
export default {

@@ -17,0 +17,0 @@ cheapDiSymbol,

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

import { findMetadata } from './metadata';
import { findMetadata } from './metadata.js';
export function isSingleton(constructor) {

@@ -3,0 +3,0 @@ const modifiedConstructor = findMetadata(constructor)?.modifiedClass;

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

import { cheapDiSymbol } from './cheapDiSymbol';
import { cheapDiSymbol } from './cheapDiSymbol.js';
export function saveConstructorMetadata(constructor, ...dependencies) {

@@ -3,0 +3,0 @@ if (!constructor) {

{
"type": "module",
"version": "4.1.2"
"version": "4.1.3-dev.1"
}

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

import { cheapDiSymbol } from './cheapDiSymbol';
import { cheapDiSymbol } from './cheapDiSymbol.js';
//# sourceMappingURL=types.js.map
{
"name": "cheap-di",
"version": "4.1.2",
"version": "4.1.3-dev.1",
"description": "TypeScript dependency injection like Autofac in .Net",

@@ -5,0 +5,0 @@ "type": "module",

@@ -0,0 +0,0 @@ # cheap-di

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

import { SomeDependency } from '../types';
import { SomeDependency } from '../types.js';
export interface InjectDecorator {

@@ -3,0 +3,0 @@ <T>(...dependencies: SomeDependency[]): (constructor: T, context?: ClassDecoratorContext) => T;

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

export * from './cheapDiSymbol';
export * from './CircularDependencyError';
export * from './ContainerImpl';
export * from './decorators/inject';
export * from './metadata';
export * from './isSingleton';
export * from './Trace';
export * from './types';
import { CircularDependencyError } from './CircularDependencyError';
import { ContainerImpl } from './ContainerImpl';
import { findMetadata, findOrCreateMetadata, saveConstructorMetadata, createConstructorMetadata } from './metadata';
import { isSingleton } from './isSingleton';
import { Trace } from './Trace';
export * from './cheapDiSymbol.js';
export * from './CircularDependencyError.js';
export * from './ContainerImpl.js';
export * from './decorators/inject.js';
export * from './metadata.js';
export * from './isSingleton.js';
export * from './Trace.js';
export * from './types.js';
import { CircularDependencyError } from './CircularDependencyError.js';
import { ContainerImpl } from './ContainerImpl.js';
import { findMetadata, findOrCreateMetadata, saveConstructorMetadata, createConstructorMetadata } from './metadata.js';
import { isSingleton } from './isSingleton.js';
import { Trace } from './Trace.js';
declare const _default: {

@@ -19,3 +19,3 @@ cheapDiSymbol: symbol;

ContainerImpl: typeof ContainerImpl;
inject: import("./decorators/inject").InjectDecorator;
inject: import("./decorators/inject.js").InjectDecorator;
findMetadata: typeof findMetadata;

@@ -22,0 +22,0 @@ findOrCreateMetadata: typeof findOrCreateMetadata;

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

import { Dependency } from './types';
import { Dependency } from './types.js';
export declare function isSingleton<T, TClass extends Dependency<T>>(constructor: TClass): boolean;

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

import { AbstractConstructor, Constructor, DiMetadata, ImplementationType, SomeDependency } from './types';
import { AbstractConstructor, Constructor, DiMetadata, ImplementationType, SomeDependency } from './types.js';
export declare function saveConstructorMetadata<T>(constructor: Constructor<T> | AbstractConstructor<T>, ...dependencies: SomeDependency[]): DiMetadata;

@@ -3,0 +3,0 @@ export declare function findOrCreateMetadata<TClass>(constructor: ImplementationType<TClass>): DiMetadata;

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

import { cheapDiSymbol } from './cheapDiSymbol';
import { cheapDiSymbol } from './cheapDiSymbol.js';
type AbstractConstructor<T = any> = abstract new (...args: any[]) => T;

@@ -3,0 +3,0 @@ type Constructor<T = any> = new (...args: any[]) => T;

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