Skip to content

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

License

Notifications You must be signed in to change notification settings

alexeev-dauwalter/model

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

41t: official

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

License: MIT

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published