1.1.0 • Published 4 years ago

@rinyii/get-class v1.1.0

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

get - class

1. introduction

install

npm i @rinyii/get-class

This module exports an object which consists of two parts.

  1. tools: provides some tools API to simlify your programming.
  • isPrimitiveType
  • getTypeOfPrimitiveValue
  • getClassOfObj
  1. decorator: enhance the function of class.
  • autoclass
  • autoenum

if you want to know more about decorator. Please read the doc in this module.

2. base use

const {tools, decorator} = require("@rinyii/get-class");

let foo = "hello";

console.log(tools.isPrimitiveType(foo)); // true
console.log(tools.getTypeOfPrimitiveValue(foo)); // string
console.log(tools.getClassOfObj(foo)); // TypeError

const autoclass = decorator.autoclass;
const autoenum = decorator.autoenum;

@autoclass
@autoenum
class Person {
    static LINDA;
    static LISA;
    static DAVID;
}

console.log(Person.LINDA.name()); // LINDA
console.log(Person.getClass()); // Person

notice: decorator needs to use babel.

1.1.0

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago