mana-syringe
Advanced tools
+3
-6
| { | ||
| "name": "mana-syringe", | ||
| "keywords": [], | ||
| "version": "0.2.1", | ||
| "version": "0.2.2-next.0", | ||
| "typings": "dist/index.d.ts", | ||
| "main": "dist/index.js", | ||
| "module": "dist/index.esm.js", | ||
| "browser": "index.umd.js", | ||
| "unpkg": "dist/index.umd.min.js", | ||
| "files": [ | ||
@@ -18,5 +18,2 @@ "package.json", | ||
| }, | ||
| "devDependencies": { | ||
| "mana-scripts": "^0.2.0" | ||
| }, | ||
| "scripts": { | ||
@@ -29,3 +26,3 @@ "prepare": "yarn run clean && yarn run build", | ||
| }, | ||
| "gitHead": "8d6f4622e203b5df7ead3650699aeb8dca719a03" | ||
| "gitHead": "59e398ac381ef9128036a6b42c8994d7452c3b86" | ||
| } |
@@ -5,2 +5,4 @@ import assert from 'assert'; | ||
| import { Syringe } from './core'; | ||
| import { contrib, Contribution } from './contribution'; | ||
| import { Module } from './module'; | ||
@@ -198,2 +200,51 @@ describe('container', () => { | ||
| }); | ||
| it('#remove contrib', () => { | ||
| const FooSymbol = Syringe.defineToken('FooSymbol'); | ||
| @singleton({ contrib: FooSymbol }) | ||
| class FooContribution {} | ||
| @singleton({ contrib: FooSymbol }) | ||
| class BarContribution {} | ||
| register(FooContribution); | ||
| register(BarContribution); | ||
| const contribs = GlobalContainer.getAll(FooSymbol); | ||
| assert(contribs.length === 2); | ||
| assert(contribs[0] instanceof FooContribution); | ||
| GlobalContainer.remove(FooSymbol); | ||
| assert(!GlobalContainer.isBound(FooSymbol)); | ||
| register(FooContribution); | ||
| const emptyContribs = GlobalContainer.getAll(FooSymbol); | ||
| assert(emptyContribs.length === 1); | ||
| }); | ||
| it('#remove contrib in module', () => { | ||
| const FooSymbol = Syringe.defineToken('FooSymbol'); | ||
| @singleton({ contrib: FooSymbol }) | ||
| class FooContribution {} | ||
| @singleton({ contrib: FooSymbol }) | ||
| class BarContribution {} | ||
| @singleton() | ||
| class Foo { | ||
| constructor(@contrib(FooSymbol) public provider: Contribution.Provider<Record<any, any>>) {} | ||
| } | ||
| // const fooModule = Module().contribution(FooSymbol).register(Foo, FooContribution); | ||
| const fooModule = Module(reg => { | ||
| Contribution.register(reg, FooSymbol, { cache: false }); | ||
| reg(Foo); | ||
| reg(FooContribution); | ||
| }); | ||
| const barModule = Module((reg, ctx) => { | ||
| ctx.container.remove(FooSymbol); | ||
| reg(BarContribution); | ||
| }); | ||
| GlobalContainer.load(fooModule); | ||
| const foo = GlobalContainer.get(Foo); | ||
| const contribs = foo.provider.getContributions(); | ||
| assert(contribs.length === 1); | ||
| assert(contribs[0] instanceof FooContribution); | ||
| GlobalContainer.load(barModule); | ||
| const newContribs = foo.provider.getContributions({ cache: false }); | ||
| assert(newContribs.length === 1); | ||
| assert(newContribs[0] instanceof BarContribution); | ||
| }); | ||
| }); | ||
@@ -200,0 +251,0 @@ describe('basic', () => { |
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
864348
0.23%0
-100%9131
0.54%