npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jsmf-jstl

v0.11.0

Published

Model transformation for JSTL

Downloads

19

Readme

JSMF-JSTL

JSTL is a model to model transformation engine that handle JSMF models. JSTL simplifies the transformation writing while leaving some responsibilities to the transformation developer following JavaScript way of thinking (e.g., the developer has to check for concurrent rules).

Install

Thanks to npm: npm install jsmf-jstl

Usage and Example

if you are not familiar with JSMF-CORE please see it first: https://github.com/JS-MF/jsmf-core.

In JSTL you define a set of transformation rules as inspired by ATL transformation Engine for EMF (https://eclipse.org/atl/). Transformation rules an composed by input (in) and an output (out) pattern functions. The input is a function that process elements of a given input model, it provides the "set of element" that corresponds to a given pattern. For instance this function can return all the elements that a "name" attributes or all elements that are conform to metaClass "Person". The output pattern iterates over the fitered element and can create output elements for each of those.

You can also use Javascript function as helper and call them into the transformation rules. Alike ATL, you can define helper attributes: function that will be launch once and that produce a value available in all transformations.

Let's take a simple example from ATL (https://wiki.eclipse.org/ATL/Tutorials_-_Create_a_simple_ATL_transformation). In this example, we first select all the element conform to Member of the Family metamodel (named MMI). Then, we filter (using lodash _.filter) and returning the result of the helper function isFemale().


//Helper function
function isFemale(member) {
    //Warning writting the function name... checking empty table
    return (member.familyMother.length!=0 || member.familyDaughter.length!=0);
}

var Member2Female = {

    in : function(inputModel) {
        return  _.filter(inputModel.Filter(MMI.Member),
                    function(elem){
                        return isFemale(elem);
                    });
    },

    out : function(inp) {
        var d = MMO.Female.newInstance('');
        familyName(inp);
        d.setFullName(inp.firstName+' '+familyName(inp));
        return [d];
    }
}

Launching the transformation is made by creating a new Transformation then by adding the rules it contains.

var transformation = new Transformation();
transformation.addRule(Member2FeMale);
transformation.addRule(Member2Male);

Execution of transformation rule is made using the apply function on a transformation. The parameters are the input Model and output model (as defined in JSMF).

transformation.apply(M.ma, M.mb);

You can find examples, discover the other components and test it online with Tonic on JSMF github website (https://js-mf.github.io/#portfolio)

License information

See License.