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

ioc-service-container

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ioc-service-container - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

6

Changelog.md

@@ -8,2 +8,8 @@ # Changelog

## [1.1.1] - 2020-02-18
### Changed
* Changed TypeScript compilation to `commonjs`
## [1.1.0] - 2020-02-16

@@ -10,0 +16,0 @@

13

dist/decorators.js

@@ -1,3 +0,9 @@

import ServiceContainer from './ServiceContainer';
export function inject(serviceIdOrTarget, propertyKey) {
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.inject = void 0;
const ServiceContainer_1 = __importDefault(require("./ServiceContainer"));
function inject(serviceIdOrTarget, propertyKey) {
if (typeof serviceIdOrTarget === 'string') {

@@ -10,5 +16,6 @@ return function (target, propertyKey) {

}
exports.inject = inject;
function redefineObject(target, propertyKey, serviceId) {
const getter = () => {
return ServiceContainer.get((serviceId === null || serviceId === void 0 ? void 0 : serviceId.toLowerCase()) || propertyKey.toLowerCase());
return ServiceContainer_1.default.get((serviceId === null || serviceId === void 0 ? void 0 : serviceId.toLowerCase()) || propertyKey.toLowerCase());
};

@@ -15,0 +22,0 @@ const setter = () => {

@@ -1,3 +0,10 @@

import ServiceContainer from './ServiceContainer';
import { inject } from './decorators';
export { ServiceContainer, inject };
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.inject = exports.ServiceContainer = void 0;
const ServiceContainer_1 = __importDefault(require("./ServiceContainer"));
exports.ServiceContainer = ServiceContainer_1.default;
const decorators_1 = require("./decorators");
Object.defineProperty(exports, "inject", { enumerable: true, get: function () { return decorators_1.inject; } });

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

export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
let services = [];
export default {
exports.default = {
set(id, factory) {

@@ -4,0 +6,0 @@ const lowerId = id.toLowerCase();

{
"name": "ioc-service-container",
"version": "1.1.0",
"version": "1.1.1",
"description": "Lightweight ioc service container",

@@ -31,3 +31,14 @@ "main": "dist/index.js",

"url": "https://github.com/mrcwbr/ioc-service-container"
}
},
"keywords": [
"ioc",
"inversion of control",
"di",
"dependency injection",
"service container",
"ioc container",
"service locator",
"javascript",
"typescript"
]
}

@@ -54,5 +54,2 @@ # ioc-service-container

```typescript
import { ServiceId } from './ServiceId';
import { ServiceContainer } from 'ioc-service-container';
const testService = ServiceContainer.get<TestService>(ServiceId.TestApi);

@@ -67,6 +64,8 @@ const testApi = ServiceContainer.get<TestService>(ServiceId.TestService);

@inject
private readonly testApi!: TestApi; // Important is the naming of the property, its mapped to the sericeId
private readonly customApi!: Api; // Important is the naming of the property, its mapped to the serice id
@inject(ServiceId.FooApi)
private readonly nameThisHowYouWant!: FooApi // If you don't want to name your property like the service id, use this decorator
@inject(ServiceId.FooApi) // If you don't want to name your property like the service id, use this decorator
private readonly nameThisHowYouWant!: Api;
private readonly barApi = ServiceContainer.get<Api>(ServiceId.BarApi) // Use this syntax if you don't want to use decorators
}

@@ -73,0 +72,0 @@ ```

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