open-index/open-npm huggingface dataset:
npm package: @saber2pr/ioc
Description: a simple Injector for ioc
Author: saber2pr
Latest version: 0.0.7

<h1 align="center">@saber2pr/ioc</h1>
  <p align="center">
    <a href="https://www.npmjs.com/package/@saber2pr/ioc">
      <img src="https://img.shields.io/npm/v/@saber2pr/ioc.svg?color=blue" />
    </a>
  </p>
<h3 align="center">a simple Injector for ioc --- 快速的依赖注入IOC容器</h3>
<h3 align="center">兼容 Typescript，es6、es5</h3>

```bash
# from npm
npm install @saber2pr/ioc

# from github
git clone https://github.com/Saber2pr/saber-ioc.git

```

> 关于反射的实现 [@saber2pr/reflect](https://github.com/Saber2pr/-saber2pr-reflect)

# Feature

```ts
@Injectable()
class Service {
  public getUser() {
    return 'saber!'
  }
}

class Controller {
  public constructor(@Inject('Service') private Service: Service) {}

  // @InjectProp() private Service: Service

  public test() {
    console.log(this.Service.getUser())
  }
}

const app = Injector(Controller)

app.test() // 'saber!'
```

# API

1. @Injectable(id?) 注解一个类作为元数据依赖，若没有提供 id 参数，则默认注册 id 为类名

   `注意：`请确保 id 是全局唯一的！

2. @Inject(id) 注解一个依赖到目标类中(从注解参数)

   如果依赖类型是 Interface，请务必提供 Inject 注解。

3. @InjectProp(id) 注解一个依赖到目标类中(从属性注解)

4. @Singleton 注册一个类为单例

5. @Static 注册一个类为静态类

   `你可能已经发现这和@Singleton可能是一样的，你是对的`

6. Injector 执行依赖树 build，自动注入实例

   `注意保证依赖在注入之前已经声明`

---

## start

```bash
npm install
```

```bash
npm start

npm run build

npm test

```

---

## develope and test

> you should write ts in /src

> you should make test in /src/test

---

# Author

saber2pr

---

# License

MIT
npm package: @saber2pr/jsx-ast-parser
Description: jsx parser by parser combinators.
Author: saber2pr
Latest version: 0.1.2

# @saber2pr/jsx-ast-parser

[![npm](https://img.shields.io/npm/v/@saber2pr/jsx-ast-parser.svg?color=blue)](https://www.npmjs.com/package/@saber2pr/jsx-ast-parser)
[![codecov](https://codecov.io/gh/Saber2pr/jsx-ast-parser/branch/master/graph/badge.svg?token=DI9E88OIZU)](https://codecov.io/gh/Saber2pr/jsx-ast-parser)

> jsx parser by parser combinators.

```bash
yarn add @saber2pr/jsx-ast-parser
```

### Usage

```ts
import {
  parser,
  transformer,
  compiler,
  traverser,
} from '@saber2pr/jsx-ast-parser'

const code = `<div className="hello">world</div>`

const ast = parser.parse(code) // parse ast from code string
const jsx = transformer.transform(ast) // transform ast to jsx

// compile jsx to source code
compiler.compile(jsx) === code // true

// find jsx node
traverser.findNode(jsx, node => transformer.isTextElement(node)) // [ { tagName: 'text', nodeValue: 'world' } ]
```

#### Help

1. [Api Docs](https://saber2pr.top/jsx-ast-parser/)
2. [Jsx Ast Viewer](https://jsx-ast-viewer.vercel.app/)

- Profile
  - [see parser output ast.json](./public/ast.json)
  - [see transformer output jsx.json](./public/jsx.json)
  - [see compiler output out.jsx](./public/out.jsx)

### Feature

#### Overview Grammar BNF

[jsx.bnf](./public/jsx.bnf)

#### Syntax currently supported

- [ ] parser
  - [ ] jsx
    - [x] jsx opened
    - [x] jsx self closing
    - [ ] jsx props
      - [x] jsx props string-value
      - [x] jsx props number-value, bool-value
      - [x] jsx props object
      - [x] jsx props object-array
      - [x] jsx props string-array, number-array
      - [x] jsx props arrow function
        - [x] jsx props arrow function scope statements
      - [x] jsx props function
        - [x] jsx props function scope statements
  - [ ] statement
    - [x] call chain
    - [x] arrow function
    - [x] comment
    - [ ] arithmetic
    - [x] function
    - [x] define
    - [x] assign
    - [x] if else
    - [ ] for
    - [ ] while
    - [ ] try catch
    - [x] return
    - [ ] deconstruct
    - [ ] as
- [ ] transformer
  - [x] transform jsx
- [ ] traverser
  - [ ] traverse ast
  - [x] traverse jsx
- [ ] compiler
  - [ ] compile ast
  - [x] compile jsx

### Why

It started as a project for me to learn the principles of compilation, but now I'm confident I can make it better! I will continue to provide analysis tools for JSX code.