Skip to content

Commit

Permalink
Prepare v4 release (microsoft#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
Xapphire13 authored Nov 2, 2019
1 parent 89da698 commit 3898663
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 22 deletions.
31 changes: 15 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,25 @@ on: [push]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [8.x, 10.x, 12.x]

steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install yarn
run: |
npm -g i yarn
- name: npm install, build, and test
run: |
yarn
yarn build --if-present
yarn test
env:
CI: true
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install yarn
run: |
npm -g i yarn
- name: npm install, build, and test
run: |
yarn
yarn build
yarn test
env:
CI: true
6 changes: 6 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,23 @@ coverage/
# Source code
src/

# Logs
*.log

# Tests
test/
*.test.js

# Configs
.github/
.vscode/
.travis.yml
tsconfig.json
typescript/
.eslintrc.yml
.prettierrc.yml
.huskyrc.json
.nvmrc

# Lock files
yarn.lock
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@
"[typescriptreact]": {
"editor.formatOnSave": false,
},
"markdown.extension.toc.levels": "1..3",
}
35 changes: 33 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,25 @@
A lightweight dependency injection container for TypeScript/JavaScript for
constructor injection.

<!-- TOC depthFrom:1 depthTo:2 -->
<!-- TOC depthFrom:1 depthTo:3 -->

- [TSyringe](#tsyringe)
- [Installation](#installation)
- [API](#api)
- [Decorators](#decorators)
- [injectable()](#injectable)
- [singleton()](#singleton)
- [autoInjectable()](#autoinjectable)
- [inject()](#inject)
- [injectAll()](#injectall)
- [scoped()](#scoped)
- [Container](#container)
- [Manual resolution](#manual-resolution)
- [Injection Token](#injection-token)
- [Providers](#providers)
- [Register](#register)
- [Registry](#registry)
- [Resolution](#resolution)
- [Child Containers](#child-containers)
- [Full examples](#full-examples)
- [Example without interfaces](#example-without-interfaces)
- [Example with interfaces](#example-with-interfaces)
Expand Down Expand Up @@ -183,6 +194,26 @@ class Bar {
}
```

### scoped()

Class decorator factory that registers the class as a scoped dependency within the global container.

#### Available scopes
- ResolutionScoped
- The same instance will be resolved for each resolution of this dependency during a single
resolution chain
- ContainerScoped
- The dependency container will return the same instance each time a resolution for this dependency
is requested. This is similar to being a singleton, however if a child container is made, that child
container will resolve an instance unique to it.

#### Usage

```typescript
@scoped(Lifecycle.ContainerScoped)
class Foo {}
```

## Container

The general principle behind [Inversion of Control](https://en.wikipedia.org/wiki/Inversion_of_control) (IoC) containers
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
"name": "tsyringe",
"version": "3.4.0",
"version": "4.0.0",
"description": "Lightweight dependency injection container for JavaScript/TypeScript",
"main": "dist/cjs/index.js",
"module": "./dist/esm5/index.js",
"es2015": "./dist/esm2015/index.js",
"typings": "./dist/typings/index.d.ts",
"scripts": {
"build": "npm run clean && npm run build:cjs && npm run build:es5 && npm run build:es2015 && npm run build:types",
"build": "yarn clean && yarn build:cjs && yarn build:es5 && yarn build:es2015 && yarn build:types",
"build:cjs": "tsc",
"build:es5": "tsc -p ./typescript/tsconfig.esm5.json",
"build:es2015": "tsc -p ./typescript/tsconfig.esm2015.json",
"build:types": "tsc -p ./typescript/tsconfig.types.json",
"clean": "rimraf ./dist",
"test": "npm run lint && jest --config test/jest.config.js",
"test:inspect": "npm run lint && node --inspect-brk ./node_modules/jest/bin/jest.js --runInBand --config test/jest.config.js",
"test": "yarn lint && jest --config test/jest.config.js",
"test:inspect": "yarn lint && node --inspect-brk ./node_modules/jest/bin/jest.js --runInBand --config test/jest.config.js",
"test:coverage": "jest --config test/jest.config.js --coverage",
"lint": "eslint --ext \".js,.jsx,.ts,.tsx\" \"./src\"",
"lint:fix": "eslint --fix --ext \".js,.jsx,.ts,.tsx\" \"./src\""
Expand Down

0 comments on commit 3898663

Please sign in to comment.