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

dependency-inject

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dependency-inject - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

1

built/all.test.js

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

});
console.log(123, result);
result.Action.setNum(2);

@@ -73,0 +72,0 @@ t.true(result.group.Store.num === 2);

4

built/demo/index.js

@@ -46,5 +46,3 @@ "use strict";

var result = index_1.injectFactory({
group: {
Store: Store
},
Store: Store,
Action: Action

@@ -51,0 +49,0 @@ });

{
"name": "dependency-inject",
"version": "1.1.0",
"version": "1.1.1",
"description": "",

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

@@ -33,1 +33,48 @@ # DependencyInject

```
# Simple useage by injectFactory
```typescript
import { injectFactory } from 'dependency-inject'
class Store {
num = 1
}
class Action {
@inject(Store)
private store: Store
setNum(num: number) {
this.store.num = num
}
}
const stores = injectFactory({Store, Action})
// stores.Store.num === 1
// stores.Action.setNum
```
## nested object
```typescript
import { injectFactory } from 'dependency-inject'
class Store {
num = 1
}
class Action {
@inject(Store)
private store: Store
setNum(num: number) {
this.store.num = num
}
}
const stores = injectFactory({
groupA: Store,
groupB: {
groupC: Action
}
})
```

@@ -65,6 +65,4 @@ import test from 'ava'

console.log(123, result)
result.Action.setNum(2)
t.true(result.group.Store.num === 2)
})

@@ -11,2 +11,6 @@ import Container from "./container"

type Partial<T> = {
[P in keyof T]?: T[P];
}
/**

@@ -16,3 +20,3 @@ * 快速实例化,key: string value: Class

*/
export function injectFactory<T>(obj: ICombineActions<T>): T {
export function injectFactory<T>(obj: ICombineActions<T>): Partial<T> {
const container = new Container()

@@ -19,0 +23,0 @@

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