@41t/model

0.0.2 • Public • Published

Model

A small project for simplified creation of classes with protected properties.

Creates an abstract model class for further inheritance and implementation of methods.

Run Locally

Clone the project

git clone https://github.com/Ishi-Inanis/model

Go to the project directory

Usage

const <YourNameNewModelClass> = Model({
    <property>: {
        type: function,
        [set: boolean],     // default true
        [get: boolean],     // default true
        [required: boolean] // default false
    } 
});

Examples

const TestModel = Model({
  name: { type: String, set: true, get: true, required: true },
  num: { type: Number, set: true, get: true }
});

const test = new TestModel({ name: '', num: 0 });

console.log(test);
const TestModel = Model({
  name: { type: String, set: true, get: true, required: true },
  num: { type: Number, set: true, get: true }
});

class Test extends TestModel {
  constructor(params) {
    super(params);
  }
}

console.log(new Test({ name: '', num: 0 }));

Roadmap

  • [] Add all primitive type support
  • [] Add unit tests

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i @41t/model

Weekly Downloads

2

Version

0.0.2

License

MIT

Unpacked Size

4.56 kB

Total Files

4

Last publish

Collaborators

  • zxxxr
  • ishi-inanis