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

@furystack/inject

Package Overview
Dependencies
Maintainers
1
Versions
151
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@furystack/inject - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

3

dist/Injector.d.ts

@@ -7,2 +7,3 @@ import { IDisposable } from "@sensenet/client-utils";

parent: Injector;
owner: any;
};

@@ -12,5 +13,5 @@ static Default: Injector;

private cachedSingletons;
GetInstance<T>(ctor: Constructable<T>, dependencies?: Array<Constructable<T>>): T;
GetInstance<T>(ctor: Constructable<T>, local?: boolean, dependencies?: Array<Constructable<T>>): T;
SetInstance<T>(instance: T, key?: Constructable<any>): void;
constructor(options?: Partial<Injector["options"]>);
}

@@ -7,2 +7,3 @@ "use strict";

parent: Injector.Default,
owner: null,
};

@@ -23,3 +24,3 @@ this.meta = new Map();

}
GetInstance(ctor, dependencies = []) {
GetInstance(ctor, local = false, dependencies = []) {
if (dependencies.includes(ctor)) {

@@ -31,7 +32,7 @@ throw Error(`Circular dependencies found.`);

}
const fromParent = this.options.parent && this.options.parent.GetInstance(ctor);
const fromParent = !local && this.options.parent && this.options.parent.GetInstance(ctor);
if (fromParent) {
return fromParent;
}
const deps = (this.meta.get(ctor) || []).map((dep) => this.GetInstance(dep, [...dependencies, ctor]));
const deps = (this.meta.get(ctor) || []).map((dep) => this.GetInstance(dep, local, [...dependencies, ctor]));
const newInstance = new ctor(...deps);

@@ -38,0 +39,0 @@ this.SetInstance(newInstance);

{
"name": "@furystack/inject",
"version": "1.0.0",
"version": "1.0.1",
"description": "Core FuryStack package",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -16,4 +16,5 @@ import { IDisposable } from "@sensenet/client-utils";

public options: { parent: Injector } = {
public options: { parent: Injector, owner: any } = {
parent: Injector.Default,
owner: null,
};

@@ -26,3 +27,3 @@

public GetInstance<T>(ctor: Constructable<T>, dependencies: Array<Constructable<T>> = []): T {
public GetInstance<T>(ctor: Constructable<T>, local: boolean = false, dependencies: Array<Constructable<T>> = []): T {
if (dependencies.includes(ctor)) {

@@ -34,7 +35,7 @@ throw Error(`Circular dependencies found.`);

}
const fromParent = this.options.parent && this.options.parent.GetInstance(ctor);
const fromParent = !local && this.options.parent && this.options.parent.GetInstance(ctor);
if (fromParent) {
return fromParent;
}
const deps = (this.meta.get(ctor) || []).map((dep) => this.GetInstance(dep, [...dependencies, ctor]));
const deps = (this.meta.get(ctor) || []).map((dep) => this.GetInstance(dep, local, [...dependencies, ctor]));
const newInstance = new ctor(...deps);

@@ -41,0 +42,0 @@ this.SetInstance(newInstance);

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