How to use the objectmodel.Model function in objectmodel

To help you get started, we’ve selected a few objectmodel examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sylvainpolletvillard / ObjectModel / docs / examples / class-usage.js View on Github external
import { Model } from "objectmodel";

class Character extends Model({ lastName: String, firstName: String }) {
	get fullName() {
		return `${this.firstName} ${this.lastName}`;
	}
}

const rick = new Character({ lastName: "Sanchez", firstName: "Rick" });
rick.lastName = 132;
//TypeError: expecting lastName to be String, got Number 132
console.log(rick.fullName); // "Rick Sanchez"

objectmodel

Strong Dynamically Typed Object Modeling for JavaScript

MIT
Latest version published 11 months ago

Package Health Score

65 / 100
Full package analysis