![From Academia to Industry](https://cdn.sanity.io/images/cgdhsj6q/production/70501690bf807891573e259da9719cf24302c7e3-4288x2848.jpg?w=400&fit=max&auto=format)
Employee Spotlight
From Academia to Industry
Philipp Burckhardt recounts his journey from childhood computer fascinations, to building an e-learning platform at Carnegie Mellon University, and on to his current role at Socket.
moddle
Advanced tools
Readme
A utility library for working with meta-model based data structures.
moddle offers you a concise way to define meta models in JavaScript. You can use these models to consume documents, create model elements and perform model validation.
A moddle description is a simple JSON file that describes types, their properties and relationships:
{
"name": "Cars",
"uri": "http://cars",
"prefix": "c",
"types": [
{
"name": "Base",
"properties": [
{ "name": "id", "type": "String", "isAttr": true }
]
},
{
"name": "Root",
"superClass": [ "Base" ],
"properties": [
{ "name": "cars", "type": "Car", "isMany": true }
]
},
{
"name": "Car",
"superClass": [ "Base" ],
"properties": [
{ "name": "name", "type": "String", "isAttr": true, "default": "No Name" },
{ "name": "power", "type": "Integer", "isAttr": true },
{ "name": "similar", "type": "Car", "isMany": true, "isReference": true }
]
}
]
}
moddle allows you to instantiate that definition and create objects from it:
import { Moddle } from 'moddle';
var cars = new Moddle([ carsJSON ]);
var taiga = cars.create('c:Car', { name: 'Taiga' });
console.log(taiga);
// { $type: 'c:Car', name: 'Taiga' };
var cheapCar = cars.create('c:Car');
console.log(cheapCar.name);
// "No Name"
// really?
cheapCar.get('similar').push(taiga);
Then again, moddle allows you to perform introspection on model instances, too.
var carDescriptor = cheapCar.$descriptor;
console.log(carDescriptor.properties);
// [ { name: 'id', type: 'String', ... }, { name: 'name', type: 'String', ...} ... ]
Have a look at our test coverage to learn about everything that is currently supported.
MIT
FAQs
A library for importing meta-model based file formats into JS
The npm package moddle receives a total of 79,521 weekly downloads. As such, moddle popularity was classified as popular.
We found that moddle demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Employee Spotlight
Philipp Burckhardt recounts his journey from childhood computer fascinations, to building an e-learning platform at Carnegie Mellon University, and on to his current role at Socket.
Security News
Git dependencies in open source packages can introduce significant risks, including lack of version control, stability issues, dependency drift, and difficulty in auditing, making them potential targets for supply chain attacks.
Security News
Node.js has added experimental support for TypeScript, a move that highlights the growing importance of TypeScript in modern development.