1.0.1 • Published 2 years ago

processor-unit v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

Processor-unit

Make an Decorator processor with processor-unit.

Installation

Processor-unit requires

npm i -g processor-unit

Example

Create your first processor project:
  • open your terminal and type :
mkdir myfirstProcessor
cd myfirstProcessor

tsc --init
npm init --yes
npm i --save ts-morph stricttype
Save myfirstProcessor as processor project

open your terminal and type :

process

choose save as Processor

Test your processor
  • create a project to test processor
mkdir Test
cd Test

tsc --init
npm init --yes

Person.ts

    
    export class Person{
        hello(@cast newPerson:Person){
            console.log(new Person());
        }    
    }

index.ts

    //import generated function and call
    import * as callback from "./strict/cast"
    Object.values(callback).forEach(v=>v())
    import {Person} from "./Person"
    
    new Person().hello({} as any);
    // output: Person{}
    new Person().hello(2 as any);
    // output: Error: 2 cannot be cast to Person
  • generate file
process

select cast

License

MIT