0.0.14 • Published 3 years ago

@zoranwong/pure-decorators v0.0.14

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

pure-decorators

pure-decorators is a class property decorator, we can use it to declare property type and class member method parameters type.

Instance

npm install --save @zoranwong/pure-decorators

Example code

import {string, int, number, unsigned, float, array, fun, 
ArrowFunction, Constructor, boolean, Enum, readonly, any, CheckType, method} from '@zoranwong/pure-decorators';
class P {}
const IPONE = 1;
const SUMSUNG =2;
const HUAWEI = 3;
const XIAOMI = 4;
class Test {
    @int
    intVar = -1;
    @unsigned
    uintVar = 1;
    @float
    floatVar = 0.01;
    @number
    num = 1;
    @string
    str = 'string';
    @array
    arr = [];
    @fun
    fun = function(){};
    @ArrowFunction
    arrow = () => {}
    @Constructor
    instance = class {};
    @Constructor(P)
    p = P
    @boolean
    isBoolean = false;
    @Enum([IPONE, SUMSUNG, HUAWEI, XIAOMI])
    mobile = IPONE;
    @readonly
    max = 1000;
    @any
    v = 1;
    @CheckType(P)
    p = new P;
    
    @method([string], string)
    log(p) {
        console.log(p);
        return p;
    }
}

Explanation

0.0.14

3 years ago

0.0.13

4 years ago

0.0.12

4 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago