OCL.js is entirely written in JavaScript and served either via npm or GitHub. It is designed to run either in a node environment or in the browser.

To add OCL.js to your project install it via npm as follows and you are good to go:

$ npm install @stekoe/ocl.js –save

As alternative, you can also download the ocl.min.js file from GitHub and include that to your code.

Use as ES6 module

When adding OCL.js via npm, you can start using it via importing the OCLEngine that is provided by “@stekoe/ocl.js”.

import OCLEngine from "@stekoe/ocl.js"

const myOclExpression = `
    context Person
        inv: self.parents->forAll(p | p <> self)

// Instantiate the OclEngine here
const oclEngine = new OclEngine()

// Add your first OCL expression here

// Evaluate an object obj against all know OCL expressions