New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@microgamma/digator

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@microgamma/digator - npm Package Compare versions

Comparing version 1.14.2 to 1.14.6-beta.0

17

CHANGELOG.md
# Change Log
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.14.6-beta.0](https://github.com/davidecavaliere/-microgamma/compare/v1.14.5...v1.14.6-beta.0) (2020-01-20)
### Features
* **digator:** adding function to set singleton implementation ([e8944d4](https://github.com/davidecavaliere/-microgamma/commit/e8944d4edfeeab7aa9967a3d9d6f817fb52cd4e3))
* **digator:** TestBed should use setImplementation ([2ca9231](https://github.com/davidecavaliere/-microgamma/commit/2ca92318f44ad7ca46478102fa445746ef820e05))
# Change Log
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

@@ -4,0 +21,0 @@

6

lib/lib/inject/inject.decorator.d.ts
export declare function Inject(classDef: any): PropertyDecorator;
export declare function getSingleton(className: any, implementation?: any): any;
export declare function getSingleton<T>(className: any, implementation?: any): T;
export declare function getSingletons(): {
[className: string]: any;
};
export declare function setImplementation({ provide, implementation }: {
provide: any;
implementation: any;
}): void;

@@ -36,2 +36,11 @@ "use strict";

exports.getSingletons = getSingletons;
function setImplementation({ provide, implementation }) {
d('setting implementation');
d({ provide });
d({ implementation });
const name = typeof provide === 'string' ? provide : provide.name;
d('resetting implementation for', provide, 'with', implementation);
singletons[name] = implementation;
}
exports.setImplementation = setImplementation;
//# sourceMappingURL=inject.decorator.js.map

12

lib/lib/testing/test-bed.js

@@ -7,14 +7,8 @@ "use strict";

class TestBed {
// private singletons = new Map<ClassType<any>, any>();
constructor(config) {
d('creating testBed');
config.providers.forEach((provider) => {
if (provider instanceof Function) {
__1.getSingleton(provider);
}
else {
const provide = provider.provide;
const useClass = provider.useClass;
__1.getSingleton(provide, useClass);
}
const provide = provider.provide;
const useClass = provider.useClass;
__1.setImplementation({ provide, implementation: useClass });
});

@@ -21,0 +15,0 @@ }

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

providers: [
TestClassA,
{

@@ -43,3 +42,2 @@ provide: TestClassB,

expect(__1.getSingletons()).toEqual({
TestClassA: expect.anything(),
TestClassB: expect.anything()

@@ -50,5 +48,21 @@ });

const singletons = __1.getSingletons();
expect(singletons['TestClassB'] instanceof MockImplementationTestClassB).toBeTruthy();
expect(singletons['TestClassB']).toEqual(MockImplementationTestClassB);
});
describe('a second TestBed which provides a different implementation is create', () => {
class MockImplementationTestClassBSecond {
}
beforeEach(() => {
// tslint:disable-next-line:no-unused-expression
new test_bed_1.TestBed({
providers: [{
provide: TestClassB,
useClass: MockImplementationTestClassBSecond
}]
});
});
it('should provide the second implementation', () => {
expect(__1.getSingleton(TestClassB)).toEqual(MockImplementationTestClassBSecond);
});
});
});
//# sourceMappingURL=test-bed.spec.js.map
export interface SingletonType<T = any> extends Function {
new (...args: any[]): T;
}
export interface SingletonWithImplementation {
export interface SingletonDefinition {
provide: SingletonType;
useClass: SingletonType;
}
export declare type SingletonDefinition = SingletonWithImplementation | SingletonType;
export interface TestBedConfiguration {

@@ -10,0 +9,0 @@ providers: SingletonDefinition[];

{
"name": "@microgamma/digator",
"version": "1.14.2",
"version": "1.14.6-beta.0",
"description": "easiest simplest dependency injection container around",

@@ -75,3 +75,3 @@ "main": "lib/index.js",

},
"gitHead": "c1e0847e0b2f2383f1bc434be61a848cf7007e0c"
"gitHead": "b99c5628fded81526a5081df6bb33f1d1be8443f"
}

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