Skip to content
forked from tmg0/yorjs

A DI lib for javascript / typescript. Without dependency of reflect metadata. Can be used with esbuild.

License

Notifications You must be signed in to change notification settings

MTTMTTMTT/yorjs

 
 

Repository files navigation

Yorjs

NPM version

A DI lib for javascript / typescript. Without dependency of reflect metadata. Can be used with esbuild.

Installation

import package

# use npm
npm install @yorjs/core

# use pnpm
pnpm add @yorjs/core

import module

import { } from '@yorjs/core'

Packages

Package Version (click for document)
@yorjs/core NPM version
@yorjs/cli NPM version
@yorjs/shared NPM version

Usage

Core

A basic usage of yor. Include define provider / controller / interface / module

import { defineProvider, defineController, defineInterface,  useModule } from '@yorjs/core'

const IProvider = defineInterface<{
  do: () => string
}>()

const IController = defineController<{
  result: string
  do: () => void
}>()

const provider = defineProvider().implements(IProvider).setup(() => ({
  do() { return 'done' }
}))

const controller = defineController().implements(IController).inject(IProvider).setup((p) => {
  let result = ''

  return {
    result,
    do() {
      result = p.do()
    }
  }
})

Use module in vue component

<script>
import { useModule } from '@yorjs/core'
import { userModule } from '../user.module'

<script setup lang="ts">
const userModule = useModule(userModule)
</script>

Cli

The recommended way to create a yor module.

Install cli tool

# use npm
npm i @yorjs/cli -g

# use pnpm
pnpm add @yorjs/cli -g

Basic usage

yor create -h

-V, --version     output the version number
-M, --module      yor module
-I, --interface   yor interface
-P, --provider    yor provider
-C, --controller  yor controller
-h, --help        display help for command

License

MIT

About

A DI lib for javascript / typescript. Without dependency of reflect metadata. Can be used with esbuild.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 77.3%
  • JavaScript 19.9%
  • Vue 1.5%
  • HTML 1.3%