1.1.0 • Published 4 years ago
@rinyii/get-class v1.1.0
get - class
1. introduction
install
npm i @rinyii/get-class
This module exports an object which consists of two parts.
- tools: provides some tools API to simlify your programming.
- isPrimitiveType
- getTypeOfPrimitiveValue
- getClassOfObj
- 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.